1

リンクhttp://www.johnwordsworth.com/2011/10/adding-charts-to-your-iphone-ipad-app-using-core-plot/を使用してコアプロットグラフを実装しました

この例では、作成者はx、yポイントに両方のfloat値を使用しました

しかし今、私はy軸ポイントの時間値を使用する必要がありますx、yポイントを割り当てるためのコードをどのように書くべきですか

AppDelegate *app =  (AppDelegate*)[[UIApplication sharedApplication] delegate];
NSMutableArray * times = app.timesArray;
NSMutableArray * painlevels = app.PainlevelsArray;
[super viewWillAppear:animated];
//Xand y Points to draw a graph
 NSMutableArray *data = [NSMutableArray array];
for(int i=0 ; i< [painlevels count]; i++)
{
    [data addObject:[NSValue valueWithCGPoint:CGPointMake([[painlevels objectAtIndex:i]floatValue] , [[times objectAtIndex:i]floatValue])]];
}

//以前の値のX、yポイント作成者の例では値をフロートします

/ * [data addObject:[NSValue valueWithCGPoint:CGPointMake(@ "fd"、0)]]; [データaddObject:[NSValue valueWithCGPoint:CGPointMake(-8、10)]]; [データaddObject:[NSValue valueWithCGPoint:CGPointMake(-6、40)]]; [データaddObject:[NSValue valueWithCGPoint:CGPointMake(-5、20)]]; [データaddObject:[NSValue valueWithCGPoint:CGPointMake(0、50)]]; [データaddObject:[NSValue valueWithCGPoint:CGPointMake(3、3)]]; [データaddObject:[NSValue valueWithCGPoint:CGPointMake(4、18)]]; [データaddObject:[NSValue valueWithCGPoint:CGPointMake(6、36)]]; [data addObject:[NSValue valueWithCGPoint:CGPointMake(9、66)]]; * /

self.scatterPlot = [[ScatterPlot alloc] initWithHostingView:_graphHostingView andData:data];
[self.scatterPlot initialisePlot];
4

1 に答える 1

2

Core Plot には、日付値をフォーマットする 2 つの異なる方法が含まれています。CPTTimeFormatter基準日からの相対秒数に基づいて日付をフォーマットします。CPTCalendarFormatter間隔 (日、月、時間など) を指定できます。

DatePlot と Plot Gallery のサンプル アプリは、 の使用方法を示していますCPTTimeFormatter。の使用方法の例については、この ディスカッション スレッドCPTCalendarFormatterを参照してください。

CPTCalendarFormatterは非常に優れていますが、バージョン 1.0 では利用できません。上記のリンクからプロジェクトに追加できます。

于 2012-05-07T23:23:45.157 に答える