Expose d3's stack offset to allow for percent-based stack using 'expand' - fix #225

master
Rusty Bailey 11 years ago
parent 843577aff8
commit a4ef6d3c5c

@ -16,6 +16,7 @@ nv.models.multiBar = function() {
, forceY = [0] // 0 is forced by default.. this makes sense for the majority of bar graphs... user can always do chart.forceY([]) to remove
, clipEdge = true
, stacked = false
, stackOffset = 'zero' // options include 'silhouette', 'wiggle', 'expand', 'zero', or a custom function
, color = nv.utils.defaultColor()
, hideable = false
, barColor = null // adding the ability to set the color for each rather than the whole group
@ -60,7 +61,7 @@ nv.models.multiBar = function() {
if (stacked)
data = d3.layout.stack()
.offset('zero')
.offset(stackOffset)
.values(function(d){ return d.values })
.y(getY)
(!data.length && hideable ? hideable : data);
@ -399,6 +400,12 @@ nv.models.multiBar = function() {
return chart;
};
chart.stackOffset = function(_) {
if (!arguments.length) return stackOffset;
stackOffset = _;
return chart;
};
chart.clipEdge = function(_) {
if (!arguments.length) return clipEdge;
clipEdge = _;

@ -393,7 +393,7 @@ nv.models.multiBarChart = function() {
chart.yAxis = yAxis;
d3.rebind(chart, multibar, 'x', 'y', 'xDomain', 'yDomain', 'xRange', 'yRange', 'forceX', 'forceY', 'clipEdge',
'id', 'stacked', 'delay', 'barColor','groupSpacing');
'id', 'stacked', 'stackOffset', 'delay', 'barColor','groupSpacing');
chart.margin = function(_) {
if (!arguments.length) return margin;

Loading…
Cancel
Save