I am now using ShinobiCharts iOS chart framework.
Can anyone please give me a example that provide the function as the following image?
I want to do the function which can show the X value and Y value when u click the point of the chart.
You have to implement the SChartDelegate methods:
For e.g.
- (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
}
you can also use the below method for point selection
- (void)sChart:(ShinobiChart *)chart toggledSelectionForPoint:(SChartDataPoint *)dataPoint inSeries:(SChartSeries *)series atPixelCoordinate:(CGPoint)pixelPoint{
//Your code goes here
}
you have to set CrossHairEnabled to YES something like this:
- (SChartSeries*)barSeriesForKey:(NSString*)key {
SChartBarSeries *series = [SChartBarSeries new];
series.stackIndex = [NSNumber numberWithInt:1];
series.crosshairEnabled = YES; // this is what you want
series.title = [self titleForKey:key];
if ([key isEqualToString:land]) {
series.style = [self.theme barSeriesStyleForSeriesAtIndex:3 selected:NO];
}
return series;
}
In order to display the default crosshair you need to set the following:
Enable crosshair on series
-(SChartSeries *)sChart:(ShinobiChart *)chart seriesAtIndex:(int)index {
SChartLineSeries *lineSeries = [[SChartLineSeries alloc] init];
lineSeries.style.lineColor = [UIColor darkGrayColor];
lineSeries.crosshairEnabled = YES;
lineSeries.selectionMode = SChartSelectionPoint;
return lineSeries;
}
Use the default crosshair tooltip
[chart.crosshair setDefaultTooltip];
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With