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.
How to configure Core Plot Data Labels with Bindings
-
03-07-2022 - |
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?
Solution
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:
.