added hideable attribute to multiBar.js so that the bars can be hidden the multibar is part of a larger chart

master-patched
Tyler Wolf 11 years ago
parent db144a9290
commit 7d69723a2d

@ -69,6 +69,9 @@ nv.addGraph(function() {
chart = nv.models.multiBarChart()
.barColor(d3.scale.category20().range());
chart.multibar
.hideable(true);
chart.xAxis
.showMaxMin(true)
.tickFormat(d3.format(',f'));

@ -5347,6 +5347,7 @@ nv.models.multiBar = function() {
, clipEdge = true
, stacked = false
, color = nv.utils.defaultColor()
, hideable = false
, barColor = null // adding the ability to set the color for each rather than the whole group
, disabled // used in conjunction with barColor to communicate from multiBarHorizontalChart what series are disabled
, delay = 1200
@ -5374,12 +5375,23 @@ nv.models.multiBar = function() {
availableHeight = height - margin.top - margin.bottom,
container = d3.select(this);
if(hideable && data.length) hideable = [{
values: data[0].values.map(function(d) {
return {
x: d.x,
y: 0,
series: d.series,
size: 0.01
};}
)}];
nv.log(hideable, data)
if (stacked)
data = d3.layout.stack()
.offset('zero')
.values(function(d){ return d.values })
.y(getY)
(data);
(!data.length && hideable ? hideable : data);
//add series index to each data point for reference
@ -5500,7 +5512,7 @@ nv.models.multiBar = function() {
var bars = groups.selectAll('rect.nv-bar')
.data(function(d) { return d.values });
.data(function(d) { return (hideable && !data.length) ? hideable.values : d.values });
bars.exit().remove();
@ -5733,6 +5745,12 @@ nv.models.multiBar = function() {
return chart;
};
chart.hideable = function(_) {
if (!arguments.length) return hideable;
hideable = _;
return chart;
};
chart.delay = function(_) {
if (!arguments.length) return delay;
delay = _;

6
nv.d3.min.js vendored

File diff suppressed because one or more lines are too long

@ -17,6 +17,7 @@ nv.models.multiBar = function() {
, clipEdge = true
, stacked = false
, color = nv.utils.defaultColor()
, hideable = false
, barColor = null // adding the ability to set the color for each rather than the whole group
, disabled // used in conjunction with barColor to communicate from multiBarHorizontalChart what series are disabled
, delay = 1200
@ -44,12 +45,23 @@ nv.models.multiBar = function() {
availableHeight = height - margin.top - margin.bottom,
container = d3.select(this);
if(hideable && data.length) hideable = [{
values: data[0].values.map(function(d) {
return {
x: d.x,
y: 0,
series: d.series,
size: 0.01
};}
)}];
nv.log(hideable, data)
if (stacked)
data = d3.layout.stack()
.offset('zero')
.values(function(d){ return d.values })
.y(getY)
(data);
(!data.length && hideable ? hideable : data);
//add series index to each data point for reference
@ -170,7 +182,7 @@ nv.models.multiBar = function() {
var bars = groups.selectAll('rect.nv-bar')
.data(function(d) { return d.values });
.data(function(d) { return (hideable && !data.length) ? hideable.values : d.values });
bars.exit().remove();
@ -403,6 +415,12 @@ nv.models.multiBar = function() {
return chart;
};
chart.hideable = function(_) {
if (!arguments.length) return hideable;
hideable = _;
return chart;
};
chart.delay = function(_) {
if (!arguments.length) return delay;
delay = _;

Loading…
Cancel
Save