nvd3 multibar chart: toggle default values to show

廉价感情. 提交于 2019-12-11 08:29:42

问题


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?


回答1:


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

ex:

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


来源:https://stackoverflow.com/questions/25955603/nvd3-multibar-chart-toggle-default-values-to-show

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