Positioning label on CPTBarPlot (Core-Plot)

旧街凉风 提交于 2019-12-07 08:21:57

问题


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:

But I want to appear as follows:

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


回答1:


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.



来源:https://stackoverflow.com/questions/13475573/positioning-label-on-cptbarplot-core-plot

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!