Question

I'm attempting to set up a pie chart using core plot and bindings. I can get the chart to display properly using CPTPieChartBindingPieSliceWidthValues

[pieChart bind:CPTPieChartBindingPieSliceWidthValues
    toObject:[self sectorAllocation]
       withKeyPath:@"arrangedObjects.sectorPercentage"
           options:nil];

(sectorAllocation is a NSArray Controller)

Similarly I tried bind data labels using CPTPlotBindingDataLabels

[pieChart bind:CPTPlotBindingDataLabels
          toObject:[self sectorAllocation]
       withKeyPath:@"arrangedObjects.sectorName"
           options:nil];

(sectorName is a NSString value)

However this doesn't seem to work i receive the following error in the console

[__NSCFString setShadow:]: unrecognized selector sent to instance 0x60800023fb00

It seems it doesn't like a string object, so how would i go about this? and what type of object is it looking for?

Was it helpful?

Solution

The binding expects an NSArray of Core Plot layers (CPTLayer), one for each data index. CPTTextLayer is a common choice since it displays text, but other layer types are allowed, too.

OTHER TIPS

Obviously Core Plot expects a class, whose instances respond to setShadow:. In Cocoa there is only one class afaik: NSView. This seems to be a reasonable class for plotting a label.

Additionally you can browse the documentation of Core Plot to find out, whether there is a framework class, that responds to setShadow:.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top