简体   繁体   English

如何在iOS图表中显示没有Y轴的Y网格线

[英]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. 我正在使用“ danielgindi / Charts”(iOS图表)来制作图表,我希望能够显示Y轴的网格线,但没有基数。

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". 设置左轴图表时,如果您不想显示第一行,请将此属性设置为“ false”。

chartView.leftAxis.drawAxisLineEnabled = false

This will give you this result. 这会给你这个结果。

在此处输入图片说明

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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