Skip to content

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

Open
@mtiberghien

Description

@mtiberghien

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"
        }]
    }]

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions