Hello, I'm trying to add spacing in between bars on a BarChat. The method setBarSpacePercent is giving an error, and I cannot find another method which allows me to add space. On another page, I read that you now must do this by using something like this:
float spaceForBar = 10f;
for (int i = 0; i < count; i++) {
float val = (float) (Math.random() * range);
yVals1.add(new BarEntry(i * spaceForBar, val));
}
However this isn't really an option, since I have a fixed number of labels and I can't really add empty entries without my graph crashing/not looking the way I like.
If anyone knows a way of adding space without adding empty bars I would very much appreciate that.
Thanks.
Since v3, the space between bars is determined by their x-position and the bar-width.
If you have a bar each interval of 1f on the x-axis, and a bar width of 0.9f, there will be 0.1f space between bars.
barData.setBarWidth(...) allows you to control the bar-width, default is 1.
Here you can find an example of how to set data for BarChart.
Most helpful comment
Since v3, the space between bars is determined by their x-position and the bar-width.
If you have a bar each interval of 1f on the x-axis, and a bar width of 0.9f, there will be 0.1f space between bars.
barData.setBarWidth(...)allows you to control the bar-width, default is 1.