NVD3访问图表对象 [英] NVD3 accessing a chart object
问题描述
在以前版本的nvd3
中,您可以然后访问图表/图形对象.
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();
这是一个简单的jsfiddle,您也可以在实际操作中看到它,
Here's a simple jsfiddle where you can see this in action as well,
http://jsfiddle.net/0m8jzetx/3/
推荐答案
我没有真正的答案,但是找到了一些有助于访问笔刷范围的内容:
您可以为自己的范围声明2个全局var,而不是将图表声明为全局var,并在更新brush时对其进行更新,如下所示:
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];
});
这篇关于NVD3访问图表对象的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!