-
-
Notifications
You must be signed in to change notification settings - Fork 635
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
fix: properly support utc timeunits. #5780
Conversation
ef5df5c
to
cf7c6d0
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Have you test with data to avoid double shifts?
Some of the code changes here look suspicious.
The docs say "Do not use UTC time unit and the UTC scale type at the same time since that will cause Vega-Lite to shift the output time twice." But that doesn't seem to happen {
"data": {
"values": [
{"date": "Sun, 01 Jan 2012 23:00:00", "price": 150},
{"date": "Sun, 02 Jan 2012 00:00:00", "price": 100},
{"date": "Sun, 02 Jan 2012 01:00:00", "price": 170},
{"date": "Sun, 02 Jan 2012 02:00:00", "price": 165},
{"date": "Sun, 02 Jan 2012 03:00:00", "price": 200}
]
},
"mark": "line",
"encoding": {
"x": {
"field": "date",
"type": "temporal",
"timeUnit": "utcyearmonthdatehoursminutes",
"scale": {"type": "utc"}
},
"y": {"field": "price", "type": "quantitative"}
}
} It doesn't seem to matter whether I set the scale type to utc or not {
"$schema": "https://vega.github.io/schema/vega-lite/v4.json",
"data": {
"values": [
{"date": "2011-01-01T23:00:00.000+00:00"},
{"date": "2011-01-02T00:00:00.000+00:00"},
{"date": "2011-01-02T01:00:00.000+00:00"},
{"date": "2011-01-02T02:00:00.000+00:00"},
{"date": "2011-01-02T03:00:00.000+00:00"}
]
},
"mark": "line",
"encoding": {
"x": {
"field": "date",
"type": "temporal",
"timeUnit": "utcyearmonthdatehoursminutes",
"scale": {"type": "utc"},
"title": null
}
}
} I think that's nice but we should look into a) why this is different, b) change the docs, c) make sure that this is not a breaking change (we don't recommend using both scale type and time unit so this should be okay). |
Here is a sanity check I did. Looks right. {
"$schema": "https://vega.github.io/schema/vega-lite/v4.json",
"data": {
"values": [
{"date": "2011-01-01T23:00:00.000+00:00"},
{"date": "2011-01-02T00:00:00.000+00:00"},
{"date": "2011-01-02T01:00:00.000+00:00"},
{"date": "2011-01-02T02:00:00.000+00:00"},
{"date": "2011-01-02T03:00:00.000+00:00"}
]
},
"mark": "point",
"encoding": {
"y": {
"field": "date",
"type": "ordinal",
"timeUnit": "utcyearmonthdatehoursminutes",
"title": null
}
}
} |
Another experiment {
"$schema": "https://vega.github.io/schema/vega-lite/v4.json",
"data": {
"values": [
{"t": "2011-01-02T00:00:00.000+00:00"},
{"t": "2011-01-02T01:00:00.000+00:00"},
{"t": "2011-01-02T02:00:00.000+00:00"},
{"t": "2011-01-02T03:00:00.000+00:00"}
]
},
"mark": "point",
"encoding": {
"x": {
"type": "temporal",
"field": "t",
"timeUnit": "hours",
"title": "hours"
},
"y": {
"type": "temporal",
"field": "t",
"timeUnit": "utchours",
"title": "utchours"
}
}
} |
4cc5784
to
f4671d1
Compare
ready to merge |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I exclude spec changes that are irrelevant to time unit.
I also made a bit updates to the examples to make it even easier to read.
Feel free to merge after all tests pass.
Thanks Ham! |
Thanks for your work on this! |
Fixes #5777