开发者

in core-plot how do i translate to coordinates using the plotSymbolWasSelectedAtRecordIndex method?

i can see that in the mac version example, they have used binding and NSArrayController (both of which are no开发者_运维知识库t available in iOs?)

what i have from

(void)scatterPlot:(CPScatterPlot *)plot plotSymbolWasSelectedAtRecordIndex:(NSUInteger)index

is the index and the plot in context.

I need to get the exact coordinates so that i can use a popover at that point.

thanks in advance


When you provided data to the scatter plot, you used the

-(NSNumber *)numberForPlot:(CPPlot *)plot field:(NSUInteger)fieldEnum recordIndex:(NSUInteger)index 

delegate method (or something like that). Part of the information it queried was the recordIndex, which is usually used as an index into an NSArray of your data points.

The delegate method you show there gives you back an index to indicate that a point on the scatter plot was interacted with. You should be able to grab the X, Y coordinate that corresponds to that index in your data source array and use

double doublePrecisionPlotPoint[2];
doublePrecisionPlotPoint[CPCoordinateX] = [xValue doubleValue];
doublePrecisionPlotPoint[CPCoordinateY] = [yValue doubleValue];

CGPoint viewPoint = [graph.defaultPlotSpace plotAreaViewPointForDoublePrecisionPlotPoint:doublePrecisionPlotPoint];

to obtain the view coordinate in the graph that corresponds to the data point location that was touched. From there, you can do coordinate space conversions to get the appropriate location to place your annotation.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜