对于我的图表实现,我希望用户能够选择他们认为合适的任意数据点。The issue is that it seems like whenever another data point is selected, the previous one gets deselected. 唯一可行的方法是将所选BOOL
对象作为我的数据源对象的一部分,然后在每次选择时在图表上调用reloadData
和。redrawChart
-(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];
}
然后dataPointAtIndex
将处理它。
-(id<SChartData>)sChart:(ShinobiChart *)chart dataPointAtIndex:(NSInteger)dataIndex forSeriesAtIndex:(NSInteger)seriesIndex {
...
datapoint.selected = myDataObject.selected;
}
但这似乎是一种浪费,效率较低的做事方式,而且这没有在选择之间保持放大的好处。