Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Make barWidth fix in barchart

Tags:

ios-charts

I am using Charts library. I want to keep chart max width fix. I didn't find any way to restrict to some width.

enter image description here

like image 515
Santosh Singh Avatar asked Mar 10 '26 03:03

Santosh Singh


2 Answers

There is a way to make sure the width of a bar is never more than a certain proportion of the screen width. For example setting the setVisibleXRangeMinimum to 10 means each bar will be around 1/10 of the screen width

barChart.setVisibleXRangeMinimum(10.0)

You can also set the maximum:

barChart.setVisibleXRangeMaximum(10.0)
like image 185
DevB2F Avatar answered Mar 11 '26 16:03

DevB2F


Finally, I am able to find the problem in my code. I was adding long value for X, which was creating the problem. I corrected the X value and everything is perfect :)

BarChartDataEntry(x: Double(x_Value), y: Double(y_Value))
like image 31
Santosh Singh Avatar answered Mar 11 '26 16:03

Santosh Singh