I'm using a custom image symbol, as described in Showing images on Scattering Graph as plot symbols in Core plot iOS. Also refer to Positioning label on CPTBarPlot (Core-Plot) regarding positioning of the data label in a CPTPlot
.
However, I'm not seeing the behavior from CPTScatterPlot.labelOffset
that I need. Positive values increase the distance between the image bottom and the point, while negative values increase the distance between the image top and the point. I need to center the image on the point. See screenshots:
My solution is hacky and requires me to modify the image frame in my CustomImageForScatterPlot
's drawInContext
method. Any ideas on how to make labelOffset
work how I want?
That behavior is correct for data labels. You want to use a plot symbol.
-(CPTPlotSymbol *)symbolForScatterPlot:(CPTScatterPlot *)plot
recordIndex:(NSUInteger)index
{
CPTPlotSymbol *symbol = nil;
if ( /* use symbol for this index? */ ) {
symbol = [CPTPlotSymbol ellipsePlotSymbol];
symbol.fill = [CPTFill fillWithImage:/* symbol image */];
symbol.size = CGSizeMake(width, height);
}
return symbol;
}
If you want every point to have a symbol, set the plotSymbol
property instead of implementing this datasource method.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With