2015-02-02 3 views
0

Я успешно выбрал точку, но я надеюсь, что в этот момент, когда выбрана точка цвета установлен отличается от других точек, чтобы различать, как реализовать, спасибо многоCore-Plot Выберите точку

Как для установки только этого красного цвета.

How to set up only this one in red

- (пустоты) рассеивания: (CPTScatterPlot *) участок plotSymbolWasSelectedAtRecordIndex: (NSUInteger) индекс { CPTXYGraph граф = (CPTXYGraph) _graph;

if (_symbolTextAnnotation){ 
    [graph.plotAreaFrame.plotArea removeAnnotation:_symbolTextAnnotation]; 
    _symbolTextAnnotation = nil; 
} 

// Setup a style for the annotation 
CPTMutableTextStyle *hitAnnotationTextStyle = [CPTMutableTextStyle textStyle]; 
hitAnnotationTextStyle.color = [CPTColor whiteColor]; 
hitAnnotationTextStyle.fontSize = 16.0; 
hitAnnotationTextStyle.fontName = @"Helvetica-Bold"; 

// Determine point of symbol in plot coordinates 
NSDictionary *dataPoint = _plotData[index]; 

NSNumber *x = dataPoint[@"x"]; 
NSNumber *y = dataPoint[@"y"]; 

NSArray *anchorPoint = @[x, y]; 

float yValue = [y floatValue]; 

NSString *yString = [NSString stringWithFormat:@"%.1f",yValue]; 

CPTTextLayer *textLayer = [[CPTTextLayer alloc] initWithText:yString style:hitAnnotationTextStyle]; 
CPTImage *background = [CPTImage imageWithCGImage:[UIImage imageNamed:@"bg_red"].CGImage]; 
textLayer.fill   = [CPTFill fillWithImage:background]; 
textLayer.paddingLeft = 2.0; 
textLayer.paddingTop = 2.0; 
textLayer.paddingRight = 2.0; 
textLayer.paddingBottom = 2.0; 

self.symbolTextAnnotation     = [[CPTPlotSpaceAnnotation alloc] initWithPlotSpace:graph.defaultPlotSpace anchorPlotPoint:anchorPoint]; 
_symbolTextAnnotation.contentLayer  = textLayer; 
_symbolTextAnnotation.contentAnchorPoint = CGPointMake(0.5, 0.0); 
_symbolTextAnnotation.displacement  = CGPointMake(0.0, 10.0); 
[graph.plotAreaFrame.plotArea addAnnotation:_symbolTextAnnotation]; 

}

+0

Эрик, спасибо, я уже решил проблему в соответствии с советами – ilyon

ответ

1

Реализация метода -symbolForScatterPlot:recordIndex: источника данных. Верните nil для использования по умолчанию plotSymbol, [NSNull null], чтобы показать символ, или CPTPlotSymbol, чтобы показать этот символ при данных индексах.

+0

работает отлично. большое спасибо. – ilyon

Смежные вопросы