{
  "$schema": "https://vega.github.io/schema/vega/v6.json",
  "width": 400,
  "height": 200,
  "padding": 5,

  "signals": [
    {
      "name": "defined", "value": true,
      "bind": {"input": "checkbox"}
    },
    {
      "name": "interpolate", "value": "linear",
      "bind": {
        "input": "select",
        "options": [
          "basis",
          "cardinal",
          "catmull-rom",
          "linear",
          "monotone",
          "natural",
          "step",
          "step-after",
          "step-before"
        ]
      }
    },
    {
      "name": "tension", "value": 0,
      "bind": {"input": "range", "min": 0, "max": 1, "step": 0.05}
    },
    {
      "name": "y2", "value": 0,
      "bind": {"input": "range", "min": 0, "max": 20, "step": 1}
    },
    { "name": "strokeWidth", "value": 4,
      "bind": {"input": "range", "min": 0, "max": 10, "step": 0.5} },
    { "name": "color", "value": "both",
      "bind": {"input": "radio", "options": ["fill", "stroke", "both"]} }
  ],

  "data": [
    {
      "name": "table",
      "values": [
        {"u": 1, "v": 28}, {"u": 2, "v": 55},
        {"u": 3, "v": 42}, {"u": 4, "v": 34},
        {"u": 5, "v": 36}, {"u": 6, "v": 48}
      ]
    }
  ],

  "scales": [
    {
      "name": "xscale",
      "type": "linear",
      "range": "width",
      "zero": false,
      "domain": {"data": "table", "field": "u"}
    },
    {
      "name": "yscale",
      "type": "linear",
      "range": "height",
      "nice": true,
      "zero": true,
      "domain": {"data": "table", "field": "v"}
    }
  ],

  "marks": [
    {
      "type": "area",
      "from": {"data": "table"},
      "encode": {
        "enter": {
          "fill": {"value": "#939597"},
          "stroke": {"value": "#652c90"}
        },
        "update": {
          "x": {"scale": "xscale", "field": "u"},
          "y": {"scale": "yscale", "field": "v"},
          "y2": {"scale": "yscale", "signal": "y2"},
          "defined": {"signal": "defined || datum.u !== 3"},
          "interpolate": {"signal": "interpolate"},
          "tension": {"signal": "tension"},
          "opacity": {"value": 1},
          "fillOpacity": {"signal": "color === 'fill' || color === 'both' ? 1 : 0"},
          "strokeOpacity": {"signal": "color === 'stroke' || color === 'both' ? 1 : 0"},
          "strokeWidth": {"signal": "strokeWidth"}
        },
        "hover": {
          "opacity": {"value": 0.5}
        }
      }
    }
  ]
}
