我在我的项目中使用了优秀的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根据在lineChartView: heightForIndex:中传递给它的数据自动选择Y轴比例。这在大多数情况下都很好。然而,我的数据是关于CPU使用率的,因此我想强制Y轴始终在底部为0,在顶部为100。
实际上,我希望它在底部为0,在顶部为MAX(100, highestPoint) (因为CPU使用率有时可能超过100%) --这可能吗?
发布于 2014-04-03 08:10:18
从v2.2.1开始,JBChartView允许您为y轴提供minimumValue和/或maximumValue。
备注:
希望这能有所帮助!
发布于 2014-02-28 05:07:47
事实证明,我所需要做的就是修改line 240 of JBLineChartView.m
self.cachedMaxHeight = maxHeight;要说的话:
self.cachedMaxHeight = MAX(100,maxHeight);https://stackoverflow.com/questions/22079773
复制相似问题