Skip to content

Commit

Permalink
small update to allow the line label to have its own distinct classna…
Browse files Browse the repository at this point in the history
…me by default.
  • Loading branch information
heavysixer committed Jul 23, 2014
1 parent fba9b5e commit a7f7702
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 14 deletions.
10 changes: 6 additions & 4 deletions d4.js
Original file line number Diff line number Diff line change
Expand Up @@ -3206,8 +3206,8 @@
}.bind(this));
},

pointLabelText: function(d) {
var str = this.x.$key + ': ' + d[this.x.$key];
pointLabelText: function(d, datum) {
var str = datum.key + ' ' + this.x.$key + ': ' + d[this.x.$key];
str += ' ' + this.y.$key + ': ' + d[this.y.$key];
return str;
},
Expand All @@ -3221,7 +3221,7 @@
label
.style('display', null)
.attr('transform', 'translate(5,' + offset + ')')
.text(d4.functor(this.features[name].accessors.pointLabelText).bind(this)(d));
.text(d4.functor(this.features[name].accessors.pointLabelText).bind(this)(d, datum));
},

showDataPoint: function(d, datum) {
Expand Down Expand Up @@ -3255,7 +3255,9 @@
.attr('x', d4.functor(scope.accessors.x).bind(this))
.attr('y', d4.functor(scope.accessors.y).bind(this))
.attr('data-key', d4.functor(scope.accessors.key).bind(this))
.attr('class', d4.functor(scope.accessors.classes).bind(this));
.attr('class', function(d, n) {
return d4.functor(scope.accessors.classes).bind(this)(d, n) + ' seriesLabel';
}.bind(this));
displayXValue.bind(this)(scope, data, selection);

return label;
Expand Down
4 changes: 2 additions & 2 deletions d4.min.js

Large diffs are not rendered by default.

10 changes: 6 additions & 4 deletions src/features/line-series-labels.js
Original file line number Diff line number Diff line change
Expand Up @@ -105,8 +105,8 @@
}.bind(this));
},

pointLabelText: function(d) {
var str = this.x.$key + ': ' + d[this.x.$key];
pointLabelText: function(d, datum) {
var str = datum.key + ' ' + this.x.$key + ': ' + d[this.x.$key];
str += ' ' + this.y.$key + ': ' + d[this.y.$key];
return str;
},
Expand All @@ -120,7 +120,7 @@
label
.style('display', null)
.attr('transform', 'translate(5,' + offset + ')')
.text(d4.functor(this.features[name].accessors.pointLabelText).bind(this)(d));
.text(d4.functor(this.features[name].accessors.pointLabelText).bind(this)(d, datum));
},

showDataPoint: function(d, datum) {
Expand Down Expand Up @@ -154,7 +154,9 @@
.attr('x', d4.functor(scope.accessors.x).bind(this))
.attr('y', d4.functor(scope.accessors.y).bind(this))
.attr('data-key', d4.functor(scope.accessors.key).bind(this))
.attr('class', d4.functor(scope.accessors.classes).bind(this));
.attr('class', function(d, n) {
return d4.functor(scope.accessors.classes).bind(this)(d, n) + ' seriesLabel';
}.bind(this));
displayXValue.bind(this)(scope, data, selection);

return label;
Expand Down
10 changes: 6 additions & 4 deletions test/lib/d4.js
Original file line number Diff line number Diff line change
Expand Up @@ -3206,8 +3206,8 @@
}.bind(this));
},

pointLabelText: function(d) {
var str = this.x.$key + ': ' + d[this.x.$key];
pointLabelText: function(d, datum) {
var str = datum.key + ' ' + this.x.$key + ': ' + d[this.x.$key];
str += ' ' + this.y.$key + ': ' + d[this.y.$key];
return str;
},
Expand All @@ -3221,7 +3221,7 @@
label
.style('display', null)
.attr('transform', 'translate(5,' + offset + ')')
.text(d4.functor(this.features[name].accessors.pointLabelText).bind(this)(d));
.text(d4.functor(this.features[name].accessors.pointLabelText).bind(this)(d, datum));
},

showDataPoint: function(d, datum) {
Expand Down Expand Up @@ -3255,7 +3255,9 @@
.attr('x', d4.functor(scope.accessors.x).bind(this))
.attr('y', d4.functor(scope.accessors.y).bind(this))
.attr('data-key', d4.functor(scope.accessors.key).bind(this))
.attr('class', d4.functor(scope.accessors.classes).bind(this));
.attr('class', function(d, n) {
return d4.functor(scope.accessors.classes).bind(this)(d, n) + ' seriesLabel';
}.bind(this));
displayXValue.bind(this)(scope, data, selection);

return label;
Expand Down

0 comments on commit a7f7702

Please sign in to comment.