vega / vega-lite

A concise grammar of interactive graphics, built on Vega.
https://vega.github.io/vega-lite/
BSD 3-Clause "New" or "Revised" License
4.7k stars 616 forks source link

UTC date labels do not display properly, seem to be using local browser timezone #7795

Open mjtribble opened 3 years ago

mjtribble commented 3 years ago

Date labels are shifted one day when viewed in mountain time. Updating browser timezone to UTC shows correct labels

Open in editor

{
  "data": {
    "format": {
      "type": "csv"
    },
    "values": "dt,value\n2021-10-09,450.0,\n2021-10-10,0.0,\n2021-10-11,410.0,\n"
  },
  "mark": {
    "tooltip": true,
    "type": "bar",
    "line": {
      "color": "darkgreen"
    },
    "point": false
  },
  "encoding": {
    "x": {
      "field": "dt",
      "timeUnit": "utcyearmonthdate",
      "title": "Day",
      "type": "ordinal",
      "axis": {
        "grid": false,
        "labelAngle": 0,
        "labelFont": "AgrilystApercu",
        "format": "%b %d",
        "ticks": true,
        "labelPadding": 6,
        "titlePadding": 15
      }
    },
    "y": {
      "field": "value",
      "type": "quantitative",
      "title": "count",
      "axis": {
        "grid": true,
        "domainColor": "white"
      }
    },
    "color": {
      "value": "#5391f5"
    },
    "opacity": {
      "value": 0.4
    }
  }
}
Screen Shot 2021-11-10 at 10 37 31 AM
domoritz commented 3 years ago

Simplified example: Open the Chart in the Vega Editor

domoritz commented 3 years ago

This issue looks a lot like https://github.com/vega/vega-lite/issues/4044.

I wonder whether we changed something in https://github.com/vega/vega-lite/pull/5780. @haldenl @kanitw do you see what's wrong here?

domoritz commented 3 years ago

I think formatType on the y-axis should be utc but it's time.

domoritz commented 3 years ago

https://github.com/vega/vega-lite/pull/7815 fixes the issue.

image
AndrewRybka commented 9 months ago

The same issue affects the labels of nominal fields:

Open the Chart in the Vega Editor

Is it possible to add support for formatType: "utc" which is supported by Vega?

domoritz commented 9 months ago

I don't see an issue with that. Can you send a pull request?

AndrewRybka commented 9 months ago

@domoritz Sure. Here it is: #9265