How Add a legend to Core Plot in iPhone SDK?

后端 未结 2 922
礼貌的吻别
礼貌的吻别 2021-01-05 05:06

How can I add Legends in Core Plot framework?

I am greatly appreciative of any guidance or help.

相关标签:
2条回答
  • 2021-01-05 05:16

    There is no Legend class yet. You can fake it using an image sometimes, but it is not in Core Plot yet. Check drewmcco Comment

    Legends have not yet been implemented in Core Plot. You're more than welcome to contribute an implementation of them to the framework.

    In the meantime, you could construct a custom UIView with UILabels and colored lines to act as the legend for the graph, then add it as a sibling to the graph (not a subview, or it will not be rendered properly) and order it to show above the graph. Check Brad Larson Answer

    0 讨论(0)
  • 2021-01-05 05:19

    Update: CorePlot 0.4 has the class 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);
    

    See CorePlot_0.4/Source/examples/CorePlotGallery/src/plots/SimpleScatterPlot.m.

    0 讨论(0)
提交回复
热议问题