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

How to align labels on left side and put values inside bars on HorizontalBarChartView? [HELP WANTED] #3833

Closed
augustocadini opened this issue Feb 6, 2019 · 1 comment

Comments

@augustocadini
Copy link

augustocadini commented Feb 6, 2019

I've setup my HorizontalBarChartView but ins't show that I want. I want that labels will showed on the left side of my chart, but these labels aren't aligned. And, put the bar's values inside bar.

This is my code of setup chart:


        func setupChart() {
        self.chartViewHorizontal.fitBars                     = true
        self.chartViewHorizontal.legend.enabled              = true
        self.chartViewHorizontal.legend.horizontalAlignment  = .left
        self.chartViewHorizontal.legend.verticalAlignment    = .bottom
        self.chartViewHorizontal.legend.form                 = .circle
        self.chartViewHorizontal.isUserInteractionEnabled    = false
        self.chartViewHorizontal.animate(yAxisDuration: 1.5)
        
        // Baixo
        self.chartViewHorizontal.rightAxis.enabled = false
        
        // Cima
        self.chartViewHorizontal.leftAxis.enabled = false
        
        // Direita
        self.chartViewHorizontal.xAxis.valueFormatter          = IndexAxisValueFormatter(values: labelDias)
        self.chartViewHorizontal.xAxis.labelFont               = UIFont.boldSystemFont(ofSize: 12.0)
        self.chartViewHorizontal.xAxis.drawLabelsEnabled       = true
        self.chartViewHorizontal.xAxis.labelPosition           = XAxis.LabelPosition.bottom
        self.chartViewHorizontal.xAxis.drawAxisLineEnabled     = false
        self.chartViewHorizontal.xAxis.drawGridLinesEnabled    = false
        self.chartViewHorizontal.xAxis.enabled                 = true
    }

and result:

screen shot 2019-02-06 at 09 41 28

Label not aligned:

screen shot 2019-02-06 at 14 42 54

I want this:

screen shot 2019-02-06 at 09 41 28

@augustocadini augustocadini changed the title How to add labels on left side and put values inside bars on HorizontalBarChartView? How to add labels on left side and put values inside bars on HorizontalBarChartView? [HELP WANTED] Feb 6, 2019
@augustocadini augustocadini changed the title How to add labels on left side and put values inside bars on HorizontalBarChartView? [HELP WANTED] How to align labels on left side and put values inside bars on HorizontalBarChartView? [HELP WANTED] Feb 6, 2019
@liuxuan30
Copy link
Member

ask on stack overflow for 'how-to' questions. thanks.
tips: I notice there is a drawValueAboveBar option, so try it out to see

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