Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Need Help. How to show labels in xAxis for GroupedBarChart? #3728

Closed
SergeyDevUA opened this issue Nov 3, 2018 · 1 comment
Closed

Need Help. How to show labels in xAxis for GroupedBarChart? #3728

SergeyDevUA opened this issue Nov 3, 2018 · 1 comment

Comments

@SergeyDevUA
Copy link

SergeyDevUA commented Nov 3, 2018

[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

@liuxuan30
Copy link
Member

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants