Template:Opinion polling of political parties in Dívasa

 { "version": 2, "padding": "strict", "signals": [ {     "name": "indexDate", "init": {"expr": "time('Jun 1 487')"}, "streams": [{ "type": "mousemove", "expr": "clamp(eventX, 0, eventGroup('root').width)", "scale": {"name": "x", "invert": true} }]   },    {"name": "maxDate", "init": {"expr": "time('Aug 9 487')"}} ],

"data": [ {     "name": "multiparty", "url": "wikiraw:///Template:Opinion polling of political parties in Dívasa/data", "format": {"type": "csv", "parse": {"support":"percentage", "date":"date"}} },   {      "name": "index", "source": "multiparty", "transform": [{ "type": "filter", "test": "month(datum.date) == month(indexDate) && year(datum.date) == year(indexDate)" }]   },    {      "name": "indexified_multiparty", "source": "multiparty", "transform": [{ "type": "lookup", "on": "index", "onKey": "symbol", "keys": ["symbol"], "as": ["index_term"], "default": {"price": 0} }, {       "type": "formula", "field": "indexed_support", "expr": "datum.index_term.price > 0 ? (datum.price - datum.index_term.price)/datum.index_term.price : 0" }]   }  ],

"scales": [ {     "name": "x", "type": "time", "domain": {"data": "name", "field": "date"}, "range": "width" },   {      "name": "y", "type": "linear", "domain": {"data": "indexified_multiparty", "field": "indexed_support"}, "range": "height", "nice": true },   {      "name": "color", "type": "ordinal", "domain": {"data": "name", "field": "symbol"}, "range": "category10" } ],  "axes": [ {"type": "y", "scale": "y", "grid": true, "layer": "back", "format": "%"} ], "marks": [ {     "type": "group", "from": { "data": "indexified_multiparty", "transform": [{"type": "facet", "groupby": ["symbol"]}] },     "marks": [ {         "type": "line", "properties": { "update": { "x": {"scale": "x", "field": "date"}, "y": {"scale": "y", "field": "indexed_price"}, "stroke": {"scale": "color", "field": "symbol"}, "strokeWidth": {"value": 2} }         }        },        {          "type": "text", "from": { "transform": [{"type": "filter", "test": "datum.date == maxDate"}] },         "properties": { "update": { "x": {"scale": "x", "field": "date", "offset": 2}, "y": {"scale": "y", "field": "indexed_price"}, "fill": {"scale": "color", "field": "symbol"}, "text": {"field": "symbol"}, "baseline": {"value": "middle"} }         }        }      ]    },    {      "type":"rule", "properties": { "update": { "x": {"field": {"group": "x"}}, "x2": {"field": {"group": "width"}}, "y": {"scale": "y", "value": 0}, "stroke": {"value": "black"}, "strokeWidth": {"value": 1} }     }    },    {      "type":"rule", "properties": { "update": { "x": {"scale": "x", "signal": "indexDate"}, "y": {"value": 0}, "y2": {"field": {"group": "height"}}, "stroke": {"value": "red"} }     }    },    {      "type":"text", "properties": { "update": { "x": {"scale": "x", "signal": "indexDate"}, "y2": {"field": {"group": "height"}, "offset": 15}, "align": {"value": "center"}, "text": {"template": "\u007B{indexDate | time: '%b %Y'}}"}, "fill": {"value": "red"} }     }    }  ] }