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.66k stars 607 forks source link

Faceted charts with `"autosize": "none"` should be rendered as if no autosize was defined #7560

Open wylieconlon opened 3 years ago

wylieconlon commented 3 years ago

There is a bug where autosize: none causes an empty chart rendering when using faceting. Vega-Lite should remove the autosize: none setting from the Vega compiled output when using facet, row, column, or any concat operator, This is similar to how width: container is treated as a special case for autosize.

Example spec that renders as expected:

{
  "$schema": "https://vega.github.io/schema/vega-lite/v5.json",
  "data": {
    "values": [
      {"a": "A", "b": 28},
      {"a": "B", "b": 55},
      {"a": "C", "b": 43},
      {"a": "D", "b": 91},
      {"a": "E", "b": 81},
      {"a": "F", "b": 53},
      {"a": "G", "b": 19},
      {"a": "H", "b": 87},
      {"a": "I", "b": 52}
    ]
  },
  "vconcat": [
    {
      "mark": "bar",
      "encoding": {
        "x": {"field": "a", "type": "ordinal" },
        "y": {"field": "b", "type": "quantitative"}
      }
    },
    {
      "mark": "bar",
      "encoding": {
        "x": {"field": "a", "type": "ordinal" },
        "y": {"field": "b", "type": "quantitative"}
      }
    }
  ]
}
Screen Shot 2021-06-28 at 2 27 46 PM

To cause the bug, add "autosize": "none".

{
  "$schema": "https://vega.github.io/schema/vega-lite/v5.json",
  "autosize": "none",
  "data": {
    "values": [
      {"a": "A", "b": 28},
      {"a": "B", "b": 55},
      {"a": "C", "b": 43},
      {"a": "D", "b": 91},
      {"a": "E", "b": 81},
      {"a": "F", "b": 53},
      {"a": "G", "b": 19},
      {"a": "H", "b": 87},
      {"a": "I", "b": 52}
    ]
  },
  "vconcat": [
    {
      "mark": "bar",
      "encoding": {
        "x": {"field": "a", "type": "ordinal" },
        "y": {"field": "b", "type": "quantitative"}
      }
    },
    {
      "mark": "bar",
      "encoding": {
        "x": {"field": "a", "type": "ordinal" },
        "y": {"field": "b", "type": "quantitative"}
      }
    }
  ]
}
Screen Shot 2021-06-28 at 2 27 38 PM
domoritz commented 3 years ago

Thanks for the report. Can you send a pull request to fix it?

salcc commented 1 year ago

Is there any way to work around this if I need to specify autosize="none" for just the first chart I concatenate?