iosswiftios-charts

iOS-Charts - yAxis labels not start exactly at bottom


I use Charts swift library in my project.I use two datasets in line chart, but the labels of Yaxis not start exactly at bottom.I want the first label on the yAxis to be exactly at bottom-left corner of chart. I try to set minimum of yAxis but it didn't help.

Following is example image.

Image


Solution

  • You need to make use of leftAxis.axisMinValue on your LineChartView property, or whatever type of chart you are graphing. If you set it to 0, then the "0.0" in your chart will be positioned correctly at the very bottom. You can set this to other values and the chart will start at those values too.

    Here is a simple example of it in action:

    @IBOutlet weak var yourChartViewController: LineChartView! // View controller for the chart in a storyboard.
    // Set up your data for the chart...
    
    // Configuring the chart's view
    yourChartViewController.leftAxis.axisMinValue = 0  // This is what you need