Diff in string vs object syntax
6 removals
Words removed | 6 |
Total words | 887 |
Words removed (%) | 0.68 |
414 lines
5 additions
Words added | 6 |
Total words | 887 |
Words added (%) | 0.68 |
413 lines
{
{
"$schema": "https://vega.github.io/schema/vega/v5.json",
"$schema": "https://vega.github.io/schema/vega/v5.json",
"autosize": {"type": "fit", "contains": "padding"},
"autosize": {"type": "fit", "contains": "padding"},
"background": "white",
"background": "white",
"padding": 5,
"padding": 5,
"style": "cell",
"style": "cell",
"data": [
"data": [
{"name": "selection_store"},
{"name": "selection_store"},
{
{
"name": "source_0",
"name": "source_0",
"url": "data/movies.json",
"url": "data/movies.json",
"format": {"type": "json", "parse": {"IMDB_Rating": "number"}},
"format": {"type": "json", "parse": {"IMDB_Rating": "number"}},
"transform": [
"transform": [
{
{
"type": "aggregate",
"type": "aggregate",
"groupby": ["IMDB_Rating"],
"groupby": ["IMDB_Rating"],
"ops": ["count"],
"ops": ["count"],
"fields": [null],
"fields": [null],
"as": ["__count"]
"as": ["__count"]
}
}
]
]
}
}
],
],
"signals": [
"signals": [
{
{
"name": "width",
"name": "width",
"init": "isFinite(containerSize()[0]) ? containerSize()[0] : 200",
"init": "isFinite(containerSize()[0]) ? containerSize()[0] : 200",
"on": [
"on": [
{
{
"update": "isFinite(containerSize()[0]) ? containerSize()[0] : 200",
"update": "isFinite(containerSize()[0]) ? containerSize()[0] : 200",
"events": "window:resize"
"events": "window:resize"
}
}
]
]
},
},
{
{
"name": "height",
"name": "height",
"init": "isFinite(containerSize()[1]) ? containerSize()[1] : 200",
"init": "isFinite(containerSize()[1]) ? containerSize()[1] : 200",
"on": [
"on": [
{
{
"update": "isFinite(containerSize()[1]) ? containerSize()[1] : 200",
"update": "isFinite(containerSize()[1]) ? containerSize()[1] : 200",
"events": "window:resize"
"events": "window:resize"
}
}
]
]
},
},
{
{
"name": "unit",
"name": "unit",
"value": {},
"value": {},
"on": [
"on": [
{"events": "mousemove", "update": "isTuple(group()) ? group() : unit"}
{"events": "mousemove", "update": "isTuple(group()) ? group() : unit"}
]
]
},
},
{
{
"name": "selection",
"name": "selection",
"update": "vlSelectionResolve(\"selection_store\", \"union\")"
"update": "vlSelectionResolve(\"selection_store\", \"union\")"
},
},
{
{
"name": "selection_x",
"name": "selection_x",
"value": [],
"value": [],
"on": [
"on": [
{
{
"events": {
"events": {
"source": "view",
"source": "scope",
"type": "mousedown",
"type": "mousedown",
"filter": [
"filter": [
"event.shiftKey",
"!event.item || event.item.mark.name !== \"selection_brush\""
"!event.item || event.item.mark.name !== \"selection_brush\""
]
]
},
},
"update": "[x(unit), x(unit)]"
"update": "[x(unit), x(unit)]"
},
},
{
{
"events": {
"events": {
"source": "view",
"source": "window",
"type": "mousemove",
"type": "mousemove",
"consume": true,
"between": [
"between": [
{
{
"source": "view",
"source": "scope",
"type": "mousedown",
"type": "mousedown",
"filter": [
"filter": [
"event.shiftKey",
"!event.item || event.item.mark.name !== \"selection_brush\""
"!event.item || event.item.mark.name !== \"selection_brush\""
]
]
},
},
{"source": "view", "type": "mouseup"}
{"source": "window", "type": "mouseup"}
]
]
},
},
"update": "[selection_x[0], clamp(x(unit), 0, width)]"
"update": "[selection_x[0], clamp(x(unit), 0, width)]"
},
},
{
{
"events": {"signal": "selection_scale_trigger"},
"events": {"signal": "selection_scale_trigger"},
"update": "[scale(\"x\", selection_IMDB_Rating[0]), scale(\"x\", selection_IMDB_Rating[1])]"
"update": "[scale(\"x\", selection_IMDB_Rating[0]), scale(\"x\", selection_IMDB_Rating[1])]"
},
},
{
{
"events": {"signal": "selection_translate_delta"},
"events": {"signal": "selection_translate_delta"},
"update": "clampRange(panLinear(selection_translate_anchor.extent_x, selection_translate_delta.x / span(selection_translate_anchor.extent_x)), 0, width)"
"update": "clampRange(panLinear(selection_translate_anchor.extent_x, selection_translate_delta.x / span(selection_translate_anchor.extent_x)), 0, width)"
},
},
{
{
"events": {"signal": "selection_zoom_delta"},
"events": {"signal": "selection_zoom_delta"},
"update": "clampRange(zoomLinear(selection_x, selection_zoom_anchor.x, selection_zoom_delta), 0, width)"
"update": "clampRange(zoomLinear(selection_x, selection_zoom_anchor.x, selection_zoom_delta), 0, width)"
},
},
{
{
"events": [{"source": "scope", "type": "dblclick"}],
"events": [{"source": "scope", "type": "dblclick"}],
"update": "[0, 0]"
"update": "[0, 0]"
}
}
]
]
},
},
{
{
"name": "selection_IMDB_Rating",
"name": "selection_IMDB_Rating",
"on": [
"on": [
{
{
"events": {"signal": "selection_x"},
"events": {"signal": "selection_x"},
"update": "selection_x[0] === selection_x[1] ? null : invert(\"x\", selection_x)"
"update": "selection_x[0] === selection_x[1] ? null : invert(\"x\", selection_x)"
}
}
]
]
},
},
{
{
"name": "selection_scale_trigger",
"name": "selection_scale_trigger",
"value": {},
"value": {},
"on": [
"on": [
{
{
"events": [{"scale": "x"}],
"events": [{"scale": "x"}],
"update": "(!isArray(selection_IMDB_Rating) || (+invert(\"x\", selection_x)[0] === +selection_IMDB_Rating[0] && +invert(\"x\", selection_x)[1] === +selection_IMDB_Rating[1])) ? selection_scale_trigger : {}"
"update": "(!isArray(selection_IMDB_Rating) || (+invert(\"x\", selection_x)[0] === +selection_IMDB_Rating[0] && +invert(\"x\", selection_x)[1] === +selection_IMDB_Rating[1])) ? selection_scale_trigger : {}"
}
}
]
]
},
},
{
{
"name": "selection_tuple",
"name": "selection_tuple",
"on": [
"on": [
{
{
"events": [{"signal": "selection_IMDB_Rating"}],
"events": [{"signal": "selection_IMDB_Rating"}],
"update": "selection_IMDB_Rating ? {unit: \"layer_0\", fields: selection_tuple_fields, values: [selection_IMDB_Rating]} : null"
"update": "selection_IMDB_Rating ? {unit: \"layer_0\", fields: selection_tuple_fields, values: [selection_IMDB_Rating]} : null"
}
}
]
]
},
},
{
{
"name": "selection_tuple_fields",
"name": "selection_tuple_fields",
"value": [{"field": "IMDB_Rating", "channel": "x", "type": "R"}]
"value": [{"field": "IMDB_Rating", "channel": "x", "type": "R"}]
},
},
{
{
"name": "selection_translate_anchor",
"name": "selection_translate_anchor",
"value": {},
"value": {},
"on": [
"on": [
{
{
"events": [
"events": [
{
{
"source": "view",
"source": "view",
"type": "mousedown",
"type": "mousedown",
"filter": ["event.shiftKey"],
"filter": ["event.shiftKey"],
"markname": "selection_brush"
"markname": "selection_brush"
}
}
],
],
"update": "{x: x(unit), y: y(unit), extent_x: slice(selection_x)}"
"update": "{x: x(unit), y: y(unit), extent_x: slice(selection_x)}"
}
}
]
]
},
},
{
{
"name": "selection_translate_delta",
"name": "selection_translate_delta",
"value": {},
"value": {},
"on": [
"on": [
{
{
"events": [
"events": [
{
{
"source": "view",
"source": "view",
"type": "mousemove",
"type": "mousemove",
"between": [
"between": [
{
{
"source": "view",
"source": "view",
"type": "mousedown",
"type": "mousedown",
"filter": ["event.shiftKey"],
"filter": ["event.shiftKey"],
"markname": "selection_brush"
"markname": "selection_brush"
},
},
{"source": "view", "type": "mouseup"}
{"source": "view", "type": "mouseup"}
]
]
}
}
],
],
"update": "{x: selection_translate_anchor.x - x(unit), y: selection_translate_anchor.y - y(unit)}"
"update": "{x: selection_translate_anchor.x - x(unit), y: selection_translate_anchor.y - y(unit)}"
}
}
]
]
},
},
{
{
"name": "selection_zoom_anchor",
"name": "selection_zoom_anchor",
"on": [
"on": [
{
{
"events": [
"events": [
{
{
"source": "scope",
"source": "scope",
"type": "wheel",
"type": "wheel",
"consume": true,
"consume": true,
"filter": ["event.shiftKey"],
"filter": ["event.shiftKey"],
"markname": "selection_brush"
"markname": "selection_brush"
}
}
],
],
"update": "{x: x(unit), y: y(unit)}"
"update": "{x: x(unit), y: y(unit)}"
}
}
]
]
},
},
{
{
"name": "selection_zoom_delta",
"name": "selection_zoom_delta",
"on": [
"on": [
{
{
"events": [
"events": [
{
{
"source": "scope",
"source": "scope",
"type": "wheel",
"type": "wheel",
"consume": true,
"consume": true,
"filter": ["event.shiftKey"],
"filter": ["event.shiftKey"],
"markname": "selection_brush"
"markname": "selection_brush"
}
}
],
],
"force": true,
"force": true,
"update": "pow(1.001, event.deltaY * pow(16, event.deltaMode))"
"update": "pow(1.001, event.deltaY * pow(16, event.deltaMode))"
}
}
]
]
},
},
{
{
"name": "selection_modify",
"name": "selection_modify",
"on": [
"on": [
{
{
"events": {"signal": "selection_tuple"},
"events": {"signal": "selection_tuple"},
"update": "modify(\"selection_store\", selection_tuple, true)"
"update": "modify(\"selection_store\", selection_tuple, true)"
}
}
]
]
}
}
],
],
"marks": [
"marks": [
{
{
"name": "selection_brush_bg",
"name": "selection_brush_bg",
"type": "rect",
"type": "rect",
"clip": true,
"clip": true,
"encode": {
"encode": {
"enter": {"fill": {"value": "#333"}, "fillOpacity": {"value": 0.125}},
"enter": {"fill": {"value": "#333"}, "fillOpacity": {"value": 0.125}},
"update": {
"update": {
"x": [
"x": [
{
{
"test": "data(\"selection_store\").length && data(\"selection_store\")[0].unit === \"layer_0\"",
"test": "data(\"selection_store\").length && data(\"selection_store\")[0].unit === \"layer_0\"",
"signal": "selection_x[0]"
"signal": "selection_x[0]"
},
},
{"value": 0}
{"value": 0}
],
],
"y": [
"y": [
{
{
"test": "data(\"selection_store\").length && data(\"selection_store\")[0].unit === \"layer_0\"",
"test": "data(\"selection_store\").length && data(\"selection_store\")[0].unit === \"layer_0\"",
"value": 0
"value": 0
},
},
{"value": 0}
{"value": 0}
],
],
"x2": [
"x2": [
{
{
"test": "data(\"selection_store\").length && data(\"selection_store\")[0].unit === \"layer_0\"",
"test": "data(\"selection_store\").length && data(\"selection_store\")[0].unit === \"layer_0\"",
"signal": "selection_x[1]"
"signal": "selection_x[1]"
},
},
{"value": 0}
{"value": 0}
],
],
"y2": [
"y2": [
{
{
"test": "data(\"selection_store\").length && data(\"selection_store\")[0].unit === \"layer_0\"",
"test": "data(\"selection_store\").length && data(\"selection_store\")[0].unit === \"layer_0\"",
"field": {"group": "height"}
"field": {"group": "height"}
},
},
{"value": 0}
{"value": 0}
]
]
}
}
}
}
},
},
{
{
"name": "layer_0_marks",
"name": "layer_0_marks",
"type": "area",
"type": "area",
"style": ["area"],
"style": ["area"],
"sort": {"field": "datum[\"IMDB_Rating\"]"},
"sort": {"field": "datum[\"IMDB_Rating\"]"},
"interactive": true,
"interactive": true,
"from": {"data": "source_0"},
"from": {"data": "source_0"},
"encode": {
"encode": {
"update": {
"update": {
"orient": {"value": "vertical"},
"orient": {"value": "vertical"},
"cursor": {"value": "pointer"},
"cursor": {"value": "pointer"},
"fill": {"value": "#4c78a8"},
"fill": {"value": "#4c78a8"},
"opacity": {"value": 0.3},
"opacity": {"value": 0.3},
"x": {"scale": "x", "field": "IMDB_Rating"},
"x": {"scale": "x", "field": "IMDB_Rating"},
"y": {"scale": "y", "field": "__count"},
"y": {"scale": "y", "field": "__count"},
"y2": {"scale": "y", "value": 0},
"y2": {"scale": "y", "value": 0},
"defined": {
"defined": {
"signal": "isValid(datum[\"IMDB_Rating\"]) && isFinite(+datum[\"IMDB_Rating\"]) && isValid(datum[\"__count\"]) && isFinite(+datum[\"__count\"])"
"signal": "isValid(datum[\"IMDB_Rating\"]) && isFinite(+datum[\"IMDB_Rating\"]) && isValid(datum[\"__count\"]) && isFinite(+datum[\"__count\"])"
}
}
}
}
}
}
},
},
{
{
"name": "layer_1_marks",
"name": "layer_1_marks",
"type": "area",
"type": "area",
"style": ["area"],
"style": ["area"],
"sort": {"field": "datum[\"IMDB_Rating\"]"},
"sort": {"field": "datum[\"IMDB_Rating\"]"},
"interactive": false,
"interactive": false,
"from": {"data": "source_0"},
"from": {"data": "source_0"},
"encode": {
"encode": {
"update": {
"update": {
"orient": {"value": "vertical"},
"orient": {"value": "vertical"},
"fill": {"value": "#4c78a8"},
"fill": {"value": "#4c78a8"},
"x": {"scale": "x", "field": "IMDB_Rating"},
"x": {"scale": "x", "field": "IMDB_Rating"},
"y": {"scale": "y", "field": "__count"},
"y": {"scale": "y", "field": "__count"},
"y2": {"scale": "y", "value": 0},
"y2": {"scale": "y", "value": 0},
"defined": {
"defined": {
"signal": "isValid(datum[\"IMDB_Rating\"]) && isFinite(+datum[\"IMDB_Rating\"]) && isValid(datum[\"__count\"]) && isFinite(+datum[\"__count\"])"
"signal": "isValid(datum[\"IMDB_Rating\"]) && isFinite(+datum[\"IMDB_Rating\"]) && isValid(datum[\"__count\"]) && isFinite(+datum[\"__count\"])"
}
}
}
}
}
}
},
},
{
{
"name": "selection_brush",
"name": "selection_brush",
"type": "rect",
"type": "rect",
"clip": true,
"clip": true,
"encode": {
"encode": {
"enter": {"fill": {"value": "transparent"}},
"enter": {"fill": {"value": "transparent"}},
"update": {
"update": {
"x": [
"x": [
{
{
"test": "data(\"selection_store\").length && data(\"selection_store\")[0].unit === \"layer_0\"",
"test": "data(\"selection_store\").length && data(\"selection_store\")[0].unit === \"layer_0\"",
"signal": "selection_x[0]"
"signal": "selection_x[0]"
},
},
{"value": 0}
{"value": 0}
],
],
"y": [
"y": [
{
{
"test": "data(\"selection_store\").length && data(\"selection_store\")[0].unit === \"layer_0\"",
"test": "data(\"selection_store\").length && data(\"selection_store\")[0].unit === \"layer_0\"",
"value": 0
"value": 0
},
},
{"value": 0}
{"value": 0}
],
],
"x2": [
"x2": [
{
{
"test": "data(\"selection_store\").length && data(\"selection_store\")[0].unit === \"layer_0\"",
"test": "data(\"selection_store\").length && data(\"selection_store\")[0].unit === \"layer_0\"",
"signal": "selection_x[1]"
"signal": "selection_x[1]"
},
},
{"value": 0}
{"value": 0}
],
],
"y2": [
"y2": [
{
{
"test": "data(\"selection_store\").length && data(\"selection_store\")[0].unit === \"layer_0\"",
"test": "data(\"selection_store\").length && data(\"selection_store\")[0].unit === \"layer_0\"",
"field": {"group": "height"}
"field": {"group": "height"}
},
},
{"value": 0}
{"value": 0}
],
],
"stroke": [
"stroke": [
{"test": "selection_x[0] !== selection_x[1]", "value": "white"},
{"test": "selection_x[0] !== selection_x[1]", "value": "white"},
{"value": null}
{"value": null}
]
]
}
}
}
}
}
}
],
],
"scales": [
"scales": [
{
{
"name": "x",
"name": "x",
"type": "linear",
"type": "linear",
"domain": {"data": "source_0", "field": "IMDB_Rating"},
"domain": {"data": "source_0", "field": "IMDB_Rating"},
"range": [0, {"signal": "width"}],
"range": [0, {"signal": "width"}],
"nice": true,
"nice": true,
"zero": false
"zero": false
},
},
{
{
"name": "y",
"name": "y",
"type": "linear",
"type": "linear",
"domain": {"data": "source_0", "field": "__count"},
"domain": {"data": "source_0", "field": "__count"},
"range": [{"signal": "height"}, 0],
"range": [{"signal": "height"}, 0],
"nice": true,
"nice": true,
"zero": true
"zero": true
}
}
],
],
"axes": [
"axes": [
{
{
"scale": "x",
"scale": "x",
"orient": "bottom",
"orient": "bottom",
"gridScale": "y",
"gridScale": "y",
"grid": true,
"grid": true,
"tickCount": {"signal": "ceil(width/40)"},
"tickCount": {"signal": "ceil(width/40)"},
"domain": false,
"domain": false,
"labels": false,
"labels": false,
"maxExtent": 0,
"maxExtent": 0,
"minExtent": 0,
"minExtent": 0,
"ticks": false,
"ticks": false,
"zindex": 0
"zindex": 0
},
},
{
{
"scale": "y",
"scale": "y",
"orient": "left",
"orient": "left",
"gridScale": "x",
"gridScale": "x",
"grid": true,
"grid": true,
"tickCount": {"signal": "ceil(height/40)"},
"tickCount": {"signal": "ceil(height/40)"},
"domain": false,
"domain": false,
"labels": false,
"labels": false,
"maxExtent": 0,
"maxExtent": 0,
"minExtent": 0,
"minExtent": 0,
"ticks": false,
"ticks": false,
"zindex": 0
"zindex": 0
},
},
{
{
"scale": "x",
"scale": "x",
"orient": "bottom",
"orient": "bottom",
"grid": false,
"grid": false,
"title": "IMDB_Rating",
"title": "IMDB_Rating",
"labelFlush": true,
"labelFlush": true,
"labelOverlap": true,
"labelOverlap": true,
"tickCount": {"signal": "ceil(width/40)"},
"tickCount": {"signal": "ceil(width/40)"},
"zindex": 0
"zindex": 0
},
},
{
{
"scale": "y",
"scale": "y",
"orient": "left",
"orient": "left",
"grid": false,
"grid": false,
"title": "Count",
"title": "Count",
"labelOverlap": true,
"labelOverlap": true,
"tickCount": {"signal": "ceil(height/40)"},
"tickCount": {"signal": "ceil(height/40)"},
"zindex": 0
"zindex": 0
}
}
]
]
}
}