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

valueFormatter API changes in Swift 3 #1551

Closed
digidhamu opened this issue Sep 24, 2016 · 2 comments
Closed

valueFormatter API changes in Swift 3 #1551

digidhamu opened this issue Sep 24, 2016 · 2 comments

Comments

@digidhamu
Copy link

I could not figure out from example how the new Chart 3.0 API works for valueFormatter. Below is previous version of snippet. Please advise.

let formatter = NumberFormatter()
formatter.numberStyle = .none
lineChartAltitude.leftAxis.valueFormatter = formatter

@danielgindi
Copy link
Collaborator

The new API does not inherit from the Cocoa's formatters. It passes more information about the value to be formatted, like the X value.
But the formatters can take a number formatter - https://github.com/danielgindi/Charts/blob/master/Source/Charts/Formatters/DefaultAxisValueFormatter.swift#L56, https://github.com/danielgindi/Charts/blob/master/Source/Charts/Formatters/DefaultValueFormatter.swift#L56

You can read the migration notes - it tells exactly how to deal with it if you're not interested in the new formatter api :-)

@digidhamu
Copy link
Author

digidhamu commented Sep 25, 2016

For other benefit. Here are the examples.
@danielgindi Hope below example is right and I can see working now. Please advise.

Line Chart

let format = NumberFormatter()
format.numberStyle = .none   
let formatter = DefaultValueFormatter(formatter: format)
lineChartSpeed.leftAxis.valueFormatter = (formatter as? IAxisValueFormatter)

Pie Chart

let format = NumberFormatter()
format.numberStyle = .none
let formatter = DefaultValueFormatter(formatter: format)
pieChartData.setValueFormatter(formatter)

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