【问题标题】:How to show the Y grid lines without the Y-Axis in iOS-charts如何在 iOS 图表中显示没有 Y 轴的 Y 网格线
【发布时间】:2018-09-10 22:32:27
【问题描述】:

我正在使用“danielgindi/Charts”(iOS-charts)制作图表,我希望能够显示 Y 轴的网格线,但没有基础。

这应该是结果:

但我被卡住了,如果不启用左轴就无法获得线条。

这就是我得到的,我想摆脱左边的线。 (红色箭头所指的那个)

这是我的一些代码:

    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
}

感谢任何帮助!

【问题讨论】:

    标签: ios swift ios-charts


    【解决方案1】:

    我自己找到了答案,我决定不删除这个问题,这样如果有人遇到同样的问题,他们可以在这里找到答案。

    设置左轴图表时,如果不想显示第一行,请将此属性设置为“false”。

    chartView.leftAxis.drawAxisLineEnabled = false
    

    这会给你这个结果。

    【讨论】:

      猜你喜欢
      • 2016-03-13
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多