Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to show the Y grid lines without the Y-Axis in iOS-charts

I am working on a chart, with the "danielgindi/Charts" ( iOS-charts ), I want to be able to show the grid lines for the Y axis, but without the base.

This should be the result:

enter image description here

But I am stuck and can't get the lines without having to enable the left axis.

This is what I am getting, I want to get rid of the line to the left. ( The one the red arrow is pointing to )

enter image description here

Here is some of my code:

    func setupChart(data: LineChartData ) {

    chartView.delegate = self
    chartView.backgroundColor = .white

    chartView.chartDescription?.enabled = false

    chartView.dragEnabled = false
    chartView.setScaleEnabled(false)
    chartView.pinchZoomEnabled = false
    chartView.setViewPortOffsets(left: 10, top: 0, right: 10, bottom: 0)

    chartView.legend.enabled = false

    chartView.leftAxis.enabled = true
    chartView.leftAxis.labelCount = 3
    chartView.leftAxis.spaceTop = 0.70
    chartView.leftAxis.spaceBottom = 0.20

    chartView.rightAxis.enabled = false
    chartView.xAxis.enabled = false

    chartView.data = data
}

Any help is appreciated !!

like image 735
J Arango Avatar asked Oct 26 '25 21:10

J Arango


1 Answers

I was able to find the answer myself, and I decided not to delete this question so that if anyone runs into the same issue they can find the answer here.

When setting your left axis chart, and you do not want the first line to show, set this property to "false".

chartView.leftAxis.drawAxisLineEnabled = false

This will give you this result.

enter image description here

like image 131
J Arango Avatar answered Oct 29 '25 11:10

J Arango



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!