NVD3访问图表对象 [英] NVD3 accessing a chart object

查看:81
本文介绍了NVD3访问图表对象的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在以前版本的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/

这是他们将其删除的git问题.

推荐答案

我没有真正的答案,但是找到了一些有助于访问笔刷范围的内容:
您可以为自己的范围声明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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆