Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Positioning label on CPTBarPlot (Core-Plot)

I am trying to change default position of labels in Bar chart with Core-Plot. I am using this method:

-(CPTLayer *)dataLabelForPlot:(CPTPlot *)plot recordIndex:(NSUInteger)idx;

And I return:

return textLayer = [[CPTTextLayer alloc] initWithText:@"2222" style:textStyle];

I get this result:

enter image description here

But I want to appear as follows:

enter image description here

Any idea? I tried to find answer on documentation, but I has been impossible.

like image 658
mhergon Avatar asked Jan 14 '23 23:01

mhergon


1 Answers

Use a negative labelOffset for the bar plot. The default is +10 which puts the labels 10 pixels above the bars. This property is inherited from CPTPlot so it works for all plot types, although the default value and behavior varies somewhat.

like image 79
Eric Skroch Avatar answered Jan 24 '23 10:01

Eric Skroch