5

I am now using ShinobiCharts iOS chart framework.

Can anyone please give me a example that provide the function as the following image? enter image description here

I want to do the function which can show the X value and Y value when u click the point of the chart.

iDev
  • 23,310
  • 7
  • 60
  • 85
nullmicgo
  • 407
  • 4
  • 19

3 Answers3

4

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
}
3

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;
}
megara
  • 97
  • 2
  • 11
2

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];