0

One of my app using Charts library for drawing graphs.

Everything works fine but in BarChartView it's adding some default margin around the chart and I have done the below changes in the Chart property but still, it's not removing the margin around the graph.

I have also checked the same issue on this Question thread but no luck at all.

Check below screenshot for margin issue:

enter image description here

I have done the below changes for removing the margin around BarChart.

_barChartView.minOffset = 0;
    
_barChartView.xAxis.enabled = NO;
            
ChartYAxis *leftAxis = _barChartView.leftAxis;
leftAxis.drawGridLinesEnabled = NO;
            
_barChartView.leftAxis.enabled = NO;
_barChartView.leftAxis.drawAxisLineEnabled = NO;
            
_barChartView.rightAxis.enabled = NO;
_barChartView.rightAxis.drawAxisLineEnabled = NO;
_barChartView.legend.enabled = NO;

But still, I am not able to remove the margin.

Also checked Charts Demo app has the same issue while changing data from the slider.

Check Below screenshot from Chart Demo App:

enter image description here

Any help or hint appreciated :)

CodeChanger
  • 7,953
  • 5
  • 49
  • 80

2 Answers2

3

Hello I have checked in the demo of Charts library which you have provided.

Where i have added below code and it's work, check the screenshot below.

BarChartViewController.h Add this code on line number : 115

_chartView.minOffset = 0;

_chartView.xAxis.enabled = NO;

_chartView.leftAxis.enabled = NO;
_chartView.leftAxis.drawAxisLineEnabled = NO;

_chartView.rightAxis.enabled = NO;
_chartView.rightAxis.drawAxisLineEnabled = NO;
_chartView.legend.enabled = NO;

enter image description here

enter image description here

let me know for more.

Here is the output of my simulator with blue background.

enter image description here

Bhavesh Dhaduk
  • 1,888
  • 15
  • 30
1

I know this is old but just for anyone who stumbles upon the question

This solved it for me

barChartView.leftAxis.axisMinimum = 0
barChartView.rightAxis.axisMinimum = 0
Ando
  • 1,802
  • 4
  • 25
  • 47