Search code examples
vega-litevega

Grid with Pre-Binned Data


With "bin": "binned" I can use pre-binned data. How can I enable the grid? It seems that during the vega-lite to vega translation my grid settings are overridden to false.

{ "mark": "bar",
  "encoding": {
    "x": {
      "type": "temporal",
      "bin": "binned",
      "field": "start",
      "axis": {"grid": true}
    },
    "x2": {"field": "end"},
    "y": {"type": "quantitative", "field": "value"}
  },
  "transform": [
    {"calculate": "toDate(datum.day)", "as": "day"},
    {"calculate": "timeOffset('hours', datum.day, -12)", "as": "start"},
    {"calculate": "timeOffset('hours', datum.day, 12)", "as": "end"}
  ],
  "height": 250,
  "width": 800,
  "$schema": "https://vega.github.io/schema/vega-lite/v4.json",
  "data": {
    "values": [
      {"day": "2021-01-01T00:00:00", "value": 5},
      {"day": "2021-01-02T00:00:00", "value": 4},
      {"day": "2021-01-04T00:00:00", "value": 5},
      {"day": "2021-01-05T00:00:00", "value": 4},
      {"day": "2021-01-09T00:00:00", "value": 1},
      {"day": "2021-01-10T00:00:00", "value": 3},
      {"day": "2021-01-11T00:00:00", "value": 2},
      {"day": "2021-01-12T00:00:00", "value": 3},
      {"day": "2021-01-13T00:00:00", "value": 5},
      {"day": "2021-01-15T00:00:00", "value": 3}
    ]
  }}

If there is no schema solution, can the grid be re-enabled via the view api?


Solution

  • This is the pull request fixing this issue. May not lead to anything.

    • #7192 fix: allow axis settings when ("bin":"binned")