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

use lineCharts ,if i want show custom string at x, don't show int number, how to do it? #1760

Closed
yuxingmin opened this issue Nov 1, 2016 · 1 comment

Comments

@yuxingmin
Copy link

No description provided.

@TheAbhiGoyal
Copy link

TheAbhiGoyal commented Nov 3, 2016

Use IAxisValueFormatter protocol and then implement the protocol method:
func stringForValue(_ value: Double, axis: AxisBase?) -> String
where you return the string you want to represent on the xAxis.
example:

let vowels = ["A", "E", "I", "O", "U"]
 func stringForValue(_ value: Double, axis: AxisBase?) -> String {
   // Check to make sure the value doesn't go out of index range
 if Int(value) < vowels.count && Int(value) >= 0 { 
      return vowels[Int(value)]
    } else {
      return "consonant"
    }
  }

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

3 participants