CorePlot: how to find out what the graphic finale is? something like ViewDidLoad method?

CorePlot: how to find out what the graphic finale is? something like ViewDidLoad method?

Since I have a front loading view when it is loading content.

I am using AAPLOT from the CorePlot sample code.

I thought the following function tells me that it finishes the graphics, but that is not the case.

-(void)dataPullerDidFinishFetch:(APYahooDataPuller *)dp; 

is there any functuon like ViewDidLoad that can tell me when it will finish drawing successfully?

Thank you

+4
source share
2 answers

Core Animation is responsible for the entire drawing in Core Plot. A complete graph of a kernel diagram has many layers; each of them is drawn independently. There is no specific drawing order, and Core Animation does not provide any callbacks when drawing is completed.

You can set the load view until your data source is queried for all data. If loading data takes a lot of time, you should not block Core Plot, waiting for it to enter. Cache the memory inside and call -reloadData on the graph (or a separate graph) when it is ready. Just show your boot view while waiting for data entry. After you tell Core Plot to download it, uncheck the boot view.

+3
source

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."); // Do something with your graph. // For example, create an image of the graph UIImage *graphImage = [graph imageOfLayer]; } } 

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.

+2
source

Source: https://habr.com/ru/post/1396976/


All Articles