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

Correct date on x axis #1325

Closed
lee-msr opened this issue Aug 16, 2016 · 3 comments
Closed

Correct date on x axis #1325

lee-msr opened this issue Aug 16, 2016 · 3 comments

Comments

@lee-msr
Copy link

lee-msr commented Aug 16, 2016

I have bunch of data that have dates on it with following format for example "9 Jan 12:00", "9 Jan 12:05", "9 Jan 12:10" etc. More accurately its in raw format and Im using NSNumberFormatter to get it in right format.

For example Dates = ["8 Jan 14:15", "9 Jan 12:00", "9 Jan 12:05", "9 Jan 12:10", "10 Jan 12:00", "10 Jan 12:05", "10 Jan 12:10", etc..] Basically bunch of data

The problem is that the X axis plotting wrong interval. It starts plots "8 Jan 14:15", "9 Jan 06:55" etc.

I want it to start with "9 Jan 12:00", "9 Jan 18:00", "10 Jan 12:00", "10 Jan 18:00", "11 Jan 12:00", etc..

@liuxuan30
Copy link
Member

not having a chance looking at v3 yet. not sure if it supports this.. @danielgindi ?

@lee-msr
Copy link
Author

lee-msr commented Aug 17, 2016

Looking through v3. So far haven't found anything that handles the x axis data

@jiadw007
Copy link

Use DefaultAxisValueFormatter.
charView.xAxis.valueFormatter = DefaultAxisValueFormatter.with(block:{
(value, axis) ->String in
//value is time interval
let date = Date(timeIntervalSince1970: value)
let dateFormatter = DateFormatter()
return dateFormatter.date(from: date)
})
You can also write dateFormatter as extension

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