2010-03-09 178 views
1

我一直在使用核心绘图创建CPScatterPlot和对图形的几行:核心数据线标签

for(int i=0; i<nLines; ++i){ 
    CPScatterPlot *xSquaredPlot = [[[CPScatterPlot alloc] initWithFrame:graph.frame] autorelease]; 
    xSquaredPlot.identifier = [NSString stringWithFormat:@"%d",i]; 
    xSquaredPlot.dataLineStyle.lineWidth = 1.0f; 
    xSquaredPlot.name = @"dd"; 

    if(i==0) 
    xSquaredPlot.dataLineStyle.lineColor = [CPColor redColor]; 
    else if (i ==1) 
    xSquaredPlot.dataLineStyle.lineColor = [CPColor blueColor]; 
    else 
    xSquaredPlot.dataLineStyle.lineColor = [CPColor greenColor]; 

    xSquaredPlot.dataSource = self; 
    [graph addPlot:xSquaredPlot]; 

    CPPlotSymbol *greenCirclePlotSymbol = [CPPlotSymbol ellipsePlotSymbol]; 
    if(i==0) 
    greenCirclePlotSymbol.fill = [CPFill fillWithColor:[CPColor blueColor]]; 
    else if (i ==1) 
    greenCirclePlotSymbol.fill = [CPFill fillWithColor:[CPColor greenColor]]; 
    else 
    greenCirclePlotSymbol.fill = [CPFill fillWithColor:[CPColor redColor]]; 

    greenCirclePlotSymbol.size = CGSizeMake(2.0, 2.0); 

    xSquaredPlot.plotSymbol = greenCirclePlotSymbol; 
} 

的线条出现很大,但我似乎无法找到一种方法来标记每行与它的标题,或提供一个传奇。

对此的任何想法?

在此先感谢!

+0

这里的bute是设置图例fram /位置的一些概率。我按照需要设置框架。 (完全在视图的底部) – user1811427

回答

0

图示在Core Plot中尚未实现。您非常欢迎您将其实施到框架中。

与此同时,您可以使用UILabels和彩色线构建自定义UIView作为图形的图例,然后将其作为图形的同级添加(不是子视图,否则将无法正确呈现)并命令它在图表上方显示。

4

更新: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); 

见CorePlot_0.4 /来源/例子/ CorePlotGallery/src目录/图/ SimpleScatterPlot.m。

+0

是的感谢提供有价值的信息。这里的bute是设置图例fram /位置的一些概率。我按照需要设置框架。 (完全在视图的底部) – user1811427