2010-03-09 193 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