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

UTC dates don't display properly in tooltips #7185

Open
jakevdp opened this issue Jan 25, 2021 · 14 comments · May be fixed by #8757
Open

UTC dates don't display properly in tooltips #7185

jakevdp opened this issue Jan 25, 2021 · 14 comments · May be fixed by #8757
Assignees
Labels
Bug 🐛 P2 Important Issues that should be fixed soon

Comments

@jakevdp
Copy link
Contributor

jakevdp commented Jan 25, 2021

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

@jakevdp
Copy link
Contributor Author

jakevdp commented Jan 25, 2021

It looks like this also affects the text encoding, which makes the issue easier to see (open in editor):

{
  "data": {"values": [{"date": "2021-01-01"}]},
  "mark": "text",
  "encoding": {
    "text": {"field": "date", "timeUnit": "utcyearmonthdatehours"},
    "x": {"field": "date", "timeUnit": "utcyearmonthdatehours"}
  }
}

visualization (31)

@domoritz domoritz added the P2 Important Issues that should be fixed soon label Jan 26, 2021
@domoritz domoritz self-assigned this Jan 26, 2021
@rnvarma
Copy link

rnvarma commented Jan 29, 2021

I am experiencing the same problem here. It is a pretty big issue for us and is blocking on going to production since data integrity is very important

image

@domoritz
Copy link
Member

Ahh, the joy of time zones again.

@rnvarma can you look into what's going on in the Vega specs? It would help us immensely scope the effort for the fix.

@rnvarma
Copy link

rnvarma commented Feb 1, 2021

the config for the x encoding above is:

{
  field: "created",
  title: "Created",
  type: "temporal",
  timeUnit: "utcyearmonthdate",
  axis: { format: "%b %d" },
}

The date value itself in the data is 2020-08-04T00:00:00. It is correctly using UTC for the x axis value, but in the tooltip converting to local time and going back to the previous day

@bbkane
Copy link

bbkane commented May 16, 2022

I'm also running into this for point charts. Apologies if this isn't a minimal example, I'm new to Vega-Lite.

{
  "$schema": "https://vega.github.io/schema/vega-lite/v5.json",
  "data": {
    "values": [
      {"Date": "2020-01-01", "Value": 10}
    ]
  },
  "mark": {"type": "point", "tooltip": true, "point": true},
  "height": "container",
  "width": "container",
  "encoding": {
    "x": {"field": "Date", "type": "temporal"},
    "y": {"field": "Value", "type": "quantitative"},
    "opacity": {"condition": {"param": "hover", "value": 1}, "value": 0.1},
  },
  "title": {"text": "Diff"},
  "params": [
    {
      "name": "hover",
      "bind": "legend",
      "select": {"type": "point", "fields": ["symbol"]}
    }
  ]
}

image

Open the Chart in the Vega Editor

@marr
Copy link

marr commented Oct 18, 2022

@jakevdp Do you plan to upgrade the altair version so it supports scale on the tooltip?

@marr
Copy link

marr commented Mar 3, 2023

Still running into this issue. Any ETA for a fix?

@domoritz
Copy link
Member

domoritz commented Mar 3, 2023

I haven't had cycles to look into this yet. Can you investigate and maybe send a pull request?

@marr
Copy link

marr commented Mar 4, 2023

I can take a look. I had thought the workaround wasn't working, but it actually does. The schema has a squiggle under the value, but I am learning that shouldn't always be trusted.

@marr marr linked a pull request Mar 4, 2023 that will close this issue
@sirusss
Copy link

sirusss commented Jul 11, 2023

Anyone find a solution for this issue yet? I was going crazy thinking there was an issue with my data or how my data was read by altair, but finally realized it's an error in how altair renders the mark line tooltip.

@marr
Copy link

marr commented Jul 11, 2023

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

@sirusss
Copy link

sirusss commented Jul 12, 2023

That worked - thank you!

@jsherman256
Copy link

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

Did that PR make it in? If so, what version fixes this?

@marr
Copy link

marr commented Sep 6, 2023 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug 🐛 P2 Important Issues that should be fixed soon
Projects
None yet
Development

Successfully merging a pull request may close this issue.

7 participants