Reputation: 9596
In CorePlot if you create a CPTPieChart
object the default colours for the data slices seem to be green, red, blue.
How can I change them? Here is a code snippet I am using to create the graph..
pieChartGraph = [[CPTXYGraph alloc] initWithFrame:self.pieChartgraphHostView.bounds];
peChart.dataSource = self;
//... code
// pieChart addSublayer:
self.dataForChart = [@[@25.0, @25.0, @48.0, @2.0] mutableCopy];
Upvotes: 0
Views: 51
Reputation: 27381
Implement one of the following datasource methods:
-(nullable CPTFill *)sliceFillForPieChart:(nonnull CPTPieChart *)pieChart recordIndex:(NSUInteger)idx;
-(nullable NSArray *)sliceFillsForPieChart:(nonnull CPTPieChart *)pieChart recordIndexRange:(NSRange)indexRange;
Provide the fill for the slice with the given index. If the datasource returns nil
, the default fill is used. If the datasource returns an NSNull
object, no fill is drawn for the slice at that index.
Upvotes: 1