From 94609991f3ac2cde3eaa194ed910163b4309e683 Mon Sep 17 00:00:00 2001 From: Robin Linacre Date: Wed, 8 Dec 2021 15:09:46 +0000 Subject: [PATCH 1/5] fix: preserve node order in swapwithparents --- src/compile/data/dataflow.ts | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/compile/data/dataflow.ts b/src/compile/data/dataflow.ts index e0c25410ee..f00b8c4f3e 100644 --- a/src/compile/data/dataflow.ts +++ b/src/compile/data/dataflow.ts @@ -116,11 +116,14 @@ export abstract class DataFlowNode { // remove old links this._children = []; // equivalent to removing every child link one by one parent.removeChild(this); - parent.parent.removeChild(parent); + const loc = parent.parent.removeChild(parent); // swap two nodes - this.parent = newParent; - parent.parent = this; + this._parent = newParent; + newParent.addChild(this, loc); + + parent._parent = this + this.addChild(parent, loc); } } From 0933eeb2b62419115667563b7533624e0839f4a1 Mon Sep 17 00:00:00 2001 From: GitHub Actions Bot Date: Wed, 8 Dec 2021 15:15:45 +0000 Subject: [PATCH 2/5] chore: update examples [CI] --- examples/compiled/facet_bullet.vg.json | 22 ++++++------ ...teractive_multi_line_pivot_tooltip.vg.json | 30 ++++++++-------- .../interactive_seattle_weather.vg.json | 36 +++++++++---------- 3 files changed, 44 insertions(+), 44 deletions(-) diff --git a/examples/compiled/facet_bullet.vg.json b/examples/compiled/facet_bullet.vg.json index 1080a96e24..1e49e16ae8 100644 --- a/examples/compiled/facet_bullet.vg.json +++ b/examples/compiled/facet_bullet.vg.json @@ -80,7 +80,12 @@ ] }, { - "name": "data_1", + "name": "row_domain", + "source": "data_0", + "transform": [{"type": "aggregate", "groupby": ["title"]}] + }, + { + "name": "data_2", "source": "data_0", "transform": [ { @@ -98,7 +103,7 @@ ] }, { - "name": "data_2", + "name": "data_3", "source": "data_0", "transform": [ { @@ -116,7 +121,7 @@ ] }, { - "name": "data_3", + "name": "data_4", "source": "data_0", "transform": [ { @@ -134,7 +139,7 @@ ] }, { - "name": "data_4", + "name": "data_5", "source": "data_0", "transform": [ { @@ -152,7 +157,7 @@ ] }, { - "name": "data_5", + "name": "data_6", "source": "data_0", "transform": [ { @@ -170,7 +175,7 @@ ] }, { - "name": "data_6", + "name": "data_7", "source": "data_0", "transform": [ { @@ -178,11 +183,6 @@ "expr": "isValid(datum[\"markers.0\"]) && isFinite(+datum[\"markers.0\"])" } ] - }, - { - "name": "row_domain", - "source": "data_0", - "transform": [{"type": "aggregate", "groupby": ["title"]}] } ], "signals": [ diff --git a/examples/compiled/interactive_multi_line_pivot_tooltip.vg.json b/examples/compiled/interactive_multi_line_pivot_tooltip.vg.json index 86b2493ff9..9303d37d68 100644 --- a/examples/compiled/interactive_multi_line_pivot_tooltip.vg.json +++ b/examples/compiled/interactive_multi_line_pivot_tooltip.vg.json @@ -17,15 +17,12 @@ "source": "source_0", "transform": [ { - "type": "pivot", - "field": "symbol", - "value": "price", - "groupby": ["date"] + "type": "filter", + "expr": "length(data(\"hover_store\")) && vlSelectionTest(\"hover_store\", datum)" }, - {"type": "formula", "expr": "toDate(datum[\"date\"])", "as": "date"}, { "type": "filter", - "expr": "(isDate(datum[\"date\"]) || (isValid(datum[\"date\"]) && isFinite(+datum[\"date\"])))" + "expr": "(isDate(datum[\"date\"]) || (isValid(datum[\"date\"]) && isFinite(+datum[\"date\"]))) && isValid(datum[\"price\"]) && isFinite(+datum[\"price\"])" } ] }, @@ -34,12 +31,15 @@ "source": "source_0", "transform": [ { - "type": "filter", - "expr": "length(data(\"hover_store\")) && vlSelectionTest(\"hover_store\", datum)" + "type": "pivot", + "field": "symbol", + "value": "price", + "groupby": ["date"] }, + {"type": "formula", "expr": "toDate(datum[\"date\"])", "as": "date"}, { "type": "filter", - "expr": "(isDate(datum[\"date\"]) || (isValid(datum[\"date\"]) && isFinite(+datum[\"date\"]))) && isValid(datum[\"price\"]) && isFinite(+datum[\"price\"])" + "expr": "(isDate(datum[\"date\"]) || (isValid(datum[\"date\"]) && isFinite(+datum[\"date\"])))" } ] } @@ -147,7 +147,7 @@ "type": "symbol", "style": ["point"], "interactive": false, - "from": {"data": "data_1"}, + "from": {"data": "data_0"}, "encode": { "update": { "opacity": {"value": 0.7}, @@ -167,7 +167,7 @@ "type": "rule", "style": ["rule"], "interactive": true, - "from": {"data": "data_0"}, + "from": {"data": "data_1"}, "encode": { "update": { "stroke": {"value": "black"}, @@ -223,8 +223,8 @@ "domain": { "fields": [ {"data": "source_0", "field": "date"}, - {"data": "data_1", "field": "date"}, - {"data": "data_0", "field": "date"} + {"data": "data_0", "field": "date"}, + {"data": "data_1", "field": "date"} ] }, "range": [0, {"signal": "width"}] @@ -235,7 +235,7 @@ "domain": { "fields": [ {"data": "source_0", "field": "price"}, - {"data": "data_1", "field": "price"} + {"data": "data_0", "field": "price"} ] }, "range": [{"signal": "height"}, 0], @@ -248,7 +248,7 @@ "domain": { "fields": [ {"data": "source_0", "field": "symbol"}, - {"data": "data_1", "field": "symbol"} + {"data": "data_0", "field": "symbol"} ], "sort": true }, diff --git a/examples/compiled/interactive_seattle_weather.vg.json b/examples/compiled/interactive_seattle_weather.vg.json index dd0b575f4c..a8684b0914 100644 --- a/examples/compiled/interactive_seattle_weather.vg.json +++ b/examples/compiled/interactive_seattle_weather.vg.json @@ -16,6 +16,10 @@ "name": "data_0", "source": "source_0", "transform": [ + { + "type": "filter", + "expr": "!length(data(\"click_store\")) || vlSelectionTest(\"click_store\", datum)" + }, { "field": "date", "type": "timeunit", @@ -24,14 +28,7 @@ }, { "type": "filter", - "expr": "!length(data(\"brush_store\")) || vlSelectionTest(\"brush_store\", datum)" - }, - { - "type": "aggregate", - "groupby": ["weather"], - "ops": ["count"], - "fields": [null], - "as": ["__count"] + "expr": "(isDate(datum[\"monthdate_date\"]) || (isValid(datum[\"monthdate_date\"]) && isFinite(+datum[\"monthdate_date\"]))) && isValid(datum[\"temp_max\"]) && isFinite(+datum[\"temp_max\"]) && isValid(datum[\"precipitation\"]) && isFinite(+datum[\"precipitation\"])" } ] }, @@ -39,10 +36,6 @@ "name": "data_1", "source": "source_0", "transform": [ - { - "type": "filter", - "expr": "!length(data(\"click_store\")) || vlSelectionTest(\"click_store\", datum)" - }, { "field": "date", "type": "timeunit", @@ -51,7 +44,14 @@ }, { "type": "filter", - "expr": "(isDate(datum[\"monthdate_date\"]) || (isValid(datum[\"monthdate_date\"]) && isFinite(+datum[\"monthdate_date\"]))) && isValid(datum[\"temp_max\"]) && isFinite(+datum[\"temp_max\"]) && isValid(datum[\"precipitation\"]) && isFinite(+datum[\"precipitation\"])" + "expr": "!length(data(\"brush_store\")) || vlSelectionTest(\"brush_store\", datum)" + }, + { + "type": "aggregate", + "groupby": ["weather"], + "ops": ["count"], + "fields": [null], + "as": ["__count"] } ] } @@ -304,7 +304,7 @@ "type": "symbol", "style": ["point"], "interactive": true, - "from": {"data": "data_1"}, + "from": {"data": "data_0"}, "encode": { "update": { "opacity": {"value": 0.7}, @@ -480,7 +480,7 @@ "type": "rect", "style": ["bar"], "interactive": true, - "from": {"data": "data_0"}, + "from": {"data": "data_1"}, "encode": { "update": { "fill": [ @@ -555,7 +555,7 @@ { "name": "concat_0_x", "type": "time", - "domain": {"data": "data_1", "field": "monthdate_date"}, + "domain": {"data": "data_0", "field": "monthdate_date"}, "range": [0, {"signal": "width"}] }, { @@ -568,7 +568,7 @@ { "name": "concat_1_x", "type": "linear", - "domain": {"data": "data_0", "field": "__count"}, + "domain": {"data": "data_1", "field": "__count"}, "range": [0, {"signal": "width"}], "nice": true, "zero": true @@ -576,7 +576,7 @@ { "name": "concat_1_y", "type": "band", - "domain": {"data": "data_0", "field": "weather", "sort": true}, + "domain": {"data": "data_1", "field": "weather", "sort": true}, "range": {"step": {"signal": "concat_1_y_step"}}, "paddingInner": 0.1, "paddingOuter": 0.05 From 1da26083d57223e6f5ba5e4b373f3dd4e3eff231 Mon Sep 17 00:00:00 2001 From: GitHub Actions Bot Date: Wed, 8 Dec 2021 15:15:45 +0000 Subject: [PATCH 3/5] style: auto-formatting [CI] --- src/compile/data/dataflow.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/compile/data/dataflow.ts b/src/compile/data/dataflow.ts index f00b8c4f3e..481b420546 100644 --- a/src/compile/data/dataflow.ts +++ b/src/compile/data/dataflow.ts @@ -122,7 +122,7 @@ export abstract class DataFlowNode { this._parent = newParent; newParent.addChild(this, loc); - parent._parent = this + parent._parent = this; this.addChild(parent, loc); } } From b89c54a7aebed47ab53548ec634ccec376fa2319 Mon Sep 17 00:00:00 2001 From: Dominik Moritz Date: Thu, 9 Dec 2021 09:24:05 -0500 Subject: [PATCH 4/5] Update src/compile/data/dataflow.ts --- src/compile/data/dataflow.ts | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/compile/data/dataflow.ts b/src/compile/data/dataflow.ts index 481b420546..722ef3a9a0 100644 --- a/src/compile/data/dataflow.ts +++ b/src/compile/data/dataflow.ts @@ -122,8 +122,7 @@ export abstract class DataFlowNode { this._parent = newParent; newParent.addChild(this, loc); - parent._parent = this; - this.addChild(parent, loc); + parent.parent = this; } } From 85d30e06b42a4dd39d948fc6e2085e5964aaad6b Mon Sep 17 00:00:00 2001 From: Dominik Moritz Date: Thu, 9 Dec 2021 09:39:10 -0500 Subject: [PATCH 5/5] docs: update src/compile/data/dataflow.ts --- src/compile/data/dataflow.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/compile/data/dataflow.ts b/src/compile/data/dataflow.ts index 722ef3a9a0..c3acdb2665 100644 --- a/src/compile/data/dataflow.ts +++ b/src/compile/data/dataflow.ts @@ -118,7 +118,7 @@ export abstract class DataFlowNode { parent.removeChild(this); const loc = parent.parent.removeChild(parent); - // swap two nodes + // swap two nodes but maintain order in children this._parent = newParent; newParent.addChild(this, loc);