0

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?

Cory
  • 2,302
  • 20
  • 33

2 Answers2

2

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.

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

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:.

Amin Negm-Awad
  • 16,582
  • 3
  • 35
  • 50
  • OK looks like it is looking for a instance of CPTTextLayer, which is a subclass of CALayer. I suspect I will use NSValueTransformer to convert the NSString instance to a CPTTextLayer instance – Cory Nov 03 '13 at 23:20