Legend clicks on line charts


#1

I want to perform some actions when the user taps on a legend of a line chart. ( highlight the series, and show data related to that series) 

Is there a delegate or event that I can use to figure out the legend a user has tapped on?


#2

Is this possible? I am looking for a similar behavior.

Thanks!


#3

Hi nisarg,

This isn’t currently part of our API, however you may be able to add a UITapGestureRecognizer to SChartLegend (a subclass of UIView) and loop through the legend’s labels to determine whether the touch point intersects with a particular label. You could then search for the series in the chart with this title and select/deselect it.

I appreciate this isn’t that easy, so I’ll make sure we add this to our task list.

Kind regards,

Sam


#4

Just as a follow-up to this, you may find it useful to take a look at this project on Github as it also makes use of tap recognizers on the legend.