To create this functionality, I added code for my implementation of numberForPlot:field:recordIndex: to check if the record index was equal to "the number of records in my source data minus one" (since the graph data source uses zero based on numbering).
Because CorePlot sequentially displays the columns on my histogram, so I can be sure that when it gets to the bar number equal to the number of records in my data source minus one, it is on the last record (this can be a more difficult situation if you draw more one chart on your chart).
At this point, I simply create an iOS notification called finishedDrawingGraph in the method numberForPlot:field:recordIndex: ::
// If this is the last bar in the chart for this layer, send notification to // say that the graph has finished drawing if (index == [self.dataController.builds count]-1 { [[NSNotificationCenter defaultCenter] postNotificationName:@"finishedDrawingGraph" object:nil]; }
I have a listener in my view controller to listen for finishedDrawingGraph events. Since the notification system is relatively slow (compared to calling the method directly), by the time this notification was received, the chart almost certainly completed drawing. To add some confidence, I could wait a while after receiving a notification.
- (void)eventHandler: (NSNotification *) notification { if ([notification.name isEqualToString:@"finishedDrawingGraph"]) { NSLog2 (@"Graph drawn.");
This is not a particularly elegant solution, and it may break under some circumstances (a system with a very large load, upgrading to CorePlot), but it is more than adequate to my current needs.
source share