如何在iPhone SDK中为Core Plot添加图例?

ios*_*ios 8 iphone cocoa-touch objective-c core-plot ios4

如何在Core Plot框架中添加图例?

我非常感谢任何指导或帮助.

Col*_*lin 26

更新:CorePlot 0.4具有CPTLegend类:

_graph.legend = [CPTLegend legendWithGraph:_graph];
_graph.legend.textStyle = x.titleTextStyle;
_graph.legend.fill = [CPTFill fillWithColor:[CPTColor darkGrayColor]];
_graph.legend.borderLineStyle = x.axisLineStyle;
_graph.legend.cornerRadius = 5.0;
_graph.legend.swatchSize = CGSizeMake(25.0, 25.0);
_graph.legendAnchor = CPTRectAnchorBottom;
_graph.legendDisplacement = CGPointMake(0.0, 12.0);
Run Code Online (Sandbox Code Playgroud)

请参阅CorePlot_0.4/Source/examples/CorePlotGallery/src/plots/SimpleScatterPlot.m.

  • 比接受的答案更好!tnx(+投票) (2认同)

Ahm*_*ali 3

目前还没有 Legend 类。有时你可以使用图像来伪造它,但它还没有出现在 Core Plot 中。检查drewmcco评论

图例尚未在 Core Plot 中实现。非常欢迎您为框架贡献它们的实现。

同时,您可以构造一个带有 UILabels 和彩色线条的自定义 UIView 作为图形的图例,然后将其作为同级添加到图形中(不是子视图,否则将无法正确呈现)并将其排序为显示在图表上方。 检查布拉德·拉尔森的答案