{
  "$schema": "https://vega.github.io/schema/vega/v4.json",
  "width": 540,
  "height": 300,
  "padding": 30,
  "autosize": "fit",
  "data": [
    {
      "name": "table",
      "url": "<%= dataset_url %>"
    }
  ],
  "scales": [
    {
      "name": "xscale",
      "type": "band",
      "domain": {
        "data": "table",
        "field": "<%= data_mapper.column_1 %>"
      },
      "range": "width",
      "padding": 0.3,
      "round": true
    },
    {
      "name": "yscale",
      "domain": {
        "data": "table",
        "field": "<%= data_mapper.column_5 %>"
      },
      "nice": true,
      "range": "height"
    }
  ],
  "axes": [
    {
      "orient": "bottom",
      "scale": "xscale",
      "ticks": false,
      "labelPadding": 10
    }
  ],
  "marks": [
    {
      "type": "rect",
      "from": {
        "data": "table"
      },
      "encode": {
        "enter": {
          "x": {
            "scale": "xscale",
            "field": "<%= data_mapper.column_1 %>"
          },
          "width": {
            "scale": "xscale",
            "band": 1
          },
          "y": {
            "scale": "yscale",
            "field": "<%= data_mapper.column_5 %>"
          },
          "y2": {
            "scale": "yscale",
            "value": 0
          }
        },
        "update": {
          "fill": {
            "value": "#F5F5F5"
          }
        }
      }
    },
    {
      "type": "rect",
      "from": {
        "data": "table"
      },
      "encode": {
        "enter": {
          "x": {
            "scale": "xscale",
            "field": "<%= data_mapper.column_1 %>"
          },
          "width": {
            "scale": "xscale",
            "band": 1
          },
          "y": {
            "scale": "yscale",
            "field": "<%= data_mapper.column_3 %>"
          },
          "y2": {
            "scale": "yscale",
            "value": 0
          }
        },
        "update": {
          "fill": {
            "value": "#FEC44F"
          }
        }
      }
    },
    {
      "type": "rect",
      "from": {
        "data": "table"
      },
      "encode": {
        "enter": {
          "x": {
            "scale": "xscale",
            "field": "<%= data_mapper.column_1 %>",
            "offset": {
              "offset": {
                "signal": "bandwidth('xscale')/3"
              }
            }
          },
          "width": {
            "scale": "xscale",
            "band": 0.33
          },
          "y": {
            "scale": "yscale",
            "field": "<%= data_mapper.column_2 %>"
          },
          "y2": {
            "scale": "yscale",
            "value": 0
          }
        },
        "update": {
          "fill": [
            {
              "test": "datum['<%= data_mapper.column_3 %>'] > datum['<%= data_mapper.column_2 %>']",
              "value": "#FF0000"
            },
            {
              "value": "#259B24"
            }
          ]
        }
      }
    },
    {
      "name": "item_score",
      "type": "text",
      "from": {
        "data": "table"
      },
      "encode": {
        "enter": {
          "x": {
            "scale": "xscale",
            "field": "<%= data_mapper.column_1 %>"
          },
          "dx": {
            "signal": "bandwidth('xscale')/2"
          },
          "y": {
            "scale": "yscale",
            "field": "<%= data_mapper.column_2 %>"
          },
          "dy": {
            "value": -10
          },
          "align": {
            "value": "center"
          },
          "fill": {
            "value": "#000000"
          },
          "text": {
            "field": "<%= data_mapper.column_2 %>"
          },
          "fontSize": {
            "value": 12
          }
        }
      }
    },
    {
      "name": "line_d",
      "type": "rule",
      "from": {
        "data": "table"
      },
      "encode": {
        "enter": {
          "stroke": {
            "value": "#000"
          },
          "strokeDash": {
            "value": [
              2,
              2
            ]
          },
          "x": {
            "scale": "xscale",
            "field": "<%= data_mapper.column_1 %>"
          },
          "x2": {
            "scale": "xscale",
            "field": "<%= data_mapper.column_1 %>",
            "offset": {
              "signal": "bandwidth('xscale')"
            }
          },
          "y": {
            "scale": "yscale",
            "field": "<%= data_mapper.column_4 %>"
          }
        }
      }
    }
  ]
}