【问题标题】:Getting bar chart height in Core-Plot在 Core-Plot 中获取条形图高度
【发布时间】:2014-05-07 14:36:00
【问题描述】:

我正在尝试使用 Core-Plot 制作堆栈条形图。

在最后一站,标签未居中。我想,如果我能找到每个条的高度,我可以将标签放在条的中心。我怎样才能找到酒吧的高度?或者有什么简单的方法将标签放在条的中心?

感谢您的回答和建议。抱歉我的英语不好:)

【问题讨论】:

    标签: ios objective-c core-plot bar-chart


    【解决方案1】:

    您可以使用绘图空间注释代替数据标签。如果您平移和缩放,它们将与图一起移动。由于注释位于数据坐标中,因此条的中心很容易计算。许多示例应用程序为散点图添加注释以响应用户操作。相同的注释代码适用于任何绘图类型。

    例如,第一个绿色条的中心在 (5, 3.5)。

    NSArray *anchorPoint = @[@5, @3.5];
    
    CPTTextLayer *textLayer = [[CPTTextLayer alloc] initWithText:@"Label Text"
                                                           style:[CPTTextStyle textStyle]];
    
    textAnnotation = [[CPTPlotSpaceAnnotation alloc] initWithPlotSpace:graph.defaultPlotSpace
                                                       anchorPlotPoint:anchorPoint];
    textAnnotation.contentLayer = textLayer;
    [plot addAnnotation:textAnnotation];
    

    【讨论】:

    • 嘿,Eric,感谢重播,我应该使用哪个代表?能给我代码示例吗?
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-12-15
    相关资源
    最近更新 更多