[英]How can I make my HorizontalBarChart scrollable?
Currently trying to implement a HorizontalBarChart using MPAndroidChart.目前正在尝试使用 MPAndroidChart 实现 HorizontalBarChart。 However, there are too many bars and they won't all fit on the screen.
但是,条形太多,无法全部显示在屏幕上。 HorizontalBarChart will scroll only if I zoom in, but will never go past what was already on the screen.
HorizontalBarChart 只有在我放大时才会滚动,但永远不会超过屏幕上已有的内容。 Not sure if this is an XML problem (I have the HorizontalBarChart in a Relative Layout, tried ScrollView but didn't work) or if there's already an implementation like chart.enableScroll() (which I have tried, and it doesn't work).
不确定这是否是 XML 问题(我在相对布局中有 HorizontalBarChart,尝试过 ScrollView 但没有工作)或者是否已经有像 chart.enableScroll() 这样的实现(我已经尝试过,但它不起作用)。
You can use chart.setVisibleXRangeMaximum(10)
to control the number of entries that should be visible at once.您可以使用
chart.setVisibleXRangeMaximum(10)
来控制应该一次可见的条目数。 If the chart contains more values, it will automatically allow scrolling.如果图表包含更多值,它将自动允许滚动。
More here: https://github.com/PhilJay/MPAndroidChart/wiki/Modifying-the-Viewport更多信息: https : //github.com/PhilJay/MPAndroidChart/wiki/Modifying-the-Viewport
chart.setData(...); // first set data
// now modify viewport
chart.setVisibleXRangeMaximum(5); // allow 5 values to be displayed
chart.moveViewToX(1);// set the left edge of the chart to x-index 1
You can use above way您可以使用上述方式
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.