kevinzhow / PNChart

A simple and beautiful chart lib used in Piner and CoinsMan for iOS
MIT License
9.71k stars 1.76k forks source link

Help with rangeColors #425

Open miguelkennedy opened 6 years ago

miguelkennedy commented 6 years ago

Hi guys,

I'm fairly new to Objective-C and I need some help understanding the rangeColors property for the line chart.

For instance, I want values from 1 to 55 to be red, 56 to 110 to be green, 111 to 130 to be yellow and 131 upwards too be red. Here's my code

lineChartData.rangeColors = @[ [[PNLineChartColorRange alloc] initWithRange:NSMakeRange(1, 55) color:[UIColor redColor]], [[PNLineChartColorRange alloc] initWithRange:NSMakeRange(56, 55) color:[UIColor greenColor]], [[PNLineChartColorRange alloc] initWithRange:NSMakeRange(111, 20) color:[UIColor yellowColor]], [[PNLineChartColorRange alloc] initWithRange:NSMakeRange(131, 20000) color:[UIColor redColor]] ];

This doesn't seem to work... Line colors are not attributed correctly :(

Can somebody please help me understand how this works?

Thanks!

farshidce commented 6 years ago

thanks to huge help from Miguel for reporting the bug, defining the use cases and testing out all patches posted in https://github.com/kevinzhow/PNChart/pull/429.

as part of PR 429 i have also bumped up the pod version so that we can release new PNChart version there which includes LineChart fixes.