3

I am trying to create and show labels with the X and Y values when a point in a Shinobi chart for iOS is clicked.

I have found the first part of the answer here ShinobiCharts:How can show the X value and Y value when u click the point of the chart

- (void)sChart:(ShinobiChart *)chart toggledSelectionForSeries:(SChartSeries *)series     nearPoint:(SChartDataPoint *)dataPoint atPixelCoordinate:(CGPoint)pixelPoint{
NSLog(@"x value:%@",dataPoint.xValue);
NSLog(@"y value:%@",dataPoint.yValue);
//here you can create an label to show the x/y values or even can add an annotation 
}

I can create the text string with this:

[NSString stringWithFormat:@"Amount:%@ from %@", dataPoint.yValue, dataPoint.xValue];

But how to create the label and assign this NSString to it using Shinobi Charts?

Community
  • 1
  • 1
Paul Cysne
  • 61
  • 5

1 Answers1

2

Rather than placing a label wherever the user taps, why don't you use the already provided SChartCrosshair class worry about that? You have to enable the crosshair for each of your series - this way you can have a crosshair only on a subset of your series if you like. You can enable the crosshair on a series like so:

mySeries.crosshairEnabled = YES;

Then press and hold on your chart to activate the crosshair.You can subclass your SChartCrosshair and do some really cool things like putting a sub-chart in it!

The crosshair brings a lot more built in functionality than just adding and removing labels to your chart - although that would work too.

jaker
  • 7,730
  • 1
  • 20
  • 22