Show Value on Bar Graph


#1

Hi All,

I’m trying to show value on my bar graph on top. Can you please help me on this.

More Detais:

SChartBarSeries *colseries = [SChartBarSeriesnew];

colseries._style = [self.themebarSeriesStyleForSeriesAtIndex:3selected:NO];

Need to show value on top of bar,

Thanks,

Mayur

 

 


#2

Hi,

Your question is a little unclear - are you looking to add a numeric label to each bar? If so, this has been discussed previously:

http://www.shinobicontrols.com/forum/shinobicontrols/2013/1/labels-on-top-of-bars/

You can achieve this using annotations.

Regards, Colin E.


#3

Thank you Colin for quick response…!!

Yes exactly, I tried with the post you suggested and i’m nearer.

I have 5 vertical bar with different y-axis. Now on each top bar, i need to annote its exact y-axis value.

Image is Edited - here i have add 800 on top of bar.

Value on bar


#4

Hello Everyone,

Can you tell me how set annotation on center of bar?


#5

Have you taken a look at the thread Colin linked to? That explains how to position the annotations - they accept x and y coordinates, so to put them in the middle of the column you could just set the y-value to half the data point y-value:

SChartAnnotation *a = [SChartAnnotation annotationWithText:[NSString stringWithFormat:@"%d",[dp.yValue intValue]]
                                                   andFont:nil
                                                 withXAxis:chart.xAxis
                                                  andYAxis:chart.yAxis
                                               atXPosition:dp.xValue
                                              andYPosition:@([dp.yValue floatValue] / 2)
                                             withTextColor:[UIColor blackColor]
                                       withBackgroundColor:[UIColor clearColor]];

_sam