How Add a legend to Core Plot in iPhone SDK?

醉酒当歌 提交于 2019-12-19 00:21:32

问题


How can I add Legends in Core Plot framework?

I am greatly appreciative of any guidance or help.


回答1:


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




回答2:


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.



来源:https://stackoverflow.com/questions/5740785/how-add-a-legend-to-core-plot-in-iphone-sdk

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