How to position annotation in multiple series column chart


#1

I have a chart that I am drawing multiple series column charts.  I would like to position a label on top of each column. How can I get the frame of annotation label in the chart? The number of series is variable. please help me. My code and reulst screen shot.

- (void)sChartRenderFinished:(ShinobiChart *)chart
{
    if ( ! self.firstRender )
        return;
    
    NSString *formatString = [self dataFormatString];

    for ( int i = 0; i < [chart.series count]; i++ ) {

        SChartColumnSeries *series = [chart.series objectAtIndex:i];

        for ( int j = 0; j < [series.dataSeries.dataPoints count]; j++ ) {
            
            SChartDataPoint *dp = [series.dataSeries.dataPoints objectAtIndex:j];
            
            NSString *dataString = [NSString stringWithFormat:formatString, [((NSNumber *)dp.yValue) doubleValue]];
            SChartAnnotation *an = [SChartAnnotation annotationWithText:dataString
                                                                andFont:chart.yAxis.style.majorTickStyle.labelFont
                                                              withXAxis:chart.xAxis
                                                               andYAxis:chart.yAxis
                                                            atXPosition:dp.xValue
                                                           andYPosition:dp.yValue
                                                          withTextColor:series.style.areaColor
                                                    withBackgroundColor:[UIColor clearColor]];
            an.position = SChartAnnotationAboveData;

            CGRect f = an.label.frame;
            f.origin.y -= f.size.height/2.f;
            an.label.frame = f;

            [chart addAnnotation:an];
        }
    }
    
    self.firstRender = NO;
}

#2

I have a chart that I am drawing multiple series column charts.  I would like to position a label on top of each column. The number of columns is variable.  How can I get the frame annotation label in the chart? Following are my code and result screen shot.

- (void)sChartRenderFinished:(ShinobiChart *)chart
{
    if ( ! self.firstRender )
        return;
    
    NSString *formatString = [self dataFormatString];

    for ( int i = 0; i < [chart.series count]; i++ ) {

        SChartColumnSeries *series = [chart.series objectAtIndex:i];

        for ( int j = 0; j < [series.dataSeries.dataPoints count]; j++ ) {
            
            SChartDataPoint *dp = [series.dataSeries.dataPoints objectAtIndex:j];

            NSString *dataString = [NSString stringWithFormat:formatString, [((NSNumber *)dp.yValue) doubleValue]];
            SChartAnnotation *an = [SChartAnnotation annotationWithText:dataString
                                                                andFont:chart.yAxis.style.majorTickStyle.labelFont
                                                              withXAxis:chart.xAxis
                                                               andYAxis:chart.yAxis
                                                            atXPosition:dp.xValue
                                                           andYPosition:dp.yValue
                                                          withTextColor:series.style.areaColor
                                                    withBackgroundColor:[UIColor clearColor]];
            an.position = SChartAnnotationAboveData;

            CGRect f = an.label.frame;
            f.origin.y -= f.size.height/2.f;
            an.label.frame = f;

            [chart addAnnotation:an];
        }
    }
    
    self.firstRender = NO;
}