3

iPhone プロジェクトでコア プロットを使用して、散布図の一部の線の色を変更する方法を知りたいです。たとえば、Y 軸の現在の値 > 前の値の場合、線の色は赤に変わります。それ以外の場合、線の色は緑のままです。以下は私のコードですが、プロットの一部の色が変化せず、プロット全体に変化することがわかりました。:(誰かが何か提案をしてくれれば感謝します。

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

{

CPTScatterPlot *myPlot = (CPTScatterPlot *)plot;
CPTMutableLineStyle *lineStyle = [CPTMutableLineStyle lineStyle];
lineStyle.lineWidth              = 3.f;
lineStyle.dashPattern            = [NSArray arrayWithObjects:[NSNumber numberWithFloat:5.0f], [NSNumber numberWithFloat:5.0f], nil];

NSLog(@"index: %d",index);


if(index < 7 && index > 0 && fieldEnum == CPTScatterPlotFieldY){
if ([[dataForPlot objectAtIndex:index] floatValue] > [[dataForPlot objectAtIndex:index-1] floatValue]) {
    //lineStyle.lineColor                = [CPTColor redColor];
    NSLog(@"%f > %f",[[dataForPlot objectAtIndex:index] floatValue],[[dataForPlot objectAtIndex:index-1] floatValue]);
    lineStyle.lineColor = [CPTColor redColor];
    myPlot.dataLineStyle = lineStyle;

}else {
    lineStyle.lineColor              = [CPTColor greenColor];
    myPlot.dataLineStyle = lineStyle;
}
}




if(fieldEnum == CPTScatterPlotFieldX){
    return [NSNumber numberWithInt:index];
}else if(fieldEnum == CPTScatterPlotFieldY){
    return [dataForPlot objectAtIndex:index];
}
}
4

1 に答える 1

1

これは現在サポートされていません。使用する色/線のスタイルごとに異なるプロットを使用する必要があります。

于 2012-04-11T00:51:55.273 に答える