How to change bandwidth in MPAndroidChart BarChart?

I am using the MPAndroidChart library .

I would like to resize the panel present on the histogram. Could you tell us where you can check the font size on the histogram in the mp android table.

+5
source share
3 answers

You can reduce the distance between the strips, which will automatically increase the width of the bars.

BarDataSet set = new BarDataSet(vals, "Set A"); set.setBarSpacePercent(50f); 

UPDATE v3.0.0:

With this version of the library, you can control the bandwidth as follows:

 BarData barData = new BarData(...); barData.setBarWidth(1f); 

The number you provided for this method is a specific interval along the x axis. If your common axis has a range, for example. 10k and you set the bandwidth to 1000, the bar will cover 10% of the total range on the x axis.

+12
source

As for the latest version of the library, BarDataSet no longer has this function, its in the BarData class.

 BarData data = new BarData(dataset); data.setBarWidth(0.5f); 
+4
source

This applies to the MPAndroidChart API. To reduce the width of the bar, you need to increase the space between the bars (as Rakesh mentioned above). A value of 50F should be good for a mobile display, but you can increase / decrease it according to the screen of your device.

Sample code requested by one user:

  BarDataSet barDataSet = new BarDataSet(group1, "X"); barDataSet.setColors(ColorTemplate.COLORFUL_COLORS); barDataSet.setBarSpacePercent(50f); 

Import API -

 import com.github.mikephil.charting.data.BarDataSet; 
0
source

Source: https://habr.com/ru/post/1215986/


All Articles