简体   繁体   中英

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:

在此处输入图片说明

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 )

在此处输入图片说明

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 !!

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.

在此处输入图片说明

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM