0

I have made a bubble chart using a coreplot scatterplot by adjusting the size of each symbol in the data source method

-(CPTPlotSymbol *)symbolForScatterPlot:(CPTScatterPlot *)plot recordIndex:(NSUInteger)idx {
    Event *thisEvent;
    CGSize size;
    CPTPlotSymbol *symbol;

    symbol = [CPTPlotSymbol ellipsePlotSymbol];
    CPTMutableLineStyle *lineStyle = [symbol.lineStyle mutableCopy];

    if (idx < self.events.count) {
        thisEvent = [self.events objectAtIndex:idx];
        size.width = [thisEvent scaledValue];
        size.height = size.width;
   }
}

How can I create a legend showing the values for each of several symbol sizes? I've been looking at CPTLegendEntry in the class reference, but haven't been able to work it out yet. If anyone out there can help (Eric?), i'd appreciate it.

dave adelson
  • 853
  • 9
  • 15

1 Answers1

0

You can use a legend delegate to customize drawing the swatches. Implement the - legend:shouldDrawSwatchAtIndex:forPlot:inRect:inContext: delegate method and draw your custom swatch into the given context. Return NO to tell the legend that it doesn't need to draw the default swatch, too.

If you need more control, you can create your own. Subclass CPTBorderedLayer, override -renderAsVectorInContext: to do the drawing, and attach the custom layer to the graph as an annotation.

Eric Skroch
  • 27,381
  • 3
  • 29
  • 36