{
    "$schema": "https://vega.github.io/schema/vega/v4.json",
    "width": 600,
    "height": 360,
  
    "data" : [
        {
        "name": "table",
        "url" : "<%= dataset_url %>"
        }
      ],
      "signals": [
      { "name": "bandPadding", "value": 0.3 }
    ],
    "scales": [
      {
        "name": "xscale",
        "type": "linear",
        "round": true,
        "range": "width",
        "domain": [0,500]
      },
      {
        "name": "yscale",
        "type": "band",
        "range": "height",
        "zindex": 1,
        "domain": {"data": "table", "field": "<%= data_mapper.column_2 %>"},
        "padding": {"signal": "bandPadding"}
      }
    ],
    "axes": [
      {"orient": "left", "scale": "yscale"}
    ],
    "marks" :[
      {
        "type": "rect",
        "from": {"data": "table"},
        "encode": {
          "update": {
            "x": {"scale": "xscale", "field": "<%= data_mapper.column_3 %>"},
            "x2": {"scale": "xscale", "field": "<%= data_mapper.column_4 %>"},
            "y": {"scale": "yscale", "field": "<%= data_mapper.column_2 %>"},
            "height": {"scale": "yscale", "band": 1},
            "fill": {"signal":"datum['<%= data_mapper.column_1 %>']=='y'?'#FEC44F': datum['<%= data_mapper.column_3 %>'] < datum['<%= data_mapper.column_4 %>'] ? '#259B24':'#FF0000'"}
          }
        }
      },
      {
        "type": "rect",
        "from": {"data": "table"},
        "encode": {
          "enter": {
            "fill": {"value": "#cccccc"},
            "stroke": {"value": "#000000"},
            "strokeWidth": {"value": 0.5},
            "strokeDash":{"value" : [1,2]},
            "height": {"value": 100}
          },
          "update": {
            "opacity":{"signal":"indexof(data('table'),datum)==length(data('table'))-1?'0':'1'"},
            "y": {"scale": "yscale", "field": "<%= data_mapper.column_2 %>"},
            "x2": {"scale": "xscale", "field": "<%= data_mapper.column_4 %>"}
          }
        }
      },
      {
        "type": "text",
        "from": {"data": "table"},
        "encode": {
          "enter": {
            "fill": {"value": "#000000"},
            "dy": {"value": 25},
            "dx": {"value": 10}
          },
          "update": {
            "text" : {"signal": "datum['<%= data_mapper.column_4 %>'] - datum['<%= data_mapper.column_3 %>']"},
            "y": {"scale": "yscale", "field": "<%= data_mapper.column_2 %>"},
            "x2": {"scale": "xscale", "signal": "datum['<%= data_mapper.column_3 %>'] > datum['<%= data_mapper.column_4 %>'] ? datum['<%= data_mapper.column_3 %>'] :datum['<%= data_mapper.column_4 %>']"}
          }
        }
      }
    ]
  }
  