In an earlier manifestation of my little iOS plot project I had things set up so that when one tapped on a plot symbol a label would be shown by that symbol and any old label would be removed. It worked fine. Now, not so fine.
My CPTScatterPlotDelegate handles the tap:
- (void)scatterPlot:(CPTScatterPlot*)the_plot
plotSymbolWasSelectedAtRecordIndex:(NSUInteger) index {
if (self.indexShowingLabel == 999999 || self.indexShowingLabel == index) {
[self.plot relabelIndexRange:NSMakeRange(index, 1)];
} else {
if (self.indexShowingLabel < index)
[self.plot relabelIndexRange:NSMakeRange(self.indexShowingLabel,
index - self.indexShowingLabel + 1)];
else
[self.plot relabelIndexRange:NSMakeRange(index,
self.indexShowingLabel - index + 1)];
}
self.indexShowingLabel = index;
}
This function gets called on a tap and the proper range is invalidated. But the labels are not redrawn.
The CPTPlotDataSource provides the data labels with a -[dataLabelForPlot:recordIndex:] function. It gets called on initial plot draw but not in response to the relabelIndexRange: calls shown above. It's been a while since I was fiddling with this code but I seem to recall that the dataLabelForPlot: was being called in response to a relabelIndexRange:. (I do not have a -[dataLabelsForPlot:recordIndexRange:] function!)
What am I missing?
Thanks in advance!
Mike