Positioning an annotation


#1

Hi,

I’m evaluating Shinobi Charts as a charting solution for a project I’m working on. I have a problem positioning an annotation on a chart.

I have a simple line chart and I need to display an annotation when a data point gets tapped. I’m creating and adding the annotation to the chart in the delegate method sChart:toggledSelectionForPoint:inSeries:atPixelCoordinate: I’ve tried manually setting the frame of a annotation and also subclassing SChartAnnotation and setting it there. Whatever I do, it doesn’t seem to work. The annotation is always centered on the data point which is no what I need.

What is the prefered way of positioning an annotation on the chart?


#2

Hi,

For line chart you need to use crosshair.delegate methosd is there for line chart.If you do long press on line you will get the positions of x and y on chart and you can add it

  • (void)sChart:(ShinobiChart *)chart crosshairMovedToXValue:(id)x andYValue:(id)y

Adding an annotation:

   SChartAnnotation *a = [SChartAnnotation annotationWithText:[NSString stringWithFormat:@"%@",@“Annotation”]
                                                           andFont:nil
                                                         withXAxis:chart.xAxis
                                                          andYAxis:chart.yAxis
                                                       atXPosition:x
                                                      andYPosition:y
                                                     withTextColor:[UIColor blackColor]
                                               withBackgroundColor:[UIColor clearColor]];
 [chart addAnnotation:a];

Thanks & Regards

Anurag