For my chart implementation, I want users to be able to select arbitrary data points as they see fit. The issue is that it seems like whenever another data point is selected, the previous one gets deselected. The only thing that seems to work is to have the selected BOOL
as part of my data source object and then call reloadData
and redrawChart
on the chart with each selection.
-(void)sChart:(ShinobiChart *)chart toggledSelectionForPoint:(SChartDataPoint *)dataPoint inSeries:(SChartSeries *)series atPixelCoordinate:(CGPoint)pixelPoint {
...
myDataObject.selected = !myDataObject.selected;
dataPoint.selected = myDataObject.selected;
[self.chart reloadData];
[self.chart redrawChart];
}
And then the dataPointAtIndex
will handle it.
-(id<SChartData>)sChart:(ShinobiChart *)chart dataPointAtIndex:(NSInteger)dataIndex forSeriesAtIndex:(NSInteger)seriesIndex {
...
datapoint.selected = myDataObject.selected;
}
But this seems like a wasteful, less efficient way of doing things, plus this does not have the benefit of persisting the zoom in between selections.
I think what you're looking for is series.togglePointSelection = YES
. This will allow the series' points to have their selection toggled, instead of only one being set at a time.
Hope this helps!
Rob