更改CPTPieChart的默认颜色

时间:2015-08-25 16:27:54

标签: ios core-plot cptxygraph

在CorePlot中,如果您创建CPTPieChart对象,则数据切片的默认颜色似乎为绿色,红色,蓝色。

如何更改它们?这是我用来创建图表的代码片段。

pieChartGraph = [[CPTXYGraph alloc] initWithFrame:self.pieChartgraphHostView.bounds];
peChart.dataSource = self;
//... code 
// pieChart addSublayer:

self.dataForChart = [@[@25.0, @25.0, @48.0, @2.0] mutableCopy];

1 个答案:

答案 0 :(得分:1)

实现以下数据源方法之一:

-(nullable CPTFill *)sliceFillForPieChart:(nonnull CPTPieChart *)pieChart recordIndex:(NSUInteger)idx;
-(nullable NSArray *)sliceFillsForPieChart:(nonnull CPTPieChart *)pieChart recordIndexRange:(NSRange)indexRange;

使用给定索引提供切片的填充。如果数据源返回nil,则使用默认填充。如果数据源返回NSNull对象,则不会为该索引处的切片绘制填充。

相关问题