在 iOS 图表中隐藏分隔线和顶部边框线

Hiding separator lines and top border line in iOS Charts

我有一个生成的图表。我试图让它尽可能简单,从而删除所有不需要的线条、网格、标签等。我无法摆脱条形图与顶部和右侧边框线之间的分隔线,如您所见图片。我正在使用 Horizo​​ntalBarChart。

此外,在这里你可以看到我的图表设置代码,我试图禁用所有字面意思:

private func setupCharts(selectedHero: Int) {
    classWinrateChart.descriptionText = ""
    classWinrateChart.legend.enabled = false
    classWinrateChart.drawBordersEnabled = false
    classWinrateChart.drawMarkers = false
    classWinrateChart.drawValueAboveBarEnabled = false

    let chartDataSet = BarChartDataSet(yVals: dataSource, label: "Noaaah")
    let chartData = BarChartData(xVals: ["", "", "", "", "", "", "", "", "", ""], dataSet: chartDataSet)
    let color = constants.colors[selectedHero]
    chartDataSet.colors = [color]
    chartDataSet.valueFont = UIFont.systemFontOfSize(13)
    //chartDataSet.drawValuesEnabled = false

    let yAxis = classWinrateChart.leftAxis
    let xAxis = classWinrateChart.rightAxis

    yAxis.enabled = false
    yAxis.drawLabelsEnabled = false
    yAxis.drawAxisLineEnabled = false
    yAxis.drawGridLinesEnabled = false

    xAxis.enabled = false
    xAxis.drawLabelsEnabled = false
    xAxis.drawAxisLineEnabled = false
    xAxis.drawGridLinesEnabled = false

    classWinrateChart.rightAxis.enabled = false

    yAxis.axisMaxValue = 100
    yAxis.axisMinValue = 0

    classWinrateChart.tintColor = colors[selectedHero]

    classWinrateChart.drawGridBackgroundEnabled = false
    classWinrateChart.data = chartData
}

检查你的代码,是吗? let xAxis = classWinrateChart.rightAxis

classWinrateChart.rightAxisrightAxis,而不是 xAxis

这可能对您有帮助:

    var viwBar = BarChartView()

    viwBar.leftAxis.drawGridLinesEnabled = false
    viwBar.rightAxis.drawGridLinesEnabled = false
    viwBar.xAxis.drawGridLinesEnabled = false
    viwBar.drawGridBackgroundEnabled = false

     //removes left and right axis representation
    let yaxis = viwBar.getAxis(ChartYAxis.AxisDependency.Left)
    yaxis.drawLabelsEnabled = false
    yaxis.enabled = false

    let xaxis = viwBar.getAxis(ChartYAxis.AxisDependency.Right)
    xaxis.drawLabelsEnabled = false
    xaxis.enabled = false