Skip to content

Commit

Permalink
Stage a new release 0.9.6
Browse files Browse the repository at this point in the history
  • Loading branch information
heavysixer committed Mar 10, 2016
1 parent 0422194 commit 529aff2
Show file tree
Hide file tree
Showing 4 changed files with 55 additions and 57 deletions.
2 changes: 1 addition & 1 deletion bower.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "d4",
"description": "A friendly charting DSL for D3",
"main": "d4.js",
"version": "0.9.5",
"version": "0.9.6",
"dependencies": {
"d3": "~3.5.16"
},
Expand Down
57 changes: 28 additions & 29 deletions d4.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*! d4 - v0.9.5
* License: MIT Expat
* Date: 2016-02-26
* Date: 2016-03-10
* Copyright: Mark Daggett, D4 Team
*/
/*!
Expand Down Expand Up @@ -201,7 +201,7 @@
* chart.builder(function() {
* return {
* link: function(chart, data) {
* // false;
* console.log(chart.x.domain.$dirty) // false;
* }
* }
* });
Expand Down Expand Up @@ -648,7 +648,7 @@
* .mixout('yAxis');
*
* // Now test that the feature has been removed.
*
* console.log(chart.features());
* // => ["bars", "barLabels", "xAxis"]
*
* @return {Array} An array of features.
Expand Down Expand Up @@ -727,7 +727,7 @@
* .mixout('yAxis');
*
* // Now test that the feature has been removed.
*
* console.log(chart.features());
* => ["bars", "barLabels", "xAxis"]
*
* @param {String} name - accessor name for chart feature.
Expand Down Expand Up @@ -3199,56 +3199,56 @@
});
}).call(this);

(function() {
(function () {
'use strict';
/*
* Approach based off this example:
* http://bl.ocks.org/mbostock/3902569
*
* @name lineSeriesLabels
*/
d4.feature('lineSeriesLabels', function(name) {
var addDataPoint = function(scope, data) {
d4.feature('lineSeriesLabels', function (name) {
var addDataPoint = function (scope, data) {
var point = this.container.select('.' + name).selectAll('.' + name + ' circle.dataPoint').data(data);
point.enter().append('circle');
point.exit().remove();
point.attr('data-key', d4.functor(scope.accessors.key).bind(this))
.style('display', 'none')
.attr('r', d4.functor(scope.accessors.r).bind(this)())
.attr('class', function(d, n) {
.attr('class', function (d, n) {
return d4.functor(scope.accessors.classes).bind(this)(d, n) + ' dataPoint';
}.bind(this));
};

var addDataPointLabel = function(scope, data) {
var addDataPointLabel = function (scope, data) {
var xLabel = this.container.select('.' + name).selectAll('.' + name + ' text.dataPoint').data(data);
xLabel.enter().append('text');
xLabel.exit().remove();
xLabel
.attr('data-key', d4.functor(scope.accessors.key).bind(this))
.style('display', 'none')
.attr('class', function(d, n) {
.attr('class', function (d, n) {
return d4.functor(scope.accessors.classes).bind(this)(d, n) + ' dataPoint';
}.bind(this));
};

var addOverlay = function(scope) {
this.container.select('.' + name).append('rect')
var addOverlay = function (scope) {
d4.appendOnce(this.container.select('.' + name), 'rect')
.attr('class', 'overlay')
.style('fill-opacity', 0)
.attr('width', this.width)
.attr('height', this.height)
.on('mouseover', function() {
.on('mouseover', function () {
this.container.selectAll('.' + name + ' .dataPoint').style('display', null);
}.bind(this))
.on('mouseout', function() {
.on('mouseout', function () {
this.container.selectAll('.' + name + ' .dataPoint').style('display', 'none');
}.bind(this))
.on('mousemove', d4.functor(scope.accessors.mouseMove).bind(this));

};

var displayXValue = function(scope, data) {
var displayXValue = function (scope, data) {
if (d4.functor(scope.accessors.displayPointValue).bind(this)()) {
if (d4.isNotFunction(this.x.invert)) {
d4.err(' In order to track the x position of a line series your scale must have an invert() function. However, your {0} scale does not have the invert() function.', this.x.$scale);
Expand All @@ -3262,29 +3262,29 @@

return {
accessors: {
classes: function(d, n) {
classes: function (d, n) {
return 'stroke series' + n;
},

displayPointValue: false,

key: d4.functor(d4.defaultKey),

mouseMove: function(data) {
var inRange = function(a, b) {
mouseMove: function (data) {
var inRange = function (a, b) {
if (this.x.$scale === 'time') {
return a.getTime() >= b[this.x.$key].getTime();
} else {
return a >= b[this.x.$key];
}
};

var bisectX = d3.bisector(function(d) {
var bisectX = d3.bisector(function (d) {
return d[this.x.$key];
}.bind(this)).right;
var overlay = this.container.select('.' + name + ' rect.overlay')[0][0];
var x0 = this.x.invert(d3.mouse(overlay)[0]);
d4.each(data, function(datum, n) {
d4.each(data, function (datum, n) {
var i = bisectX(datum.values, x0, 1);
var d0 = datum.values[i - 1];
if (inRange.bind(this)(x0, d0)) {
Expand All @@ -3302,15 +3302,15 @@
}.bind(this));
},

pointLabelText: function(d, datum) {
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;
},

r: 4.5,

showDataLabel: function(d, datum, n) {
showDataLabel: function (d, datum, n) {
var pointLabelSelector = '.' + name + ' text.dataPoint[data-key="' + d4.functor(this.features[name].accessors.key).bind(this)(datum, n) + '"]';
var label = this.container.select(pointLabelSelector);
var offset = n * 20;
Expand All @@ -3320,28 +3320,28 @@
.text(d4.functor(this.features[name].accessors.pointLabelText).bind(this)(d, datum));
},

showDataPoint: function(d, datum, n) {
showDataPoint: function (d, datum, n) {
var pointSelector = '.' + name + ' circle.dataPoint[data-key="' + d4.functor(this.features[name].accessors.key).bind(this)(datum, n) + '"]';
var point = this.container.select(pointSelector);
point
.style('display', null)
.attr('transform', 'translate(' + this.x(d[this.x.$key]) + ',' + this.y(d[this.y.$key]) + ')');
},

text: function(d) {
text: function (d) {
return d.key;
},

x: function(d) {
x: function (d) {
return this.x(d.values[d.values.length - 1][this.x.$key]);
},

y: function(d) {
y: function (d) {
return this.y(d.values[d.values.length - 1][this.y.$key]);
}
},

render: function(scope, data, selection) {
render: function (scope, data, selection) {
var group = d4.appendOnce(selection, 'g.' + name);
var label = group.selectAll('.seriesLabel').data(data);
label.enter().append('text');
Expand All @@ -3350,7 +3350,7 @@
.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', function(d, n) {
.attr('class', function (d, n) {
return d4.functor(scope.accessors.classes).bind(this)(d, n) + ' seriesLabel';
}.bind(this));
displayXValue.bind(this)(scope, data, selection);
Expand All @@ -3361,7 +3361,6 @@
};
});
}).call(this);

(function() {
'use strict';
/*
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "d4",
"version": "0.9.5",
"version": "0.9.6",
"description": "A friendly reusable chart DSL for D3",
"repository": {
"type": "git",
Expand Down

0 comments on commit 529aff2

Please sign in to comment.