Charts,BarChartView,默认情况下,如果x轴数据过多,会自动缩小单个柱状图宽度,造成数据都挤在一起。底部柱状图的名称也显示不全。
需要当X轴数据多时, 柱形图柱状条的宽度定值,滑动X轴左右查看其它数据。
设置一页显示的数据条数,超出的数量需要滑动查看:
1 |
[self.barChartView setVisibleXRangeMaximum:7]; |
1 2 3 4 |
/// Sets the size of the area (range on the x-axis) that should be maximum visible at once (no further zooming out allowed). /// If this is e.g. set to 10, no more than a range of 10 values on the x-axis can be viewed at once without scrolling. /// If you call this method, chart must have data or it has no effect. - (void)setVisibleXRangeMaximum:(double)maxXRange; |
最重要的事情是,如果需要调用此方法,需要BarChartView有数据,否则不会生效。一般在 self.barChartView.data = data; 之后调用即可。