nvd3 multibar图表:切换默认值显示 [英] nvd3 multibar chart: toggle default values to show

查看:145
本文介绍了nvd3 multibar图表:切换默认值显示的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是d3的新手,我正试图学习使用nvd3。现在,我正在使用多用图表这里。我试图设置它,使得在页面加载时,流#1和流#2被切换到禁用状态 - 也就是说,只有Stream#0应该在页面加载时显示,您必须点击Stream#1和Stream#2按钮在图表上切换这些值。

I'm new to d3 and am trying to learn using nvd3. Right now, I'm playing with the multibar chart here. I'm trying to set it so that on the page load, "Stream #1" and "Stream #2" are toggled to the disabled state — that is, only "Stream #0" should be displayed when the page is loaded, and you should have to click the "Stream #1" and "Stream #2" buttons to toggle those values on the graph.

没有任何文档显示设置默认状态作为一个选项,所以我试图挖掘源,找出我应该做这个。从迄今为止我已经能够解析,代码这里控制分组和堆叠按钮,并允许您切换它们,但是我无法识别控制数据切换的源的类似部分。

There doesn't seem any documentation that shows setting the default state as an option, so I've tried to dig into the source to figure out where I should do this. From what I've been able to parse so far, the code here controls the "Grouped" and "Stacked" buttons and lets you toggle those, but I haven't been able to identify the analogous part of the source that controls the data toggles.

之前有人遇到过这种情况吗?任何想法如何去这样做?

Has anyone run into this before? Any ideas on how to go about doing this?

推荐答案

在系列的json中将'disabled'设置为true。

set 'disabled' to true in the json for the series.

例如:

[
  {
      key: 'Stream#0',
      values: data
  },
  {
      key: 'Stream#1',
      disabled: true,
      values: data
  }
]

这篇关于nvd3 multibar图表:切换默认值显示的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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