简体   繁体   English

d3图中的事件

[英]Events in d3 graphs

I'm using a line char from nvd3 http://nvd3.org/ghpages/lineWithFocus.html I want to customise the tooltip events (stop them from fading out when you hover out) and also add other events like click. 我正在使用来自nvd3的行字符http://nvd3.org/ghpages/lineWithFocus.html我想自定义工具提示事件(当你将鼠标悬停时阻止它们淡出)并添加其他事件,如点击。

How can I add events and how can I select the points that have been plotted from a json document (ie click in a point triggers an event). 如何添加事件以及如何选择从json文档中绘制的点(即点击某个点会触发事件)。

Thanks! 谢谢!

I know google is a thing, I have tried. 我知道谷歌是一件事,我试过了。

NVD3 is unfortunately not very flexible when it comes to things like this. 不幸的是,NVD3在这样的事情上并不是很灵活。 To customise the behaviour you've mentioned, you're much better off building your graph in pure D3. 要自定义您提到的行为,最好在纯D3中构建图形。 This will be a bit more difficult to start with, but will allow you to do everything you want quite easily afterwards. 这将是一个更难开始,但将允许您事后很容易地做你想要的一切。

A good place to start is probably this example . 一个好的起点可能是这个例子 There are many more on the D3 website, including ones with interaction, tooltips etc. D3网站上还有更多内容,包括互动,工具提示等。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM