开发者

CPBarPlot with different color bars

开发者 https://www.devze.com 2023-01-14 00:19 出处:网络
There is a way to have different color bars in a CPBarPlot in just one plot space? 开发者_开发百科Thanks in advance.Founded how.

There is a way to have different color bars in a CPBarPlot in just one plot space?

开发者_开发百科Thanks in advance.


Founded how.

In CPTBarPlotDataSource protocol there is a

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

method that works like a charm.

Cheers.


In .h file

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

In .m file

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]];
0

精彩评论

暂无评论...
验证码 换一张
取 消