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"
    }
  }
}
Screen Shot 2021-01-25 at 3 04 09 PM

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"
    }
  }
}
Screen Shot 2021-01-25 at 3 08 14 PM

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Reactions: 4
  • Comments: 20 (11 by maintainers)

Commits related to this issue

Most upvoted comments

Thank you. I’ll take a look.

It’s not specifically on my queue. But I’d be happy to review a pull request.

We’re all volunteers. If you rely on Vega-Lite, please consider donating so we can eventually hire someone to help with the backlog.

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