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 use a date/string for the X value #1604

Closed
hdoria opened this issue Oct 3, 2016 · 4 comments
Closed

How to use a date/string for the X value #1604

hdoria opened this issue Oct 3, 2016 · 4 comments

Comments

@hdoria
Copy link

hdoria commented Oct 3, 2016

The new Charts version only accepts double for the x value. How can I use a date (or string) for the X value?

ChartDataEntry: public init(x: Double, y: Double)

@Carielle
Copy link

Carielle commented Oct 3, 2016

This issue talks about how to use axis value formatters to use strings as axis labels.

However, I'm still confused about how I can put one string under each bar in a bar chart, instead of the strings lining up with axis gridlines.

@liuxuan30
Copy link
Member

@Carielle I don't understand why you said this. In ChartsDemo, the x axis label is centered in each bar's center.

@madhikarma
Copy link

Hey @hdoria how did you get on? Did you find the new IAxisValueFormatter in Charts v3.0.0 to customise the text to a string?

Just in case: create one a subclass of IAxisValueFormatter, implement func stringForValue(_ value: Double, axis: AxisBase?) -> String and return the string you want there then set your xAxis.valueFormatter to it.

Let us know how you get on and whether to close this issue.

@hdoria
Copy link
Author

hdoria commented Oct 16, 2016

@madhikarma did exactly like you said. Thanks.

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

4 participants