How do you toggle all dimensions in a Flot chart at once?

44 Views Asked by At

From the Flotcharts example: https://www.flotcharts.org/flot/examples/series-toggle/index.html

I'd like to toggle on/off all flot series at once (i.e. Select All / Select None).

Toggling the checkboxes themselves is easy enough:

$('input:checkbox').addAttr('checked');    // Select All
$('input:checkbox').removeAttr('checked'); // Select None

But how can I also trigger the dimensions to change?

Here's a jsfiddle of the flotcharts example: https://jsfiddle.net/uzc5rqow/

Flot Charts Example

1

There are 1 best solutions below

0
vqf On

I understand that "dimensions" refers to the axes. In your code, it is simple, you just need to call plotAccordingToChoices. I have forked your fiddle to show how to add all ticks with a button ( https://jsfiddle.net/Lk4oqvm5/ ). In the opposite case, when you uncheck every box, you need to decide which behavior you want. With no data, the graph cannot calculate the dimensions (if you manually uncheck every box, you will see that the last line does not disappear).