Core Plot: Data point labels shown, or when data points touched? - iphone

Is there a way using Core Plot to have periodic labels assigned to data plots? Such as 10-20 labels listed across my plot points.
Here is an example (mockup) of what I am hoping to do:
Is it possible to do this when the graph loads, or maybe when you swipe across the graph you see the data points showing their call out?

You'll have to draw the callout bubbles yourself, but it is possible to label data points. To make a callout, you could subclass CPTextLayer and have it draw the bubble around the text. Use this new class to make your labels.
You can implement a datasource method to inform Core Plot which data points should be labeled and provide your own labels if you wish (this is how you'd do the callouts). You can also respond to touch events (click events on the Mac) and show a label for the point that was touched. You have to touch each point individually--you won't get the delegate notification if you drag from one point to the next.
The examples included with Core Plot demonstrate how both techniques work.

Related

Adding a slider to ILNumerics Plot

I'd like to make use of an ILNumerics 3D plot but I would like to add a slider control. The slider would be responsible for filtering values on the backing data set so I can visualize my data under certain conditions. Basically, user moves slider and plot automatically updates based on criteria set by slider.
The functionality that I am looking for is very similar to Mathematica's manipulate feature. Is this type of functionality possible?
Thanks!
Yes. Interactivity is one specialty of ILNumerics. All objects can be modified dynamically. Simply place your code into the event handler of the slider and change everyting you need there.
Afterwards, call Configure() on the affected part of the scene in order to lock your changes in. ILPanel.Refresh() causes an immediate refresh of the display.

Get every point plot data information when clicked on graph core plot

I am using the core plot to draw graph but i need to show every plot point info on touch on every plot coordinate.Please help me how can i show the info my data on every plot accordingly.
Thanks in advance.
I guess you should save the location and information of each plot point and check that against the touch you receive from the user. When you have drawn something on a canvas there is no way to ask it for information about a certain point.
Use a plot delegate to get notified of the touch. There are several examples in the Plot Gallery and CPTTestApp (Mac) example apps.

Core Plot show 'Loading' spinner

I am using core plot (0.4) to render a graph and it is working fine. However (especially when on the iPad) the graph can take a while to render. I have added a UIActivityIndicatorView to the graph which shows up when the graphs starts to be drawn, but I can't find any event to hook that I can use to stop the spinner.
I have tried using the numberForPlot method and detecting when the last datapoint has been requested, but this is called multiple times for each line on the scatterGraph, so I can't easily use this. Is there any sort of graph rendered event that I can hook for this?
If you're doing [graph reloadData] to update the graph, can you just bracket that call with your indicator start/stop calls? I think that core-plot does everything in the main thread.
Core Plot uses Core Animation for all rendering. A single graph contains many CA layers that are rendered independently. -reloadData just tells the graph to update its data cache next time it draws and tells Core Animation that it needs to be redrawn. Similarly, just bracketing the data source calls only captures the data caching that happens before the render. You would miss the actual drawing time and would never know if Core Animation re-rendered the graph at another time, such as after a resize.
If you only care about the time to render the plot and not the other parts of the graph, one way to do this would be to subclass CPTScatterPlot and override the -renderAsVectorInContext: method. Bracket the calls to super with your activity indicator code.

Continously Updating UIViews in Objective C

I am very new to Iphone programming with Objective-C but I have picked up pretty fast in the last 1 month.
I have an application that reads data from a .csv which I then use to plot a continous graph on the Iphone. The problem is that there are close to 84,000 data points ( a major requirement) and the current design I used with Quartz 2D has helped to make the required plots but it takes close to 3mins for the UIView to show the infinitely long plot I desire.
The solution I am looking for is this
I intend to use a function in normal C language to sequential access the file within a thread and pass it to the drawing function which will then update the screen as the data arrives so that the user has a feel of how the data is been plotted continously. The problem I have however is that the CGRECT drawing function and the setNEEDSDisplay would just take all the points at once and display on the UIView,
How do I update only specific point on the UIView as the data arrives without clearing the whole View
You'll want to use setNeedsDisplayInRect as described here:
Drawing incrementally in a UIView (iPhone)
Have you looked at using Core Plot?
http://code.google.com/p/core-plot/
It's a little hard to figure out, google for example uses. But it may be able to handle what you need through selective plotting of large data sets.

How to make the coordinate of a graph user interactive?

I have tried to plot a graph using Quartz 2D . It looks more like a drawing. But I am fixing the axes and plotting the coordinates according to the axes. But the problem is I want to make the graph user interactive. Each coordinate on the graph will further have to drill down showing the details of the coordinate. So how can I make the coordinates interactive .
Rather than rolling your own Quartz graph with interactivity, you might want to take a look at the Core Plot framework, which is available for Mac and iPhone. The stubs are there to provide user interactivity, but we haven't filled in any implementations of this yet.
If you wish, you can implement
-(BOOL)containsPoint:(CGPoint)thePoint
-(void)mouseOrFingerDownAtPoint:(CGPoint)interactionPoint
-(void)mouseOrFingerUpAtPoint:(CGPoint)interactionPoint
-(void)mouseOrFingerDraggedAtPoint:(CGPoint)interactionPoint
-(void)mouseOrFingerCancelled
within the appropriate CPLayer subclass to make that Core Plot element respond to user interaction. We will also be setting up a delegation pattern so that your controllers can handle the logic for interaction events as well.