条形图与不同的颜色条

时间:2010-09-02 16:55:36

标签: iphone core-plot

有一种方法可以在一个绘图空间中的CPBarPlot中使用不同的颜色条吗?

提前致谢。

2 个答案:

答案 0 :(得分:3)

成立了。

在CPTBarPlotDataSource协议中有一个

-(CPTFill *)barFillForBarPlot:(CPTBarPlot *)barPlot recordIndex:(NSUInteger)index;

像魅力一样工作的方法。

干杯。

答案 1 :(得分:0)

在.h文件中

 @property (nonatomic, strong) CPTBarPlot *yourPlot1;
 @property (nonatomic, strong) CPTBarPlot *yourPlot2;

在.m文件中

self.yourPlot1 = [[CPTBarPlot alloc] init];
self.yourPlot1.fill = [CPTFill fillWithColor:[CPTColor colorWithComponentRed:194.0f/255.0f   green:237.0f/255.0f blue:154.0f/255.0f alpha:1.0f]];
self.yourPlot2 = [[CPTBarPlot alloc] init];
self.yourPlot2.fill = [CPTFill fillWithColor:[CPTColor colorWithComponentRed:190.0f/255.0f green:245.0f/255.0f blue:104.0f/255.0f alpha:1.0f]];
相关问题