I'm using the excellent JBChartView
in my project and It's working great. Here's my current code:
self.lineChart = [[JBLineChartView alloc] initWithFrame:CGRectMake(320, 400, 680, 300)];
self.lineChart.dataSource = self;
self.lineChart.delegate = self;
self.lineChart.backgroundColor = [UIColor clearColor];
JBLineChartFooterView *footerView = [[JBLineChartFooterView alloc] initWithFrame:CGRectMake(10, ceil(self.view.bounds.size.height * 0.5) - ceil(10 * 0.5), self.view.bounds.size.width - (10 * 2), 10)];
footerView.backgroundColor = [UIColor clearColor];
footerView.leftLabel.text = @"yesterday";
footerView.leftLabel.textColor = [UIColor whiteColor];
footerView.rightLabel.text = @"now";
footerView.rightLabel.textColor = [UIColor whiteColor];
footerView.sectionCount = 10;
self.lineChart.footerView = footerView;
[self.view addSubview:self.lineChart];
[self.lineChart setState:JBChartViewStateCollapsed animated:YES];
Nothing fancy, really.
JBChartView automatically chooses the Y-axis scale based on what data is passed to it in lineChartView: heightForIndex:
. This is nice in most situations. My data, however, is on CPU usage, and thus I'd like to force the Y-axis to always be 0 at the bottom and 100 at the top.
Actually, I'd like it to be 0 on the bottom and MAX(100, highestPoint)
at the top (because CPU usage can sometimes be over 100%) - is this possible?
As of v2.2.1, JBChartView allows you to supply a minimumValue and/or maximumValue for the y-axis.
Notes:
Hope this helps!