Janardhan Y
Janardhan Y

Reputation: 257

I used MPAndroidChart library in my app, How to give space between bars?

Can you tell how to give space between the bars and fit to the screen.

Issue

I had reduced bar width with chart.getLayoutParams().width=70. my graph compressed and it is not looking good. I want to give space between them so that i will look good

Upvotes: 2

Views: 4524

Answers (3)

Suresh Maidaragi
Suresh Maidaragi

Reputation: 2308

As per the latest MpChart Library, you should use

            val data = BarData(dataSets)
            data.barWidth = 0.7f //bar width
            data.getGroupWidth(0f, 2f)//space between bars

Above code is in kotlin

Upvotes: 0

eli
eli

Reputation: 9228

You can use this:

chart.getXAxis().setSpaceMax(1);

or follow the solution proposed by PhilJay in the related GitHub issue:

Space between individual bars:

barDataSet.setBarSpacePercent(...);

Space between DataSets:

barData.setGroupSpace(...);

Values in percent.

Upvotes: 0

Oleh
Oleh

Reputation: 41

Maybe try spaceview to create space between the bars?

Upvotes: 1

Related Questions