Mobile charts: clickable legend

  

Hi, I am using charts in my mobile application. The customer wants the legend items to be clickable, so data series can be shown or hidden by clicking the corresponding legend item.

Seems that charts do not support that... Now I am looking for any suggestions about  how this functionality can be implemented.

A possible solution would be to remove the legend altogether and make a separate control, like button group to control series visibility. I do not like this much, because it is difficult to make that manual quasi-legend look like a natural part of the graph.

Maybe it is possible to hack into the chart somehow and add some custom event handlers? I am OK with using pure javascript if needed. 

Any suggestions are much appreciated.

Hi Alexander,

It might be that on Mobile, the default is to not allow hiding a series. You could take a look at the legendItemClick event, and see whether you can override the current functionality.

Solution

Kilian Hekhuis wrote:

Hi Alexander,

It might be that on Mobile, the default is to not allow hiding a series. You could take a look at the legendItemClick event, and see whether you can override the current functionality.

Oops... it actually works on mobile device! Just does not work in browser preview of mobile app :) 

Thank you!


Solution

Thanks for the feedback! Weird it doesn't work in preview mode, shouldn't be much difference. Anyway, glad it works for you on a real device.