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

时间:2016-04-23 07:03:17

标签: swift ios-charts

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

enter image description here

此外,在这里你可以看到我的图表设置代码,我试图禁用字面上的一切:

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
}

2 个答案:

答案 0 :(得分:4)

这可能会对您有所帮助:

undefinded

答案 1 :(得分:0)

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

classWinrateChart.rightAxisrightAxis,而不是xAxis