In the bar chart I am creating the first and last rows are consistently being cut in half (even if I add additional bars). This also causes the values above the bar
Please use setAxisMinimum
and setAxisMaximum
, it will work perfectly!
After your BarData
is instantiated, you just need
chart.getXAxis().setAxisMinimum(-data.getBarWidth() / 2);
chart.getXAxis().setAxisMaximum(count-data.getBarWidth() / 2);`
There is no need for setFitBars
, and the count is BARENTRY
size.
If the problem is with the first bar only, you can use negative values for the axis minimum:
xAxis.setAxisMinimum(-0.5f);
Like in the answer to this question here:
To answer your questions:
In order to properly show your bars you need to fit the bars, like this (don't ask me why it's not enabled by default):
chart.setFitBars(true)
You can find more information in the BarChart
javadocs:
setFitBars(boolean enabled): Adds half of the bar width to each side of the x-axis range in order to allow the bars of the barchart to be fully displayed.
If you have a CombinedChart
you could use setSpaceMin() and setSpaceMax() to add additional spacing on both ends of the axis:
XAxis xAxis = chart.getXAxis();
xAxis.setSpaceMin(barData.getBarWidth() / 2f);
xAxis.setSpaceMax(barData.getBarWidth() / 2f);
It is currently impossible to infuence the value positions rendered on the axis. Creating a ValueFormatter
only changes the displayed text, not the actual position of the label.
i just fixed it,settings the x range min, using
barChart.setFitBars(true);
barChart.setVisibleXRangeMinimum(barEntries.size());