NVD3 accessing a chart object

你说的曾经没有我的故事 提交于 2019-12-12 03:17:49

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!