This website is for Vega-Lite v4. Go to the main Vega-Lite homepage for the latest release.

Bar Chart with a spacing-saving y-axis

Bar Chart with a spacing-saving y-axis

View this example in the online editor

Vega-Lite JSON Specification

{
  "$schema": "https://vega.github.io/schema/vega-lite/v4.json",
  "description": "Bar Chart with a spacing-saving y-axis",
  "data": {"url": "data/cars.json"},
  "height": {"step": 50},
  "mark": {"type": "bar", "yOffset": 5, "cornerRadiusEnd": 2},
  "encoding": {
    "y": {
      "field": "Origin",
      "scale": {"padding": 0},
      "band": 0.5,
      "axis": {
        "bandPosition": 0,
        "grid": true,
        "domain": false,
        "ticks": false,
        "labelAlign": "left",
        "labelBaseline": "middle",
        "labelPadding": -5,
        "labelOffset": -15,
        "titleX": 5,
        "titleY": -5,
        "titleAngle": 0,
        "titleAlign": "left"
      }
    },
    "x": {
      "aggregate": "count",
      "axis": {"grid": false},
      "title": "Number of Cars"
    }
  }
}