问题
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