最新消息:iOS编程开发交流群(6906921) ,Mac.Cocoa开发交流群(7758675) 欢迎iOS/macOS开发编程爱好及学习者加入!

iOS开发之Charts柱状图设置最大可见量,X轴数据过长左右滑动查看

iOS 天狐 16401浏览 0评论

Charts,BarChartView,默认情况下,如果x轴数据过多,会自动缩小单个柱状图宽度,造成数据都挤在一起。底部柱状图的名称也显示不全。

需要当X轴数据多时, 柱形图柱状条的宽度定值,滑动X轴左右查看其它数据。

设置一页显示的数据条数,超出的数量需要滑动查看:

 [self.barChartView setVisibleXRangeMaximum:7];
/// 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; 之后调用即可。

转载请注明:天狐博客 » iOS开发之Charts柱状图设置最大可见量,X轴数据过长左右滑动查看

微信 OR 支付宝 扫描二维码
为天狐 打赏
非常感谢你的支持,哥会继续努力!
发表我的评论
取消评论

表情

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址