Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I make my HorizontalBarChart scrollable?

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).

like image 526
squeegene Avatar asked Oct 18 '15 07:10

squeegene


People also ask

How do I make my scroll bar horizontal?

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.

How do I add a horizontal scroll bar in Excel?

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.

How to make a table horizontally scrollable in HTML?

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:

How do I make a chart scroll?

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.

How to make The navbar scrollable?

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.

How do I set the position of the scrollbar in a table?

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.


2 Answers

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

like image 100
Philipp Jahoda Avatar answered Sep 18 '22 21:09

Philipp Jahoda


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

like image 23
fahrizal89 Avatar answered Sep 21 '22 21:09

fahrizal89