Eugleo
Eugleo

Reputation: 438

Hiding separator lines and top border line in iOS Charts

I have a generated chart. I'm trying to make it as simple as possible, thus removing all the unneeded lines, grids, labels etc. I can't get rid of the separator line between the bars and the top and right border lines, as you can see on the picture. I'm using HorizontalBarChart.

enter image description here

Also, here you can see my chart setup code, I tried to disable literally everything:

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
}

Upvotes: 3

Views: 2793

Answers (2)

Bhagyalaxmi Poojary
Bhagyalaxmi Poojary

Reputation: 1213

This may help you :

    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

Upvotes: 6

Newbie.Dev
Newbie.Dev

Reputation: 81

check your code, Is it like ? let xAxis = classWinrateChart.rightAxis

classWinrateChart.rightAxis is rightAxis, not xAxis.

Upvotes: 0

Related Questions