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

PieChart percent values are always rounded up to integer, I would like to show them as float. #1131

Closed
yigitserin opened this issue Jun 13, 2016 · 3 comments

Comments

@yigitserin
Copy link

yigitserin commented Jun 13, 2016

Hi there,

I am using a piechart but having problems with labels of each slice. What I want to achieve is this:
My goal

And this is what I have so far:
My progress

So here are my questions:

  1. How to show labels as Float instead of Int? [SOLVED]
  2. How to show the percent signs near the labels? [SOLVED]
  3. How to hide labels for small slices?

These are my settings so far:

            piechart.highlightPerTapEnabled = false

            piechart.rotationEnabled = false

            piechart.usePercentValuesEnabled = true

            piechart.drawSliceTextEnabled =  false

            piechart.drawHoleEnabled = false
@yigitserin
Copy link
Author

Solved 1 and 2 by using:

            let formatter = NSNumberFormatter()
            formatter.numberStyle = .PercentStyle
            formatter.maximumFractionDigits = 1
            formatter.multiplier = 1.0
            data.setValueFormatter(formatter)

Still need a way to disable labels for slices under X% percent of pie.

@liuxuan30
Copy link
Member

liuxuan30 commented Jun 14, 2016

last one is dup I guess, closing. check #944

@paulowolking
Copy link

let formatter = NSNumberFormatter()
formatter.numberStyle = .PercentStyle
formatter.maximumFractionDigits = 1
formatter.multiplier = 1.0
data.setValueFormatter(formatter)

It is still a valid solution ? Me did not work.

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

No branches or pull requests

3 participants