JQPlot on and off series

If I run this code below in jqplot, I get all the lines (series) presented on the graph:

series: [ {label:'qqq', color:'#CD0000',show:true}, {label:'www', color:'#FFAA00',show:true}, {label:'eee', color:'#9CCB19',show:true}, {label:'ddd', color:'#3299CC',show:true}, {label:'ccc', color:'#871F78',show:true}, {label:'ggg', color:'#BF5FFF',show:true} ], 

but if I run this code below to show only one series on the chart, which is beautiful, and the rest are crossed out, but if I want to turn them on again by turning them off, this no longer works:

 series: [ {label:'qqq', color:'#CD0000',show:true}, {label:'www', color:'#FFAA00',show:false}, {label:'eee', color:'#9CCB19',show:false}, {label:'ddd', color:'#3299CC',show:false}, {label:'ccc', color:'#871F78',show:false}, {label:'ggg', color:'#BF5FFF',show:false} ], 

Can anyone help?

+4
source share
3 answers

you can do this using this piece of code:

 graphPlot.series[0].show = true; graphPlot.redraw(false); 

You can also specify the index of any series in the above code, and then set its show property to true or false.

+4
source

Add seriesToggle to legend / rendererOptions with a value other than 'off' http://www.jqplot.com/docs/files/plugins/jqplot-enhancedLegendRenderer-js.html#seriesToggle

false to enable on / off serial recording in the legend. true or fadein / fadeout speed (number of milliseconds or "fast", normal, "Slow") to turn on / off the series when you click a legend item.

+1
source

You can find a working example here.

Once you have implemented something, and if you still have problems, do not hesitate to seek help.

-one
source

Source: https://habr.com/ru/post/1494919/


All Articles