User:MusikAnimal (WMF)/NPPChart/Core-line

{ "version": 2, "width": 800, "height": , "padding": "strict", "signals": [ {     "name": "indexDate", "init": {"expr": "time('')"}, "streams": [{ "type": "mousemove", "expr": "clamp(eventX, 0, eventGroup('root').width)", "scale": {"name": "x", "invert": false} }]   },    {      "name": "indexValues", "init": {"expr": "0"}, "streams": [{ "type": "mousemove", "expr": "eventX", "scale": {"name": "y", "invert": true} }]   },    {"name": "maxDate", "init": {"expr": "time('')"}} ],

"data": [ {     "name": "stocks", "url": "wikiraw:///User:MusikAnimal (WMF)/NPPChart/Sources/-line", "format": {"type": "csv", "parse": {"value":"number", "date":"date"}} },   {      "name": "index", "source": "stocks" },   {      "name": "indexified_stocks", "source": "stocks", "transform": [{ "type": "lookup", "on": "index", "onKey": "type", "keys": ["type"], "as": ["index_term"], "default": {"value": 0} }, {       "type": "formula", "field": "indexed_value", "expr": "datum.index_term.value > 0 ? (datum.value - datum.index_term.value)/datum.index_term.value : 0" }]   }  ],

"scales": [ {     "name": "x", "type": "time", "domain": {"data": "stocks", "field": "date"}, "range": "width" },   {      "name": "y", "type": "linear", "domain": {"data": "stocks", "field": "value"}, "range": "height", "nice": true, "zero": true },   {      "name": "color", "type": "ordinal", "domain": {"data": "stocks", "field": "type"}, "range": "category10" } ],  "axes": [ {     "type": "y", "scale": "y", "grid": true, "layer": "back" },   {      "type": "x", "scale": "x", "format": "%b %d", "tickPadding": 3, "ticks": 10 },   {      "type": "x", "scale": "x", "title": "", "orient": "top", "values": [], "properties": { "title": { "fill": { "value": "black" },         "fontSize": { "value": 14 }       },        "axis": { "strokeOpacity": { "value": 0 }       }      }    }  ],  "marks": [ {     "type": "group", "from": { "data": "indexified_stocks", "transform": [{"type": "facet", "groupby": ["type"]}] },     "marks": [ {         "type": "line", "properties": { "update": { "x": {"scale": "x", "field": "date"}, "y": {"scale": "y", "field": "value"}, "stroke": {"scale": "color", "field": "type"}, "strokeWidth": {"value": 2} }         }        }      ]    },    {      "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": "gray"} }     }    }  ] }