Charts: Need Help. How to show labels in xAxis for GroupedBarChart?

Created on 3 Nov 2018  路  1Comment  路  Source: danielgindi/Charts

[yes] I've read, understood, and done my best to follow the *CONTRIBUTING guidelines.

Hello, I try add labels in xAxis, I find it is common question in Issues, but, I can't still fix it for me.

What did you do?

`chartView.chartDescription?.enabled = false
chartView.pinchZoomEnabled = false
chartView.drawBarShadowEnabled = false

    let marker = BalloonMarker(color: UIColor(white: 180.0/255.0, alpha: 1.0),
                               font: .systemFont(ofSize: 12.0),
                               textColor: .white,
                               insets: UIEdgeInsets(top: 8.0, left: 8.0, bottom: 20.0, right: 8.0))
    marker.chartView = chartView
    marker.minimumSize = CGSize(width: 80.0, height: 40.0)
    marker.textColor = UIColor.white
    chartView.marker = marker

    let l = chartView.legend
    l.textColor = UIColor.white
    l.horizontalAlignment = .left
    l.verticalAlignment = .bottom
    l.orientation = .horizontal
    l.drawInside = false
    l.font = .systemFont(ofSize: 8.0, weight: .light)
    l.yOffset = 0.0
    l.xOffset = 10.0
    l.yEntrySpace = 0.0
    l.enabled = true

    let xAxis = chartView.xAxis
    xAxis.labelTextColor = UIColor.red
    xAxis.labelFont = .systemFont(ofSize: 20.0, weight: .light)
    xAxis.drawAxisLineEnabled = true
    xAxis.drawGridLinesEnabled = false
    xAxis.drawLabelsEnabled = true
    xAxis.labelPosition = .bottom
    xAxis.valueFormatter = IndexAxisValueFormatter(values: ["1", "2"])
    xAxis.granularity = 1.0
    xAxis.granularityEnabled = true
    xAxis.forceLabelsEnabled = true

    let leftAxisFormatter = NumberFormatter()
    leftAxisFormatter.maximumFractionDigits = 1

    let leftAxis = chartView.leftAxis
    leftAxis.labelTextColor = UIColor.white
    leftAxis.labelFont = .systemFont(ofSize: 10.0, weight: .light)
    leftAxis.valueFormatter = LargeValueFormatter()
    leftAxis.spaceTop = 0.35
    leftAxis.axisMinimum = 0.0

    // RightAxis
    chartView.rightAxis.enabled = false // this fixed the extra xAxis grid lines
    chartView.rightAxis.drawLabelsEnabled = false

    //slidersValueChanged(nil)

    setDataCount(Int(sliderX), range: UInt32(sliderY))`

What did you expect to happen?

2018-11-03 02 57 08

What happened instead?

2018-11-03 02 55 33

Charts Environment

*Charts version/Branch/Commit Number: Using Charts (3.2.1)
*
Xcode version:Version 10.1 (10B61)
*Swift version: Swift 4.2
*
Platform(s) running Charts: iOS
**macOS version running Xcode: macOS Mojave 10.14

Demo Project

https://github.com/danielgindi/Charts

>All comments

I guess you don't check out ChartsDemo. It should work.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

newbiebie picture newbiebie  路  3Comments

cilasgimenez picture cilasgimenez  路  4Comments

guanyanlin picture guanyanlin  路  3Comments

Aungbandlab picture Aungbandlab  路  4Comments

Shunshine07 picture Shunshine07  路  3Comments