3

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
}
Eugleo
  • 418
  • 4
  • 11

2 Answers2

6

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
Bhagyalaxmi Poojary
  • 1,213
  • 1
  • 12
  • 17
  • Thanks to you, this answer should be accepted as well. Can I have one more help? I can't disable leftAxis as shown in this fig (https://puu.sh/vYVW5/78722a9414.png). And when i applied you code, it hide also the yaxis label and it separator. I don't want to hide the label, I just want to hide separator and give some spacing. Is there any way? – Thiha Aung May 23 '17 at 09:15
0

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

classWinrateChart.rightAxis is rightAxis, not xAxis.

Rao
  • 20,781
  • 11
  • 57
  • 77
Newbie.Dev
  • 71
  • 1
  • 4