Fixed legend height and margin.top issue in the ready to go charts. Also re organized code a little bit for consistency

master-patched
Bob Monteverde 12 years ago
parent 2cb05b38d0
commit 542dc094f9

@ -0,0 +1,83 @@
<!DOCTYPE html>
<meta charset="utf-8">
<link href="../src/d3.css" rel="stylesheet" type="text/css">
<style>
body {
overflow-y:scroll;
}
text {
font: 12px sans-serif;
}
#chart1 {
height: 500px;
margin: 10px;
min-width: 100px;
min-height: 100px;
/*
Minimum height and width is a good idea to prevent negative SVG dimensions...
For example width should be =< margin.left + margin.right + 1,
of course 1 pixel for the entire chart would not be very useful, BUT should not have errors
*/
}
</style>
<body>
<div id="chart1">
</div>
<script src="../lib/d3.v2.js"></script>
<script src="../nv.d3.js"></script>
<!-- including all the components so I don't have to minify every time I test in development -->
<script src="../src/tooltip.js"></script>
<script src="../src/models/legend.js"></script>
<script src="../src/models/axis.js"></script>
<script src="../src/models/line.js"></script>
<script src="../src/models/lineWithLegend.js"></script>
<script src="../src/charts/lineChart.js"></script>
<script>
nv.charts.line()
.selector('#chart1')
.data(sinAndCos())
.y(function(d) { return d.voltage })
.yAxisLabel('Voltage (v)')
.build();
function sinAndCos() {
var sin = [],
cos = [],
r1 = Math.random(),
r2 = Math.random();
for (var i = 0; i < 100; i++) {
sin.push({x: i, voltage: r2 * Math.sin(i/10)});
cos.push({x: i, voltage: r1 * Math.cos(i/10)});
}
return [
{
values: sin,
key: "Sine Wave",
color: "#ff7f0e"
},
{
values: cos,
key: "Cosine Wave",
color: "#2ca02c"
}
];
}
</script>

@ -13,12 +13,16 @@ text {
font: 12px sans-serif;
}
#chart1 {
svg {
display: block;
}
#chart1 svg {
height: 500px;
margin: 10px;
min-width: 100px;
min-height: 100px;
/*
margin: 50px;
Minimum height and width is a good idea to prevent negative SVG dimensions...
For example width should be =< margin.left + margin.right + 1,
of course 1 pixel for the entire chart would not be very useful, BUT should not have errors
@ -29,40 +33,53 @@ text {
<body>
<div id="chart1">
<svg style="height: 500px;"></svg>
</div>
<script src="../lib/d3.v2.js"></script>
<script src="../nv.d3.js"></script>
<!-- including all the components so I don't have to minify every time I test in development -->
<script src="../src/tooltip.js"></script>
<script src="../src/utils.js"></script>
<script src="../src/models/legend.js"></script>
<script src="../src/models/axis.js"></script>
<script src="../src/models/scatter.js"></script>
<script src="../src/models/line.js"></script>
<script src="../src/models/lineWithLegend.js"></script>
<script src="../src/charts/lineChart.js"></script>
<script src="../src/models/lineChart.js"></script>
<script>
// Wrapping in nv.addGraph allows for '0 timeout render', stors rendered charts in nv.graphs, and may do more in the future... it's NOT required
nv.addGraph(function() {
var chart = nv.models.lineChart();
chart.xAxis // chart sub-models (ie. xAxis, yAxis, etc) when accessed directly, return themselves, not the partent chart, so need to chain separately
.tickFormat(d3.format(',r'));
chart.yAxis
.axisLabel('Voltage (v)')
.tickFormat(d3.format(',.2f'));
d3.select('#chart1 svg')
.datum(sinAndCos())
.transition().duration(500)
.call(chart);
nv.charts.line()
.selector('#chart1')
.data(sinAndCos())
.y(function(d) { return d.voltage })
.yAxisLabel('Voltage (v)')
.build();
//TODO: Figure out a good way to do this automatically
nv.utils.windowResize(chart.update);
//nv.utils.windowResize(function() { d3.select('#chart1 svg').call(chart) });
return chart;
});
function sinAndCos() {
var sin = [],
cos = [],
r1 = Math.random(),
r2 = Math.random();
cos = [];
for (var i = 0; i < 100; i++) {
sin.push({x: i, voltage: r2 * Math.sin(i/10)});
cos.push({x: i, voltage: r1 * Math.cos(i/10)});
sin.push({x: i, y: Math.sin(i/10)});
cos.push({x: i, y: .5 * Math.cos(i/10)});
}
return [

@ -1,100 +0,0 @@
<!DOCTYPE html>
<meta charset="utf-8">
<link href="../src/d3.css" rel="stylesheet" type="text/css">
<style>
body {
overflow-y:scroll;
}
text {
font: 12px sans-serif;
}
svg {
display: block;
}
#chart1 svg {
height: 500px;
min-width: 100px;
min-height: 100px;
/*
margin: 50px;
Minimum height and width is a good idea to prevent negative SVG dimensions...
For example width should be =< margin.left + margin.right + 1,
of course 1 pixel for the entire chart would not be very useful, BUT should not have errors
*/
}
</style>
<body>
<div id="chart1">
<svg style="height: 500px;"></svg>
</div>
<script src="../lib/d3.v2.js"></script>
<script src="../nv.d3.js"></script>
<script src="../src/tooltip.js"></script>
<script src="../src/utils.js"></script>
<script src="../src/models/legend.js"></script>
<script src="../src/models/axis.js"></script>
<script src="../src/models/scatter.js"></script>
<script src="../src/models/line.js"></script>
<script src="../src/models/lineChart.js"></script>
<script>
// Wrapping in nv.addGraph allows for '0 timeout render', stors rendered charts in nv.graphs, and may do more in the future... it's NOT required
nv.addGraph(function() {
var chart = nv.models.lineChart();
chart.xAxis // chart sub-models (ie. xAxis, yAxis, etc) when accessed directly, return themselves, not the partent chart, so need to chain separately
.tickFormat(d3.format(',r'));
chart.yAxis
.axisLabel('Voltage (v)')
.tickFormat(d3.format(',.2f'));
d3.select('#chart1 svg')
.datum(sinAndCos())
.transition().duration(500)
.call(chart);
//TODO: Figure out a good way to do this automatically
nv.utils.windowResize(chart.update);
//nv.utils.windowResize(function() { d3.select('#chart1 svg').call(chart) });
return chart;
});
function sinAndCos() {
var sin = [],
cos = [];
for (var i = 0; i < 100; i++) {
sin.push({x: i, y: Math.sin(i/10)});
cos.push({x: i, y: .5 * Math.cos(i/10)});
}
return [
{
values: sin,
key: "Sine Wave",
color: "#ff7f0e"
},
{
values: cos,
key: "Cosine Wave",
color: "#2ca02c"
}
];
}
</script>

@ -2433,6 +2433,7 @@ nv.models.lineChart = function() {
width = null,
height = null,
showLegend = true,
tooltips = true,
tooltip = function(key, x, y, e, graph) {
return '<h3>' + key + '</h3>' +
'<p>' + y + ' at ' + x + '</p>'
@ -2473,13 +2474,6 @@ nv.models.lineChart = function() {
- margin.top - margin.bottom;
lines
.width(availableWidth)
.height(availableHeight)
.color(data.map(function(d,i) {
return d.color || color[i % 10];
}).filter(function(d,i) { return !data[i].disabled }));
var wrap = container.selectAll('g.wrap.lineWithLegend').data([data]);
var gEnter = wrap.enter().append('g').attr('class', 'wrap nvd3 lineWithLegend').append('g');
@ -2496,19 +2490,31 @@ nv.models.lineChart = function() {
if (showLegend) {
//TODO: margins should be adjusted based on what components are used: axes, axis labels, legend
margin.top = legend.height();
legend.width(availableWidth);
//legend.width(availableWidth / 2);
g.select('.legendWrap')
.datum(data)
.attr('transform', 'translate(0,' + (-margin.top) +')')
.call(legend);
if ( margin.top != legend.height()) {
margin.top = legend.height();
availableHeight = (height || parseInt(container.style('height')) || 400)
- margin.top - margin.bottom;
}
g.select('.legendWrap')
.attr('transform', 'translate(0,' + (-margin.top) +')')
}
lines
.width(availableWidth)
.height(availableHeight)
.color(data.map(function(d,i) {
return d.color || color[i % 10];
}).filter(function(d,i) { return !data[i].disabled }));
g.attr('transform', 'translate(' + margin.left + ',' + margin.top + ')');
@ -2573,23 +2579,16 @@ nv.models.lineChart = function() {
e.pos = [e.pos[0] + margin.left, e.pos[1] + margin.top];
dispatch.tooltipShow(e);
});
dispatch.on('tooltipShow', function(e) { showTooltip(e, container[0][0]) } ); // TODO: maybe merge with above?
if (tooltips) dispatch.on('tooltipShow', function(e) { showTooltip(e, container[0][0]) } ); // TODO: maybe merge with above?
lines.dispatch.on('elementMouseout.tooltip', function(e) {
dispatch.tooltipHide(e);
});
dispatch.on('tooltipHide', nv.tooltip.cleanup);
if (tooltips) dispatch.on('tooltipHide', nv.tooltip.cleanup);
});
/*
// If the legend changed the margin's height, need to recalc positions... should think of a better way to prevent duplicate work
if (margin.top != legend.height())
chart(selection);
*/
//TODO: decide if this is a good idea, and if it should be in all models
chart.update = function() { chart(selection) };
@ -2626,12 +2625,31 @@ nv.models.lineChart = function() {
return chart;
};
chart.color = function(_) {
if (!arguments.length) return color;
color = _;
legend.color(_);
return chart;
};
chart.showLegend = function(_) {
if (!arguments.length) return showLegend;
showLegend = _;
return chart;
};
chart.tooltips = function(_) {
if (!arguments.length) return tooltips;
tooltips = _;
return chart;
};
chart.tooltipContent = function(_) {
if (!arguments.length) return tooltip;
tooltip = _;
return chart;
};
return chart;
}
@ -4352,6 +4370,7 @@ nv.models.multiBarHorizontalChart = function() {
height = null,
color = d3.scale.category20().range(),
showControls = true,
showLegend = true,
tooltips = true,
tooltip = function(key, x, y, e, graph) {
return '<h3>' + x + '</h3>' +
@ -4402,13 +4421,6 @@ nv.models.multiBarHorizontalChart = function() {
- margin.top - margin.bottom;
multibar
.width(availableWidth)
.height(availableHeight)
.color(data.map(function(d,i) {
return d.color || color[i % 10];
}).filter(function(d,i) { return !data[i].disabled }))
var wrap = container.selectAll('g.wrap.multiBarHorizontalChart').data([data]);
@ -4416,7 +4428,7 @@ nv.models.multiBarHorizontalChart = function() {
gEnter.append('g').attr('class', 'x axis');
gEnter.append('g').attr('class', 'y axis');
gEnter.append('g').attr('class', 'linesWrap');
gEnter.append('g').attr('class', 'barsWrap');
gEnter.append('g').attr('class', 'legendWrap');
gEnter.append('g').attr('class', 'controlsWrap');
@ -4425,16 +4437,35 @@ nv.models.multiBarHorizontalChart = function() {
//TODO: margins should be adjusted based on what components are used: axes, axis labels, legend
margin.top = legend.height();
var g = wrap.select('g')
.attr('transform', 'translate(' + margin.left + ',' + margin.top + ')');
var g = wrap.select('g');
legend.width(availableWidth / 2);
if (showLegend) {
legend.width(availableWidth / 2);
g.select('.legendWrap')
.datum(data)
.call(legend);
if ( margin.top != legend.height()) {
margin.top = legend.height();
availableHeight = (height || parseInt(container.style('height')) || 400)
- margin.top - margin.bottom;
}
g.select('.legendWrap')
.attr('transform', 'translate(' + (availableWidth / 2) + ',' + (-margin.top) +')')
}
multibar
.width(availableWidth)
.height(availableHeight)
.color(data.map(function(d,i) {
return d.color || color[i % 10];
}).filter(function(d,i) { return !data[i].disabled }))
g.select('.legendWrap')
.datum(data)
.attr('transform', 'translate(' + (availableWidth / 2) + ',' + (-margin.top) +')')
.call(legend);
if (showControls) {
controls.width(180).color(['#444', '#444', '#444']);
@ -4445,11 +4476,14 @@ nv.models.multiBarHorizontalChart = function() {
}
var linesWrap = g.select('.linesWrap')
g.attr('transform', 'translate(' + margin.left + ',' + margin.top + ')');
var barsWrap = g.select('.barsWrap')
.datum(data.filter(function(d) { return !d.disabled }))
d3.transition(linesWrap).call(multibar);
d3.transition(barsWrap).call(multibar);
xAxis
@ -4531,9 +4565,7 @@ nv.models.multiBarHorizontalChart = function() {
//TODO: decide if this makes sense to add into all the models for ease of updating (updating without needing the selection)
chart.update = function() {
selection.transition().call(chart);
}
chart.update = function() { selection.transition().call(chart) };
});
@ -4568,12 +4600,25 @@ nv.models.multiBarHorizontalChart = function() {
return chart;
};
chart.color = function(_) {
if (!arguments.length) return color;
color = _;
legend.color(_);
return chart;
};
chart.showControls = function(_) {
if (!arguments.length) return showControls;
showControls = _;
return chart;
};
chart.showLegend = function(_) {
if (!arguments.length) return showLegend;
showLegend = _;
return chart;
};
chart.tooltips = function(_) {
if (!arguments.length) return tooltips;
tooltips = _;
@ -6616,6 +6661,10 @@ nv.models.stackedAreaChart = function() {
function chart(selection) {
selection.each(function(data) {
//TODO: decide if this makes sense to add into all the models for ease of updating (updating without needing the selection)
chart.update = function() { selection.transition().call(chart) };
var container = d3.select(this);
var availableWidth = (width || parseInt(container.style('width')) || 960)
@ -6624,10 +6673,6 @@ nv.models.stackedAreaChart = function() {
- margin.top - margin.bottom;
stacked
.width(availableWidth)
.height(availableHeight)
var wrap = container.selectAll('g.wrap.stackedAreaChart').data([data]);
var gEnter = wrap.enter().append('g').attr('class', 'wrap nvd3 stackedAreaChart').append('g');
@ -6643,20 +6688,30 @@ nv.models.stackedAreaChart = function() {
if (showLegend) {
//TODO: margins should be adjusted based on what components are used: axes, axis labels, legend
margin.top = legend.height();
legend
.width(availableWidth/2 - margin.right)
.color(color);
.width(availableWidth/2 - margin.right);
g.select('.legendWrap')
.datum(data)
.attr('transform', 'translate(' + (availableWidth/2 - margin.left) + ',' + (-margin.top) +')')
.call(legend);
if ( margin.top != legend.height()) {
margin.top = legend.height();
availableHeight = (height || parseInt(container.style('height')) || 400)
- margin.top - margin.bottom;
}
g.select('.legendWrap')
.attr('transform', 'translate(' + (availableWidth/2 - margin.left) + ',' + (-margin.top) +')');
}
stacked
.width(availableWidth)
.height(availableHeight)
if (showControls) {
controls.width(280).color(['#444', '#444', '#444']);
g.select('.controlsWrap')
@ -6765,18 +6820,8 @@ nv.models.stackedAreaChart = function() {
if (tooltips) dispatch.on('tooltipHide', nv.tooltip.cleanup);
//TODO: decide if this makes sense to add into all the models for ease of updating (updating without needing the selection)
chart.update = function() {
selection.transition().call(chart);
}
});
/*
// If the legend changed the margin's height, need to recalc positions... should think of a better way to prevent duplicate work
if (margin.top != legend.height())
chart(selection);
*/
return chart;
}
@ -6823,6 +6868,13 @@ nv.models.stackedAreaChart = function() {
return chart;
};
chart.color = function(_) {
if (!arguments.length) return color;
color = _;
legend.color(_);
return chart;
};
chart.showControls = function(_) {
if (!arguments.length) return showControls;
showControls = _;
@ -6835,6 +6887,18 @@ nv.models.stackedAreaChart = function() {
return chart;
};
chart.tooltips = function(_) {
if (!arguments.length) return tooltips;
tooltips = _;
return chart;
};
chart.tooltipContent = function(_) {
if (!arguments.length) return tooltip;
tooltip = _;
return chart;
};
return chart;
}

6
nv.d3.min.js vendored

File diff suppressed because one or more lines are too long

@ -5,6 +5,7 @@ nv.models.lineChart = function() {
width = null,
height = null,
showLegend = true,
tooltips = true,
tooltip = function(key, x, y, e, graph) {
return '<h3>' + key + '</h3>' +
'<p>' + y + ' at ' + x + '</p>'
@ -45,13 +46,6 @@ nv.models.lineChart = function() {
- margin.top - margin.bottom;
lines
.width(availableWidth)
.height(availableHeight)
.color(data.map(function(d,i) {
return d.color || color[i % 10];
}).filter(function(d,i) { return !data[i].disabled }));
var wrap = container.selectAll('g.wrap.lineWithLegend').data([data]);
var gEnter = wrap.enter().append('g').attr('class', 'wrap nvd3 lineWithLegend').append('g');
@ -68,19 +62,31 @@ nv.models.lineChart = function() {
if (showLegend) {
//TODO: margins should be adjusted based on what components are used: axes, axis labels, legend
margin.top = legend.height();
legend.width(availableWidth);
//legend.width(availableWidth / 2);
g.select('.legendWrap')
.datum(data)
.attr('transform', 'translate(0,' + (-margin.top) +')')
.call(legend);
if ( margin.top != legend.height()) {
margin.top = legend.height();
availableHeight = (height || parseInt(container.style('height')) || 400)
- margin.top - margin.bottom;
}
g.select('.legendWrap')
.attr('transform', 'translate(0,' + (-margin.top) +')')
}
lines
.width(availableWidth)
.height(availableHeight)
.color(data.map(function(d,i) {
return d.color || color[i % 10];
}).filter(function(d,i) { return !data[i].disabled }));
g.attr('transform', 'translate(' + margin.left + ',' + margin.top + ')');
@ -145,23 +151,16 @@ nv.models.lineChart = function() {
e.pos = [e.pos[0] + margin.left, e.pos[1] + margin.top];
dispatch.tooltipShow(e);
});
dispatch.on('tooltipShow', function(e) { showTooltip(e, container[0][0]) } ); // TODO: maybe merge with above?
if (tooltips) dispatch.on('tooltipShow', function(e) { showTooltip(e, container[0][0]) } ); // TODO: maybe merge with above?
lines.dispatch.on('elementMouseout.tooltip', function(e) {
dispatch.tooltipHide(e);
});
dispatch.on('tooltipHide', nv.tooltip.cleanup);
if (tooltips) dispatch.on('tooltipHide', nv.tooltip.cleanup);
});
/*
// If the legend changed the margin's height, need to recalc positions... should think of a better way to prevent duplicate work
if (margin.top != legend.height())
chart(selection);
*/
//TODO: decide if this is a good idea, and if it should be in all models
chart.update = function() { chart(selection) };
@ -198,12 +197,31 @@ nv.models.lineChart = function() {
return chart;
};
chart.color = function(_) {
if (!arguments.length) return color;
color = _;
legend.color(_);
return chart;
};
chart.showLegend = function(_) {
if (!arguments.length) return showLegend;
showLegend = _;
return chart;
};
chart.tooltips = function(_) {
if (!arguments.length) return tooltips;
tooltips = _;
return chart;
};
chart.tooltipContent = function(_) {
if (!arguments.length) return tooltip;
tooltip = _;
return chart;
};
return chart;
}

@ -5,6 +5,7 @@ nv.models.multiBarHorizontalChart = function() {
height = null,
color = d3.scale.category20().range(),
showControls = true,
showLegend = true,
tooltips = true,
tooltip = function(key, x, y, e, graph) {
return '<h3>' + x + '</h3>' +
@ -55,13 +56,6 @@ nv.models.multiBarHorizontalChart = function() {
- margin.top - margin.bottom;
multibar
.width(availableWidth)
.height(availableHeight)
.color(data.map(function(d,i) {
return d.color || color[i % 10];
}).filter(function(d,i) { return !data[i].disabled }))
var wrap = container.selectAll('g.wrap.multiBarHorizontalChart').data([data]);
@ -69,7 +63,7 @@ nv.models.multiBarHorizontalChart = function() {
gEnter.append('g').attr('class', 'x axis');
gEnter.append('g').attr('class', 'y axis');
gEnter.append('g').attr('class', 'linesWrap');
gEnter.append('g').attr('class', 'barsWrap');
gEnter.append('g').attr('class', 'legendWrap');
gEnter.append('g').attr('class', 'controlsWrap');
@ -78,16 +72,35 @@ nv.models.multiBarHorizontalChart = function() {
//TODO: margins should be adjusted based on what components are used: axes, axis labels, legend
margin.top = legend.height();
var g = wrap.select('g')
.attr('transform', 'translate(' + margin.left + ',' + margin.top + ')');
var g = wrap.select('g');
if (showLegend) {
legend.width(availableWidth / 2);
g.select('.legendWrap')
.datum(data)
.call(legend);
if ( margin.top != legend.height()) {
margin.top = legend.height();
availableHeight = (height || parseInt(container.style('height')) || 400)
- margin.top - margin.bottom;
}
g.select('.legendWrap')
.attr('transform', 'translate(' + (availableWidth / 2) + ',' + (-margin.top) +')')
}
multibar
.width(availableWidth)
.height(availableHeight)
.color(data.map(function(d,i) {
return d.color || color[i % 10];
}).filter(function(d,i) { return !data[i].disabled }))
legend.width(availableWidth / 2);
g.select('.legendWrap')
.datum(data)
.attr('transform', 'translate(' + (availableWidth / 2) + ',' + (-margin.top) +')')
.call(legend);
if (showControls) {
controls.width(180).color(['#444', '#444', '#444']);
@ -98,11 +111,14 @@ nv.models.multiBarHorizontalChart = function() {
}
var linesWrap = g.select('.linesWrap')
g.attr('transform', 'translate(' + margin.left + ',' + margin.top + ')');
var barsWrap = g.select('.barsWrap')
.datum(data.filter(function(d) { return !d.disabled }))
d3.transition(linesWrap).call(multibar);
d3.transition(barsWrap).call(multibar);
xAxis
@ -184,9 +200,7 @@ nv.models.multiBarHorizontalChart = function() {
//TODO: decide if this makes sense to add into all the models for ease of updating (updating without needing the selection)
chart.update = function() {
selection.transition().call(chart);
}
chart.update = function() { selection.transition().call(chart) };
});
@ -221,12 +235,25 @@ nv.models.multiBarHorizontalChart = function() {
return chart;
};
chart.color = function(_) {
if (!arguments.length) return color;
color = _;
legend.color(_);
return chart;
};
chart.showControls = function(_) {
if (!arguments.length) return showControls;
showControls = _;
return chart;
};
chart.showLegend = function(_) {
if (!arguments.length) return showLegend;
showLegend = _;
return chart;
};
chart.tooltips = function(_) {
if (!arguments.length) return tooltips;
tooltips = _;

@ -47,6 +47,10 @@ nv.models.stackedAreaChart = function() {
function chart(selection) {
selection.each(function(data) {
//TODO: decide if this makes sense to add into all the models for ease of updating (updating without needing the selection)
chart.update = function() { selection.transition().call(chart) };
var container = d3.select(this);
var availableWidth = (width || parseInt(container.style('width')) || 960)
@ -55,10 +59,6 @@ nv.models.stackedAreaChart = function() {
- margin.top - margin.bottom;
stacked
.width(availableWidth)
.height(availableHeight)
var wrap = container.selectAll('g.wrap.stackedAreaChart').data([data]);
var gEnter = wrap.enter().append('g').attr('class', 'wrap nvd3 stackedAreaChart').append('g');
@ -74,20 +74,30 @@ nv.models.stackedAreaChart = function() {
if (showLegend) {
//TODO: margins should be adjusted based on what components are used: axes, axis labels, legend
margin.top = legend.height();
legend
.width(availableWidth/2 - margin.right)
.color(color);
.width(availableWidth/2 - margin.right);
g.select('.legendWrap')
.datum(data)
.attr('transform', 'translate(' + (availableWidth/2 - margin.left) + ',' + (-margin.top) +')')
.call(legend);
if ( margin.top != legend.height()) {
margin.top = legend.height();
availableHeight = (height || parseInt(container.style('height')) || 400)
- margin.top - margin.bottom;
}
g.select('.legendWrap')
.attr('transform', 'translate(' + (availableWidth/2 - margin.left) + ',' + (-margin.top) +')');
}
stacked
.width(availableWidth)
.height(availableHeight)
if (showControls) {
controls.width(280).color(['#444', '#444', '#444']);
g.select('.controlsWrap')
@ -196,18 +206,8 @@ nv.models.stackedAreaChart = function() {
if (tooltips) dispatch.on('tooltipHide', nv.tooltip.cleanup);
//TODO: decide if this makes sense to add into all the models for ease of updating (updating without needing the selection)
chart.update = function() {
selection.transition().call(chart);
}
});
/*
// If the legend changed the margin's height, need to recalc positions... should think of a better way to prevent duplicate work
if (margin.top != legend.height())
chart(selection);
*/
return chart;
}
@ -254,6 +254,13 @@ nv.models.stackedAreaChart = function() {
return chart;
};
chart.color = function(_) {
if (!arguments.length) return color;
color = _;
legend.color(_);
return chart;
};
chart.showControls = function(_) {
if (!arguments.length) return showControls;
showControls = _;
@ -266,6 +273,18 @@ nv.models.stackedAreaChart = function() {
return chart;
};
chart.tooltips = function(_) {
if (!arguments.length) return tooltips;
tooltips = _;
return chart;
};
chart.tooltipContent = function(_) {
if (!arguments.length) return tooltip;
tooltip = _;
return chart;
};
return chart;
}

Loading…
Cancel
Save