Reputation: 75
I have put together a stacked line chart using nvd3's helpful pre-packaged charts.
I get the chart doing the majority of the functionality fine, but whenever I click on a specific series the error 'Uncaught TypeError: Cannot read property 'y' of undefined', and the chart does not resize to only display the series.
For an example of correct functionality: http://nvd3.org/examples/stackedArea.html
I've checked against the most common errors, including differently sized series, and it's none of those.
The code I'm using for generating the chart is:
function stackedChart(data) {
nv.addGraph(function() {
var chart = nv.models.stackedAreaChart()
.margin({right: 100})
.x(function(d) { return d[0] })
.y(function(d) { return d[1] })
.useInteractiveGuideline(true)
.duration(500)
.showControls(true)
.clipEdge(true);
chart.xAxis
.tickFormat(d3.format(',.0f'));
chart.yAxis
.tickFormat(d3.format(',.2f'));
d3.select('#stackedChart svg')
.datum(data)
.transition().duration(500).call(chart);
nv.utils.windowResize(chart.update);
return chart;
});
}
stackedChart(a);
with the data found in the jsfiddle with a live example of the error: https://jsfiddle.net/0yxr15ut/5/
Upvotes: 1
Views: 3846
Reputation: 63
This issue has been addresses here: https://github.com/novus/nvd3/issues/1093 A workaround is available for this issue although not sure about the side effects. Add the following check in the scatter y function in your nv.d3.js
.y(function(d) {
if (d.display !== undefined) { return d.display.y + d.display.y0; }
else return 0
})
I have made a for repository which has this change which you can use. https://github.com/nishantk92/nvd3.git
Upvotes: 1