Currently trying to implement a HorizontalBarChart using MPAndroidChart. 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. 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).
For horizontal scrollable bar use the x and y-axis. Set the overflow-y: hidden; and overflow-x: auto; that will automatically hide the vertical scroll bar and present only the horizontal scrollbar. The white-space: nowrap; property is used to wrap text in a single line.
Show scroll bars in Word and Excel for WindowsClick File > Options. On the Advanced tab, scroll to the Display section. Select Show horizontal scroll bar and Show vertical scroll bar, and then click OK.
By creating a container to keep the table. Making the table horizontally scrollable. We can enclose the table in a <div> tag and provide the following styling to the <div> tag: To make it even better, we can even set a width for column tables:
You can use chart.setVisibleXRangeMaximum (10) to control the number of entries that should be visible at once. If the chart contains more values, it will automatically allow scrolling.
The trick to make the navbar scrollable is by using overflow:auto and white-space: nowrap: Tip: Go to our CSS Navbar Tutorial to learn more about navigation bars.
You can set the table property scrollableColCount to e.g. 10. The horizontal scrollbar should appear automatically. For the non-scrollable columns you can set the property fixedPosition to left. All columns having the value left assigned to this property will appear as fixed columns left of the scrollable columns.
You can use chart.setVisibleXRangeMaximum(10)
to control the number of entries that should be visible at once. If the chart contains more values, it will automatically allow scrolling.
More here: 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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With