Craig Gidney
Craig Gidney

Reputation: 18296

Circling special scatter plot points in Core Plot

I have a scatter plot where some points are interpolated and some points are the 'key' points used for those interpolations. I want the key points to stand out, by using a larger ellipse as a plot symbol. How do I do this in core plot?

I know how to make all points in the plot be represented as an ellipse:

CPTPlotSymbol *plotSymbol = [CPTPlotSymbol ellipsePlotSymbol];
plotSymbol.fill = [CPTFill fillWithColor:[CPTColor whiteColor]];
plotSymbol.size = CGSizeMake(5.0, 5.0);
plot.plotSymbol = plotSymbol;

But not how to filter that setting, like you can with text labels by implementing dataLabelForPlot:

-(CPTLayer *)dataLabelForPlot:(CPTPlot *)plot recordIndex:(NSUInteger)idx {
    return isSpecial(idx) ? [[CPTTextLayer alloc] initWithText:@"key"] : nil;
}

Upvotes: 0

Views: 202

Answers (1)

Eric Skroch
Eric Skroch

Reputation: 27381

Use the -symbolForScatterPlot:recordIndex: datasource method. Return a special plot symbol at the key indices to highlight certain points. Return nil to use the default plotSymbol or [NSNull null] to skip drawing a symbol at the index.

Upvotes: 1

Related Questions