A responsive chart demo in Vega. The spec is a modification of a Vega-Lite output:
- Set width and height to be signals. The signals gets their initial values from
containerSize()
, and listens to subsequent resize events onwindow:resize
. - Use
autosize: { type: "fit", contains: "padding" }
. This ensures that the width / height correspond to the entire chart, not the plotting area.
Click Open
and resize the window to see this example in action.