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

widget generated with vegaEmbed transform dates to numbers when exporting to vega editor #1038

Open
mtiberghien opened this issue Dec 19, 2022 · 0 comments

Comments

@mtiberghien
Copy link

Hi,

I've created a vega spec based on a small datasource where dates as written with the following form "yyyy-mm-dd" so that the spec date can be human readable.

The spec code is here.
The spec is embedded in a web page using https://cdn.jsdelivr.net/npm/vega-embed@6 script.
The page code is here.

The widget can be viewed here

My issue occurs when I'm using "View Source" or "Open in Vega Editor" which is provided in button created by vegaEmbed.

The dates in my datasource are now stored as timestamp and not string.
This breaks my spec because I was using a parser to convert my string dates.

Here is the code used in my spec (in data)

"data": [
    {
      "name":"dates",
      "format":{"parse":{"debut":"utc:%Y-%m-%d","fin":"utc:%Y-%m-%d"}},
      "values":[
        {"debut":"2022-11-7", "fin":"2022-11-7", "module":"Algorithmie", "code":9601, "type":"Environnement", "enseignant":"Didier Razon"},
        {"debut":"2022-11-8", "fin":"2022-11-8", "module":"Rôle et comportement du consultant", "code":6480, "type":"Comportement", "enseignant":"Sylvie Deprez"},
        {"debut":"2022-11-9", "fin":"2022-11-9", "module":"Algorithmie", "code":8082, "type":"Environnement", "enseignant":"Didier Razon"}]
    }]

Here is the code when viewing source or exporting in vega editor

  "data": [
    {
      "name": "dates",
      "format": {"parse": {"debut": "utc:%Y-%m-%d", "fin": "utc:%Y-%m-%d"}},
      "values": [
        {
          "debut": 1667779200000,
          "fin": 1667779200000,
          "module": "Algorithmie",
          "code": 9601,
          "type": "Environnement",
          "enseignant": "Didier Razon"
        },
        {
          "debut": 1667865600000,
          "fin": 1667865600000,
          "module": "Rôle et comportement du consultant",
          "code": 6480,
          "type": "Comportement",
          "enseignant": "Sylvie Deprez"
        },
        {
          "debut": 1667952000000,
          "fin": 1667952000000,
          "module": "Algorithmie",
          "code": 8082,
          "type": "Environnement",
          "enseignant": "Didier Razon"
        }]
    }]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant