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];
}
}
안녕하세요. 나는 또한 동일한 요구 사항을 가지고 있습니다 ... 해결책이 있습니까? 감사합니다 ... –
안녕하세요, 솔루션을 받으셨습니까? – SRI