The main plot Question: how to add a data indicator

I want to add a data indicator line similar to the following image in the main plot.

Image image http://img203.imageshack.us/img203/9412/plota.png

Any idea how I can achieve this using the main plot. I just started to understand the main plot, so any advice will be very useful.

thanks

Edit:

For a better understanding, I created a screencast to show what I mean:

http://www.screencast.com/users/GauravVerma/folders/Jing/media/78fbef04-8785-46d6-9347-4f35d257109c

Added February 26th:

I solved a partial problem using two datasets. here is the current implementation:

http://www.screencast.com/users/GauravVerma/folders/Jing/media/02a1e685-8bf8-41a9-aaa6-5ea6445f6a6c

I used two dataplots, one of them is one, and the other is only one data point, which reloads when the value of the slider changes.

Here are my Datasource methods (might help someone):

-(NSUInteger)numberOfRecordsForPlot:(CPPlot *)plot { if ([(NSString *)plot.identifier isEqualToString:@"Blue Plot"]){ return [dataForPlot count]; }else { return 1; } } -(NSNumber *)numberForPlot:(CPPlot *)plot field:(NSUInteger)fieldEnum recordIndex:(NSUInteger)index { if ([(NSString *)plot.identifier isEqualToString:@"Green Plot"]) { index = floor((double)[slider value]); if (index > [dataForPlot count] -1) { index = [dataForPlot count] -1; } NSLog(@"Green plot index : %f",index); } NSNumber *num = [[dataForPlot objectAtIndex:index] valueForKey:(fieldEnum == CPScatterPlotFieldX ? @"x" : @"y")]; num = [NSNumber numberWithDouble:[num doubleValue] + 1.0]; return num; } 

Now the only problem remains - to find an easy way to draw a line. Any ideas

+6
objective-c iphone cocoa-touch core-plot
source share
1 answer

There is really no direct way to make this type of interaction in the kernel itself, but it is planned for future inclusion.

One way to do this is to place your own UIView above the top of the graph and use it to receive mouse movement events.

You can have several options for displaying a red line:

1) Add a second y axis and position it according to mouse events

2) Add a bar chart with exactly one bar that extends to the entire vertical space

3) Add a scatterplot that has two points, one at the bottom and one at the top.

These are all hacks, but they should all work.

+6
source share

All Articles