Skip to content

Commit

Permalink
Assigning label to the element, thus avoiding need to get the data-la…
Browse files Browse the repository at this point in the history
…bel from the element.
  • Loading branch information
gauravsinghania committed Jul 16, 2015
1 parent 3820832 commit 4782bd6
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 30 deletions.
1 change: 1 addition & 0 deletions src/kibana/components/vislib/lib/data.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ define(function (require) {
if (this.type === 'series') {
if (getLabels(data).length === 1 && getLabels(data)[0] === '') {
this.labels = [(this.get('yAxisLabel'))];
this.data.series[0].label = this.get('yAxisLabel');
} else {
this.labels = getLabels(data);
}
Expand Down
12 changes: 2 additions & 10 deletions src/kibana/components/vislib/visualizations/area_chart.js
Original file line number Diff line number Diff line change
Expand Up @@ -96,11 +96,7 @@ define(function (require) {
var path = layer.append('path')
.call(this._addIdentifier)
.style('fill', function (d) {
var label = d[0].label;
if (!label) {
label = this.getAttribute('data-label');
}
return color(label);
return color(d[0].label);
})
.classed('overlap_area', function () {
return isOverlapping;
Expand Down Expand Up @@ -183,11 +179,7 @@ define(function (require) {
.append('circle')
.call(this._addIdentifier)
.attr('stroke', function strokeColor(d) {
var label = d.label;
if (!label) {
label = this.getAttribute('data-label');
}
return color(label);
return color(d.label);
})
.attr('fill', 'transparent')
.attr('stroke-width', circleStrokeWidth);
Expand Down
6 changes: 1 addition & 5 deletions src/kibana/components/vislib/visualizations/column_chart.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,11 +73,7 @@ define(function (require) {
.append('rect')
.call(this._addIdentifier)
.attr('fill', function (d) {
var label = d.label ;
if (!label) {
label = this.getAttribute('data-label');
}
return color(label);
return color(d.label);
});

self.updateBars(bars);
Expand Down
18 changes: 3 additions & 15 deletions src/kibana/components/vislib/visualizations/line_chart.js
Original file line number Diff line number Diff line change
Expand Up @@ -113,15 +113,7 @@ define(function (require) {
}

function cColor(d) {
getColor(d, this);
}

function getColor(d, circleElement) {
var label = d.label;
if (!label) {
label = circleElement.getAttribute('data-label');
}
return color(label);
return color(d.label);
}

function colorCircle(d) {
Expand All @@ -131,7 +123,7 @@ define(function (require) {

// If only 1 point exists, show circle
if (!showCircles && !isVisible) return 'none';
return getColor(d, this);
return cColor(d);
}
function getCircleRadiusFn(modifier) {
return function getCircleRadius(d) {
Expand Down Expand Up @@ -218,11 +210,7 @@ define(function (require) {
})
.attr('fill', 'none')
.attr('stroke', function lineStroke(d) {
var label = d.label;
if (!label) {
label = this.getAttribute('data-label');
}
return color(label);
return color(d.label);
})
.attr('stroke-width', 2);

Expand Down

0 comments on commit 4782bd6

Please sign in to comment.