{
  "$schema": "https://vega.github.io/schema/vega/v4.json",
  "width": 600,
  "height": 360,
  "autosize": "fit",
  "data": [
    {
      "name": "pyramid_data1",
      "url": "<%= absolute_url %>data/stacked-pyramid.json",
      "transform": [
        {
          "type": "stack",
          "groupby": [
            "Ranks"
          ],
          "field": "value",
          "offset": "center",
          "sort": {
            "field": "name",
            "order": "descending"
          },
          "as": [
            "value1",
            "value2"
          ]
        }
      ]
    }
  ],
  "scales": [
    {
      "name": "py_xscale",
      "type": "linear",
      "domain": {
        "data": "pyramid_data1",
        "field": "value2"
      },
      "range": "width"
    },
    {
      "name": "py_yscale",
      "type": "band",
      "padding": 0.3,
      "domain": {
        "data": "pyramid_data1",
        "field": "Ranks"
      },
      "range": "height"
    },
    {
      "name": "color",
      "type": "ordinal",
      "range": "category",
      "domain": {
        "data": "pyramid_data1",
        "field": "name"
      }
    }
  ],
  "marks": [
    {
      "type": "rect",
      "from": {
        "data": "pyramid_data1"
      },
      "encode": {
        "enter": {
          "y": {
            "scale": "py_yscale",
            "field": "Ranks"
          },
          "height": {
            "scale": "py_yscale",
            "band": 1,
            "offset": -1
          },
          "x": {
            "scale": "py_xscale",
            "field": "value1"
          },
          "x2": {
            "scale": "py_xscale",
            "field": "value2"
          },
          "fill": {
            "scale": "color",
            "field": "name"
          }
        }
      }
    }
  ]
}
