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

Displaying float values in bar chart label. #2517

Closed
gabhisekdev opened this issue Jun 13, 2017 · 1 comment
Closed

Displaying float values in bar chart label. #2517

gabhisekdev opened this issue Jun 13, 2017 · 1 comment

Comments

@gabhisekdev
Copy link

Hi,

I have a bar chart in my project in XCode 8.3 and SWIFT 3. I want to display float values upto a max of 2 decimal places and a minimum of 0 decimal places depending upon the value of data passed.

My current code:

To pass data:

var dataEntries: [BarChartDataEntry] = []
        for i in 0...weekData.count-1 {
            print("\(i) day data \(Double(weekData[i]))") //e.g. weekData = [0.0,12.03,3.0]
            var dataEntry = BarChartDataEntry(x: Double(i), y: Double(weekData[i]))
            dataEntries.append(dataEntry)
        }
        let chartDataSet = BarChartDataSet(values: dataEntries, label: nil)
let chartData = BarChartData(dataSet: chartDataSet)

Problem:
My values are not displayed in float rather are rounded off to nearest whole number.

So is there any way to achieve this?

@liuxuan30
Copy link
Member

use valueFormatter

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