How to toggle on/off a chart series using the Shinobi iOS SDK?

732 Views Asked by At

My chart is composed of multiple chart series. I have created a custom legend with buttons so the user can press a button and show or hide a chart series as desired. I have implemented a solution where the number of series are redefined after each button press but this requires a call to reloadData which is an expensive operation.

How do I hide a chart series without calling reloadData? I am looking for a solution that only requires the chart to be redrawn using redrawChart.

1

There are 1 best solutions below

2
On BEST ANSWER

SChartSeries objects (from which all series types inherit) have a hidden property. You can set this property to NO or YES to show or hide the series. You must call redrawChart after changing the value.

For example, the following method toggles the visibility of the first series in a chart:

- (IBAction)handleTogglePressed:(id)sender {
    SChartSeries *series = _chart.series[0];
    series.hidden = !series.hidden;
    [_chart redrawChart];
}