开发者

how to rotate label of a bar chart and add offset in core plot?

开发者 https://www.devze.com 2023-04-08 09:37 出处:网络
just wondering if there is a way to rotate the labels placed on bar charts and add offset to it ? Thank you.

just wondering if there is a way to rotate the labels placed on bar charts and add offset to it ? Thank you.

Below my delegate implementation. Note the padding on label

-(CPTLayer *)dataLabelForPlot:(CPTPlot *)plot recordIndex:(NSUInteger)index
{
    CPTMutableTextStyle *whiteTextStyle = [[[CPTMutableTextStyle alloc] init] autorelease];
    whiteTextStyle.color = [CPTColor whiteColor];
    whiteTextStyle.fontSize = 14.0f;

    CPTTextLayer *label = [[CPTTextLayer alloc] 开发者_C百科initWithText:@"Test" style:whiteTextStyle];
    label.paddingLeft = -100.0f; // <---
    return [label autorelease];
}


Use the labelOffset and labelRotation properties on the plot. These are inherited from CPTPlot by all Core Plot plots.

You should not set the padding in -dataLabelForPlot:recordIndex:.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号