{
  "$schema": "https://vega.github.io/schema/vega/v4.json",
  "width": 600,
  "height": 360,
  "autosize": "fit",
  "data": [
    {
      "name": "data_table",
      "url": "<%= dataset_url %>",
      "transform": [
        {
          "type": "stack",
          "groupby": [
            "<%= data_mapper.column_1 %>"
          ],
          "sort": {
            "field": "<%= data_mapper.column_3 %>"
          },
          "field": "<%= data_mapper.column_2 %>"
        }
      ]
    }
  ],
  "scales": [
    {
      "name": "scales_xScale",
      "type": "linear",
      "range": "width",
      "domain": {
        "data": "data_table",
        "field": "y1"
      }
    },
    {
      "name": "scales_yScale",
      "type": "band",
      "range": "height",
      "domain": {
        "data": "data_table",
        "field": "<%= data_mapper.column_1 %>"
      }
    },
    {
      "name": "scales_color",
      "type": "ordinal",
      "range": [
        "#dd83c4",
        "#e4de89",
        "#81c4e9"
      ],
      "domain": {
        "data": "data_table",
        "field": "<%= data_mapper.column_4 %>"
      }
    }
  ],
  "axes": [
    {
      "orient": "left",
      "scale": "scales_yScale",
      "domain": false,
      "ticks": false,
      "offset": -20,
      "zindex": 1,
      "labelBaseline": "bottom",
      "labelAlign": "center",
      "encode": {
        "labels": {
          "enter": {
            "fontSize": {
              "value": 12
            },
            "fontWeight": {
              "value": "bold"
            },
            "fill": {
              "value": "#fffff"
            }
          }
        }
      }
    }
  ],
  "marks": [
    {
      "name": "marks_rect",
      "type": "rect",
      "from": {
        "data": "data_table"
      },
      "encode": {
        "enter": {
          "fillOpacity": {
            "value": 1
          }
        },
        "update": {
          "y": {
            "scale": "scales_yScale",
            "field": "<%= data_mapper.column_1 %>"
          },
          "height": {
            "scale": "scales_yScale",
            "band": 0.5,
            "round": true
          },
          "x": {
            "scale": "scales_xScale",
            "field": "y0"
          },
          "x2": {
            "scale": "scales_xScale",
            "signal": "datum.y1 + 15"
          },
          "cornerRadius": {
            "signal": "width/100 + 5"
          },
          "fill": {
            "scale": "scales_color",
            "field": "<%= data_mapper.column_4 %>"
          }
        }
      }
    }
  ],
  "legends": [
    {
      "orient": "none",
      "encode": {
        "labels": {
          "enter": {
            "fill": {
              "value": "#000000"
            },
            "fontWeight": {
              "value": "bold"
            }
          },
          "update": {
            "fontSize": {
              "signal": "width/100 * 2"
            }
          }
        },
        "legend": {
          "update": {
            "x": {
              "signal": "width/3"
            },
            "y": {
              "signal": "height - 10"
            }
          }
        }
      },
      "direction": "horizontal",
      "fill": "scales_color",
      "rowPadding": 20,
      "symbolType": "circle"
    }
  ]
}
