2012-11-05 71 views
0

我正在使用Coreplot,我需要幫助繪製圖表上的數據。使用Coreplot繪圖數據

我已經使用字典數據填充了一個名爲結果的數組。它輸出的內容如下(我已經縮短爲簡單起見數據) -

{ 
    temperature = "5.0832667,5.2916833,4.6418246"; 
    windspeed = "2.333,2.521,2.021,1.833,1.292,1.167"; 
} 

我無法得到這個數據使用方法numberForPlot繪製。這是我迄今爲止所做的。下面是一個嘗試只繪製「溫度」的數據 -

-(NSNumber *)numberForPlot:(CPTPlot *)plot field:(NSUInteger)fieldEnum recordIndex:(NSUInteger)index; 

     return [results valueForKey:@"temperature"]; 
{ 

我猜這是我創作我的字典的方式做,因爲他們是字符串,並且需要NSNumbers?作爲附加的註釋,這裏是創建該字典的代碼 -

for(counter = 0; counter < [node childCount]; counter++) { 

    [item setObject:[[node childAtIndex:counter] stringValue] forKey:[[node childAtIndex:counter] name]]; 

} 

[results addObject:item]; 

任何幫助,因爲我一直試圖讓這個工作了好幾天,現在將不勝感激!謝謝

回答

0

每個小區類型使用不同的「字段」來請求小區數據。例如,散點圖使用CPTScatterPlotFieldX來請求x值,而CPTScatterPlotFieldY要求y值。

-numberOfRecordsForPlot:方法告訴Core Plot有多少數據點可用於繪圖。 -numberForPlot:field:recordIndex:方法將被調用一次,每個字段的值爲0到(n-1)範圍內的每個索引。

Core Plot包含很多示例應用程序。看看他們中的任何一個,看看如何設置數據源。