rickshaw icon indicating copy to clipboard operation
rickshaw copied to clipboard

Disable Series on Start using Series.Toggle?

Open ghost opened this issue 10 years ago • 4 comments

Hi. Is there a way to disable a series manually? I'd like to disable some series first and allow the user to enable them using Behavior.Series.Toggle Thanks

ghost avatar Jul 25 '13 15:07 ghost

You can disable the series programmatically using graph.series[0].disable(), replacing 0 with the desired series index.

While this will prevent the series from appearing, the corresponding element in the legend will still appear to be enabled. It doesn't seem like the Series.Toggle extension supports changing the class of legend elements programmatically, so you'd probably have to do it yourself (just find the element in the legend and add the 'disabled' class). For example, if you're using jQuery: $('.rickshaw_legend .line:nth-child(1)').addClass('disabled'). See this function for details.

You could also submit a pull request to add support for this within Series.Toggle.

Disclaimer: not a Rickshaw maintainer

dellsystem avatar Aug 07 '13 23:08 dellsystem

thanks, works perfectly fine!

ghost avatar Aug 08 '13 18:08 ghost

I was able to do it with document.getElementsByClassName("label")[0].click();

Not the most elegant, but pretty simple.

jayenashar avatar Jul 26 '14 22:07 jayenashar

For me the order of the legend and graph.series was different, so I used this:

$('.rickshaw_legend .label:contains("foo")').siblings('.action').click()

arnov avatar Jun 24 '15 10:06 arnov