Skip to content

Commit

Permalink
Merge pull request #3197 from stormpython/enhancement/3176
Browse files Browse the repository at this point in the history
adding feature to remove circles when option to remove circles selected
  • Loading branch information
w33ble committed Mar 4, 2015
2 parents e0bea02 + 2b2d0f5 commit cde5f15
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 3 deletions.
15 changes: 13 additions & 2 deletions src/kibana/components/vislib/visualizations/line_chart.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ define(function (require) {
*/
LineChart.prototype.addCircles = function (svg, data) {
var self = this;
var showCircles = this._attr.showCircles;
var color = this.handler.data.getColorFunc();
var xScale = this.handler.xAxis.xScale;
var yScale = this.handler.yAxis.yScale;
Expand All @@ -81,7 +82,7 @@ define(function (require) {
.attr('class', 'points line');

var circles = layer
.selectAll('rect')
.selectAll('circle')
.data(function appendData(d) {
return d;
});
Expand All @@ -105,13 +106,23 @@ define(function (require) {
return color(d.label);
}

function colorCircle(d) {
var parent = d3.select(this).node().parentNode;
var lengthOfParent = d3.select(parent).data()[0].length;
var isVisible = (lengthOfParent === 1);

// If only 1 point exists, show circle
if (!showCircles && !isVisible) return 'none';
return cColor(d);
}

circles
.enter()
.append('circle')
.attr('r', visibleRadius)
.attr('cx', cx)
.attr('cy', cy)
.attr('fill', cColor)
.attr('fill', colorCircle)
.attr('class', 'circle-decoration');

circles
Expand Down
8 changes: 8 additions & 0 deletions src/kibana/plugins/vis_types/vislib/editors/line.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<!-- vis type specific options -->
<vislib-basic-options></vislib-basic-options>
<div class="vis-option-item form-group">
<label>
<input type="checkbox" value="{{showCircles}}" ng-model="vis.params.showCircles" name="showCircles" ng-checked="vis.params.showCircles">
Show Circles
</label>
</div>
3 changes: 2 additions & 1 deletion src/kibana/plugins/vis_types/vislib/line.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,10 @@ define(function (require) {
shareYAxis: true,
addTooltip: true,
addLegend: true,
showCircles: true,
defaultYExtents: false
},
editor: require('text!plugins/vis_types/vislib/editors/basic.html')
editor: require('text!plugins/vis_types/vislib/editors/line.html')
},
schemas: new Schemas([
{
Expand Down

0 comments on commit cde5f15

Please sign in to comment.