问题
In previous version's of nvd3 you can do the following to access the chart/graph object.
chart = nv.graphs[0];
However in more recent versions this seems to have been removed:
nv.graphs -> undefined
nv.graphs[0] -> TypeError: nv.graphs is undefined
Is there an alternative way to access the chart elements as such?
chart = nv.graphs[0];
a = chart.brushExtent();
Here's a simple jsfiddle where you can see this in action as well,
http://jsfiddle.net/0m8jzetx/3/
Here is the git issue where they remove it.
回答1:
I don't have a real answer, but have found something that may help accessing brushextents:
Rather than declaring chart as a global var, you can declare 2 global var for your extents, and update them when brush is updated, like so:
chart.dispatch.on('brush.update', function(b) {
curve_focus_min = b.extent[0];
curve_focus_max = b.extent[1];
});
来源:https://stackoverflow.com/questions/32999020/nvd3-accessing-a-chart-object