我JBChartView
在我的项目中使用了优秀的,它工作得很好。这是我当前的代码:
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];
没有什么花哨的,真的。
JBChartView 根据传入的数据自动选择 Y 轴刻度lineChartView: heightForIndex:
。这在大多数情况下都很好。但是,我的数据是关于 CPU 使用率的,因此我想强制 Y 轴在底部始终为 0,在顶部始终为 100。
实际上,我希望它在底部和MAX(100, highestPoint)
顶部都为 0(因为 CPU 使用率有时可能超过 100%) - 这可能吗?