Skip to content
This repository has been archived by the owner on Mar 31, 2024. It is now read-only.

Commit

Permalink
Merge pull request #7 from jthomassie/2803
Browse files Browse the repository at this point in the history
add endzones to 2803
  • Loading branch information
stormpython committed Feb 2, 2015
2 parents 2ec49ab + df4dd78 commit 0fe3d4f
Show file tree
Hide file tree
Showing 2 changed files with 71 additions and 0 deletions.
66 changes: 66 additions & 0 deletions src/kibana/components/vislib/lib/dispatch.js
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,9 @@ define(function (require) {
if (!this.isBrushable()) return;

var xScale = this.handler.xAxis.xScale;
var yScale = this.handler.xAxis.xScale;
var brush = this.createBrush(xScale, svg);
var endZones = this.createEndZones(xScale, yScale, svg);

function brushEnd() {
var bar = d3.select(this);
Expand Down Expand Up @@ -241,6 +243,70 @@ define(function (require) {
}
};

/**
* Creates rects to show buckets outside of the ordered.min and max, returns rects
*
* @param xScale {Function} D3 xScale function
* @param svg {HTMLElement} Reference to SVG
* @method createEndZones
* @returns {D3.Selection}
*/
Dispatch.prototype.createEndZones = function (xScale, yScale, svg) {
var attr = this.handler._attr;
var height = attr.height;
var width = attr.width;
var margin = attr.margin;
var ordered = this.handler.xAxis.ordered;
var xVals = this.handler.xAxis.xValues;
var color = '#004c99';
var data = [
{
x: 0,
w: xScale(ordered.min) > 0 ? xScale(ordered.min) : 0
},
{
x: xScale(ordered.max),
w: width - xScale(ordered.max) > 0 ? width - xScale(ordered.max) : 0
}
];

// svg diagonal line pattern
var pattern = svg.append('defs')
.append('pattern')
.attr('id', 'DiagonalLines')
.attr('patternUnits', 'userSpaceOnUse')
.attr('patternTransform', 'rotate(45)')
.attr('x', '0')
.attr('y', '0')
.attr('width', '4')
.attr('height', '4')
.append('rect')
.attr('stroke', 'none')
.attr('fill', color)
.attr('width', 2)
.attr('height', 4);

var endzones = svg.selectAll('.layer')
.data(data)
.enter()
.insert('g', '.brush')
.attr('class', 'endzone')
.append('rect')
.attr('class', 'zone')
.attr('x', function (d) {
return d.x;
})
.attr('y', 0)
.attr('height', height - margin.top - margin.bottom)
.attr('width', function (d) {
return d.w;
})
.attr('fill', 'url(#DiagonalLines)');

return endzones;
};


return Dispatch;
};
});
5 changes: 5 additions & 0 deletions src/kibana/components/vislib/styles/_svg.less
Original file line number Diff line number Diff line change
Expand Up @@ -61,3 +61,8 @@ path {
stroke: #333;
}
}

.endzone {
opacity: 0.2;
pointer-events: none;
}

0 comments on commit 0fe3d4f

Please sign in to comment.