vega-lite: UTC dates don't display properly in tooltips
Here is a short example (open in editor):
{
"data": {"values": [{"date": "2021-01-01"}]},
"mark": {"type": "square", "size": 500},
"encoding": {
"tooltip": {
"field": "date",
"timeUnit": "utcyearmonthdatehours"
},
"x": {
"field": "date",
"timeUnit": "utcyearmonthdatehours"
}
}
}
Despite showing identical fields with identical timeUnits, the date shown in the tooltip and the date shown on the axis label disagree.
Note that a workaround is to use "scale": {"type": "utc"} in the tooltip (view in editor), but I don’t think this should be necessary:
{
"data": {"values": [{"date": "2021-01-01"}]},
"mark": {"type": "square", "size": 500},
"encoding": {
"tooltip": {
"field": "date",
"timeUnit": "utcyearmonthdatehours",
"scale": {"type": "utc"}
},
"x": {
"field": "date",
"timeUnit": "utcyearmonthdatehours"
}
}
}
About this issue
- Original URL
- State: closed
- Created 6 years ago
- Reactions: 4
- Comments: 20 (11 by maintainers)
Commits related to this issue
- fix: ensure temporal field propagates to time expression (#8757) Fixes https://github.com/vega/vega-lite/issues/7185 — committed to vega/vega-lite by marr a year ago
Thank you. I’ll take a look.
I just rebased and pushed my existing PR that addresses this https://github.com/vega/vega-lite/pull/8757
You can add
"scale": { "type": "utc" }to the encoding as a workaround.My PR fixes the issue but I wasn’t able to get it merged because of the github access token. It still might be worth trying to merge that, @domoritz