1

I am trying to display a bar chart using this library with months as the X-label. However, the x labels seem to be duplicating and "bleeding" to the next columns especially when I scroll. How do I fix this?

enter image description here

enter image description here

Code:

let xAxis = barChartView.xAxis
    xAxis.drawGridLinesEnabled = false
    xAxis.drawLabelsEnabled = true
    xAxis.drawAxisLineEnabled = false
    xAxis.labelPosition = .bottom
    xAxis.enabled = true
    xAxis.axisLineColor = white
    xAxis.labelTextColor = white
    xAxis.decimals = 0
    xAxis.granularity = 1
    xAxis.granularityEnabled = true

After grabbing data

    // indexCounter = # of data points
    xAxis.valueFormatter = IndexAxisValueFormatter(values: xAxisLabelValues)
    xAxis.setLabelCount(Int(indexCounter), force: true)
    notifyDataSetChanged()

1 Answer 1

0

No idea how it works.. but removing the setLabelCount fixed the problem for me...

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.