如何在默认情况下禁用一些流在nvd3简单折线图? [英] How to disable some streams by default in a nvd3 Simple Line Chart?

查看:102
本文介绍了如何在默认情况下禁用一些流在nvd3简单折线图?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有几行,我知道点击图例中的点将隐藏/显示它。

I have several lines and I know that clicking on the "dot" in the legend will hide/show it.

但是,我需要从一些这些行被禁用并且不显示,并且用户必须点击图例中的点以将其显示在图表上。

However, I need to start with some of the lines being disabled and not displayed, and the user will have to click on the dot in the legend to show it on the graph.

(例如,的问题在stackoverflow每种语言,但与C,PHP和javascript默认禁用)。图表只显示python,ruby ...但在传说中,你有所有的语言,包括C,PHP和js,这3个被禁用。

(eg. I graph the number of questions on stackoverflow per language, but with C, PHP and javascript disabled by default). the graph only shows python, ruby... but on the legend, you have all the languages, including C, PHP and js with these 3 being disabled.

找不到每个数据系列的方法/属性来设置默认显示/隐藏状态。

I haven't found a method/attribute for each data serie to set the default show/hide status. Am I missing something?

推荐答案

对于您希望停用的每个数据系列,只需执行:

For each of your data series that you want disabled, just do:

series.disabled=true

nvd3不做所有,但如果你愿意仔细阅读代码,它实际上是相当灵活。我发现这是通过在几个图表模型的源代码中找到这一行:

nvd3 does not do everything, but if you are willing to peruse the code it is actually quite flexible. I discovered this by finding this line in the source of several of the chart models:

state.disabled = data.map(function(d) { return !!d.disabled });

这篇关于如何在默认情况下禁用一些流在nvd3简单折线图?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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