2012-04-10 4 views
2

iPhone 프로젝트에서 코어 플롯을 사용하여 산점도 부분의 선 색상을 변경하는 방법을 알고 싶습니다. 예. Y 축의 현재 값> 이전 값이면 선 색상이 빨간색으로 변경되고 그렇지 않으면 선 색상이 녹색으로 유지됩니다. 아래는 내 코드이지만, 음모의 일부분에서 색상이 변하지 않는 것을 발견했습니다. 전체 음모로 바뀝니다. 사람이 어떤 제안을 줄 수있는 경우 :( 을 주셔서 감사합니다.코어 플롯을 사용하여 scatterPlot의 일부분에 대한 선 색상을 변경하려면 어떻게해야합니까?

-(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]; 
} 
} 
+0

안녕하세요. 나는 또한 동일한 요구 사항을 가지고 있습니다 ... 해결책이 있습니까? 감사합니다 ... –

+0

안녕하세요, 솔루션을 받으셨습니까? – SRI

답변

1

이 지금은 지원되지 않습니다. 당신이 원하는 각 색상/선 스타일에 대해 다른 플롯을 사용해야합니다

+0

고마워요. 의견을 보내 주셔서 감사합니다. :) – chao

+0

그것은 가능합니다 ri 지금? –

+0

@Eric Skroch이 질문에 대한 답변을 업데이트했습니다. 필요한 경우 수정하십시오. 감사합니다. –

관련 문제