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

Example for rangeColor in LineChart #449

Open sureshcapternal opened 6 years ago

sureshcapternal commented 6 years ago

I have implemented line chart same as attachment. I want to apply following things, this is an pill data where, Y axis label shows pill time. (may be 3 times per day) X axis shows days of the week.

1) There is one case where user don't take pill on Tuesday and Thursday. In this case I don't want to show line When user skipped pill.

I am trying to apply

NSArray data01Array = @[@7.00, @7.00, @7.00, @7.00, @7.00,@7.00,@7.00]; PNLineChartData data01 = [PNLineChartData new]; data01.rangeColors = @[ [[PNLineChartColorRange alloc] initWithRange:NSMakeRange(10, 30) color:[UIColor redColor]], [[PNLineChartColorRange alloc] initWithRange:NSMakeRange(7, 7) color:[UIColor purpleColor]]]; data01.rangeColors = [[data01.rangeColors reverseObjectEnumerator] allObjects];

data01.color = ColorName.Walkthrough3;
data01.itemCount = self.lineChart.xLabels.count;
data01.inflexionPointColor = ColorName.Walkthrough3;
data01.inflexionPointStyle = PNLineChartPointStyleCircle;
data01.getData = ^(NSUInteger index) {
    CGFloat yValue = [data01Array[index] floatValue];
    return [PNLineChartDataItem dataItemWithY:yValue];
};

but not able to change color of line

Expected Result

screen shot 2018-10-31 at 9 53 16 pm

Actual Result

screen shot 2018-10-31 at 9 53 16 pm