简体   繁体   中英

CanvasJS - Chart with Multiple Y Axis and Hide Unhide Data Series on Legend Click

I use CanvasJS in my project and it worked fine until now.

Here is the two examples from the web site :

Multiple Y Axis

Hide Unhide Data Series on Legend Click

Since i added the option maximum: to my Axis Y2-2 var the scale no longer hides by clicking in the legend !

Here is my JSfiddle live example

Can you help me to debug it please ?

Well, I solved this issue and here an workable example jsfiddle .

if (typeof(e.dataSeries.visible) === "undefined" || e.dataSeries.visible) {
  e.dataSeries.visible = false;
  if (e.dataSeriesIndex == 2) {
    e.chart.options.axisY2[0].valueFormatString = " ";
    e.chart.options.axisY2[0].title = null;
    e.chart.options.axisY2[0].lineColor = "#BBBBBB";
  };
}
else {
  e.dataSeries.visible = true;
  if (e.dataSeriesIndex == 2) {
    e.chart.options.axisY2[0].valueFormatString = "#,##0.##";
    e.chart.options.axisY2[0].title = "Linear Scale";
    e.chart.options.axisY2[0].lineColor = "#7F6084";
  };
}

I hope that can help someone else :)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM