同じグラフに異なる時間に複数のプロットを描画する必要があります。プロットの数が動的に変化することを除いてcoreplotに複数のプロットを描画する方法
:下の画像をご覧下さい。時には、ブルーとオレンジのデータセットを4回と3回だけ必要とすることもあります。このようなバープロットを1つ管理することができます。私の場合は
CPTScatterPlot *plot = [[[CPTScatterPlot alloc] init] autorelease];
plot.dataSource = self;
plot.identifier = @"mainplot";
plot.dataLineStyle = lineStyle;
plot.plotSymbol = plotSymbol;
[self.graph addPlot:plot];
私は彼らがforループに入れ、各反復で[self.graph addplot:plot]
を行うことができます。しかし、どのようにデータソースを管理するのですか?データセットの数が動的に変化する場合、以下のコードをどのように管理すればよいですか。
-(NSNumber *)numberForPlot:(CPTPlot *)plot field:(NSUInteger)fieldEnum recordIndex:(NSUInteger)index {
if ([plot.identifier isEqual:@"mainplot"])
{
NSValue *value = [self.graphData objectAtIndex:index];
CGPoint point = [value CGPointValue];
// FieldEnum determines if we return an X or Y value.
if (fieldEnum == CPTScatterPlotFieldX)
{
return [NSNumber numberWithFloat:point.x];
}
else // Y-Axis
{
return [NSNumber numberWithFloat:point.y];
}
}
return [NSNumber numberWithFloat:0];
}
こんにちはMrMage、あなたのquichk応答のおかげで、あなたは私を伝えることができますどのように私は、ダイナミックな識別子を割り当ててしまうと、厳しい質問はifループでそれらをどのように比較するかです。if([plot.identifier isEqual:@ "mainplot"])。上記のサンプル "mainplot"はハードコードされています。どのように私はこれを動的に変更するだろう。 – Rajashekar
私はあなたがそれについてちょっと考えたらそれを理解することができると確信しています。 – MrMage
私は最高の推測をしています。 CPTPlot * tempPlot = [self.graph objectatindex:indexpath.row]; if([plot.identifier isEqual:tempPlot.identifier])// self.graphはobjectatindexメソッドを使用しないと確信しています。どのような方法が取れるか知りたいですか? – Rajashekar