I am using core plot to make a line graph for my iPhone app. So far I successfully made the line graph from my xml data.
Furthermore I added a text layer that shows the value (for example 40) once I select the cell
holding the value 40. For this, I use the function:
(CPTLayer *)dataLabelForPlot:(CPTPlot *)plot recordIndex:(NSUInteger)index
So now I want to have a vertical line on the graph to indicate the selected value (the 40). I tried adding CPTBarplot but somehow the bars show only at the beginning of the graph axis.
Is there a function from core plot like the above that will create a line indicator?
I would appreciate if someone can give me some hint how to solve this problem and thank you very much in advance.
You could use a scatter plot for that. There’s a point selection demo in the Mac CPTTestApp that draws a crosshair over the selected point. It would be trivial to modify that to only draw the vertical line.
The
-numberOfRecordsForPlot:datasource method returns the number of points in the selection indicator (5 for the crosshairs) or zero (0) if there is no current selection. The-numberForPlot:field:recordIndex:method returns the points in the indicator. The points are drawn in this order:The
-symbolForScatterPlot:recordIndex:method controls the plot symbol in the center. You can eliminate this method if you don’t need any symbols on the indicator plot.