Skip to content

Commit

Permalink
Fix a beforeRender bug, which was causing the waterfall connectors an…
Browse files Browse the repository at this point in the history
…d stacked column totals from being properly rendered.

This occurred because the beforeRender is now a formalized accessor, which was previously used outside of the accessors object in those classes.
  • Loading branch information
heavysixer committed Nov 27, 2014
1 parent 87f411b commit c37ab8e
Show file tree
Hide file tree
Showing 9 changed files with 58 additions and 52 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.8.10",
"version": "0.8.16",
"dependencies": {
"d3": "~3.4.4"
},
Expand Down
38 changes: 20 additions & 18 deletions d4.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*! d4 - v0.8.15
/*! d4 - v0.8.16
* License: MIT Expat
* Date: 2014-10-19
* Date: 2014-11-27
* Copyright: Mark Daggett, D4 Team
*/
/*!
Expand Down Expand Up @@ -201,7 +201,7 @@
* chart.builder(function() {
* return {
* link: function(chart, data) {
* console.log(chart.x.domain.$dirty) // false;
* // false;
* }
* }
* });
Expand Down Expand Up @@ -479,7 +479,7 @@
var baseFeature = {
accessors: {
afterRender: function() {},
beforeRender : function(){}
beforeRender: function() {}
},
proxies: []
};
Expand Down Expand Up @@ -645,7 +645,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 @@ -724,7 +724,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 @@ -2074,13 +2074,13 @@

return {
accessors: {
beforeRender: function(data) {
return calculateStackTotals.bind(this)(data);
},
y: function(d) {
var padding = 5;
return this.y(d.size) - padding;
}
},
beforeRender: function(data) {
return calculateStackTotals.bind(this)(data);
}
};
};
Expand Down Expand Up @@ -2218,14 +2218,15 @@

return {
accessors: {
beforeRender: function(data) {
return calculateStackTotals.bind(this)(data);
},

x: function(d) {
var padding = 5;
return this.x(d.size) + padding;
}
},
beforeRender: function(data) {
return calculateStackTotals.bind(this)(data);
}
};
};

Expand Down Expand Up @@ -4002,6 +4003,13 @@
d4.feature('waterfallConnectors', function(name) {
return {
accessors: {
beforeRender: function(data) {
var d = data.map(function(o) {
return o.values[0];
});
return d4.flatten(d);
},

classes: function(d, i) {
return 'series' + i;
},
Expand Down Expand Up @@ -4035,12 +4043,6 @@
}
}
},
beforeRender: function(data) {
var d = data.map(function(o) {
return o.values[0];
});
return d4.flatten(d);
},

render: function(scope, data, selection) {
selection.append('g').attr('class', name);
Expand Down
8 changes: 4 additions & 4 deletions d4.min.js

Large diffs are not rendered by default.

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.8.15",
"version": "0.8.16",
"description": "A friendly reusable chart DSL for D3",
"repository": {
"type": "git",
Expand Down
2 changes: 1 addition & 1 deletion src/base.js
Original file line number Diff line number Diff line change
Expand Up @@ -474,7 +474,7 @@
var baseFeature = {
accessors: {
afterRender: function() {},
beforeRender : function(){}
beforeRender: function() {}
},
proxies: []
};
Expand Down
6 changes: 3 additions & 3 deletions src/charts/stacked-column.js
Original file line number Diff line number Diff line change
Expand Up @@ -107,13 +107,13 @@

return {
accessors: {
beforeRender: function(data) {
return calculateStackTotals.bind(this)(data);
},
y: function(d) {
var padding = 5;
return this.y(d.size) - padding;
}
},
beforeRender: function(data) {
return calculateStackTotals.bind(this)(data);
}
};
};
Expand Down
7 changes: 4 additions & 3 deletions src/charts/stacked-row.js
Original file line number Diff line number Diff line change
Expand Up @@ -107,14 +107,15 @@

return {
accessors: {
beforeRender: function(data) {
return calculateStackTotals.bind(this)(data);
},

x: function(d) {
var padding = 5;
return this.x(d.size) + padding;
}
},
beforeRender: function(data) {
return calculateStackTotals.bind(this)(data);
}
};
};

Expand Down
13 changes: 7 additions & 6 deletions src/features/waterfall-connectors.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,13 @@
d4.feature('waterfallConnectors', function(name) {
return {
accessors: {
beforeRender: function(data) {
var d = data.map(function(o) {
return o.values[0];
});
return d4.flatten(d);
},

classes: function(d, i) {
return 'series' + i;
},
Expand Down Expand Up @@ -50,12 +57,6 @@
}
}
},
beforeRender: function(data) {
var d = data.map(function(o) {
return o.values[0];
});
return d4.flatten(d);
},

render: function(scope, data, selection) {
selection.append('g').attr('class', name);
Expand Down
32 changes: 17 additions & 15 deletions test/lib/d4.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*! d4 - v0.8.15
/*! d4 - v0.8.16
* License: MIT Expat
* Date: 2014-10-19
* Date: 2014-11-27
* Copyright: Mark Daggett, D4 Team
*/
/*!
Expand Down Expand Up @@ -479,7 +479,7 @@
var baseFeature = {
accessors: {
afterRender: function() {},
beforeRender : function(){}
beforeRender: function() {}
},
proxies: []
};
Expand Down Expand Up @@ -2074,13 +2074,13 @@

return {
accessors: {
beforeRender: function(data) {
return calculateStackTotals.bind(this)(data);
},
y: function(d) {
var padding = 5;
return this.y(d.size) - padding;
}
},
beforeRender: function(data) {
return calculateStackTotals.bind(this)(data);
}
};
};
Expand Down Expand Up @@ -2218,14 +2218,15 @@

return {
accessors: {
beforeRender: function(data) {
return calculateStackTotals.bind(this)(data);
},

x: function(d) {
var padding = 5;
return this.x(d.size) + padding;
}
},
beforeRender: function(data) {
return calculateStackTotals.bind(this)(data);
}
};
};

Expand Down Expand Up @@ -4002,6 +4003,13 @@
d4.feature('waterfallConnectors', function(name) {
return {
accessors: {
beforeRender: function(data) {
var d = data.map(function(o) {
return o.values[0];
});
return d4.flatten(d);
},

classes: function(d, i) {
return 'series' + i;
},
Expand Down Expand Up @@ -4035,12 +4043,6 @@
}
}
},
beforeRender: function(data) {
var d = data.map(function(o) {
return o.values[0];
});
return d4.flatten(d);
},

render: function(scope, data, selection) {
selection.append('g').attr('class', name);
Expand Down

0 comments on commit c37ab8e

Please sign in to comment.