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 display the integer values on pie chart instead of float? #3093

Closed
shilpashreeamt opened this issue Dec 13, 2017 · 2 comments
Closed

Comments

@shilpashreeamt
Copy link

shilpashreeamt commented Dec 13, 2017

screen shot 2017-12-13 at 10 34 19 am
Hi,
I tried to customise the library in order to display the int values(Above image represents my requirement)...in some links they mentioned to follow NSNumberFormatter.But i failed to use that solution am not getting which class i should customise to get the required solution...can any one help me to resolve this issue.
I spent more than a day to find solution but no use.
Thanks in advance

@shilpashreeamt
Copy link
Author

After many trials i found the answer

let track = ["Passed", "Failed", "Pending"]
let money = [10, 6, 10]
var entries = PieChartDataEntry
for (index, value) in money.enumerated() {
let entry = PieChartDataEntry()

        entry.y = Double(value)
       
       entry.label = track[index]
        entries.append( entry)
    }

let set = PieChartDataSet( values: entries, label: "")
let data = PieChartData(dataSet: set)
pieChartView.data = data
let formatter = NumberFormatter()
formatter.minimumFractionDigits = 0
data.setValueFormatter(DefaultValueFormatter(formatter:formatter))

@chanoktrue
Copy link

thank you

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