diff --git a/examples/compiled/area_cumulative_freq.png b/examples/compiled/area_cumulative_freq.png index 5a7ce39ce0..2fedc7f17b 100644 Binary files a/examples/compiled/area_cumulative_freq.png and b/examples/compiled/area_cumulative_freq.png differ diff --git a/examples/compiled/area_cumulative_freq.svg b/examples/compiled/area_cumulative_freq.svg index 7c3c368d38..b9313e8a83 100644 --- a/examples/compiled/area_cumulative_freq.svg +++ b/examples/compiled/area_cumulative_freq.svg @@ -1 +1 @@ -246810IMDB Rating05001,0001,5002,0002,5003,0003,500Cumulative Count \ No newline at end of file +246810IMDB Rating05001,0001,5002,0002,5003,0003,500Max of Cumulative Count \ No newline at end of file diff --git a/examples/compiled/area_cumulative_freq.vg.json b/examples/compiled/area_cumulative_freq.vg.json index db79cf7e92..6d8987bd37 100644 --- a/examples/compiled/area_cumulative_freq.vg.json +++ b/examples/compiled/area_cumulative_freq.vg.json @@ -19,6 +19,13 @@ "fields": ["count"], "sort": {"field": ["IMDB Rating"], "order": ["ascending"]}, "frame": [null, 0] + }, + { + "type": "aggregate", + "groupby": ["IMDB Rating"], + "ops": ["max"], + "fields": ["Cumulative Count"], + "as": ["max_Cumulative Count"] } ] } @@ -35,13 +42,13 @@ "orient": {"value": "vertical"}, "fill": {"value": "#4c78a8"}, "description": { - "signal": "\"IMDB Rating: \" + (format(datum[\"IMDB Rating\"], \"\")) + \"; Cumulative Count: \" + (format(datum[\"Cumulative Count\"], \"\"))" + "signal": "\"IMDB Rating: \" + (format(datum[\"IMDB Rating\"], \"\")) + \"; Max of Cumulative Count: \" + (format(datum[\"max_Cumulative Count\"], \"\"))" }, "x": {"scale": "x", "field": "IMDB Rating"}, - "y": {"scale": "y", "field": "Cumulative Count"}, + "y": {"scale": "y", "field": "max_Cumulative Count"}, "y2": {"scale": "y", "value": 0}, "defined": { - "signal": "isValid(datum[\"IMDB Rating\"]) && isFinite(+datum[\"IMDB Rating\"]) && isValid(datum[\"Cumulative Count\"]) && isFinite(+datum[\"Cumulative Count\"])" + "signal": "isValid(datum[\"IMDB Rating\"]) && isFinite(+datum[\"IMDB Rating\"]) && isValid(datum[\"max_Cumulative Count\"]) && isFinite(+datum[\"max_Cumulative Count\"])" } } } @@ -59,7 +66,7 @@ { "name": "y", "type": "linear", - "domain": {"data": "source_0", "field": "Cumulative Count"}, + "domain": {"data": "source_0", "field": "max_Cumulative Count"}, "range": [{"signal": "height"}, 0], "nice": true, "zero": true @@ -108,7 +115,7 @@ "scale": "y", "orient": "left", "grid": false, - "title": "Cumulative Count", + "title": "Max of Cumulative Count", "labelOverlap": true, "tickCount": {"signal": "ceil(height/40)"}, "zindex": 0 diff --git a/examples/compiled/area_density.vg.json b/examples/compiled/area_density.vg.json index 9a2296166c..8fc8c8ca43 100644 --- a/examples/compiled/area_density.vg.json +++ b/examples/compiled/area_density.vg.json @@ -16,6 +16,22 @@ "field": "IMDB Rating", "bandwidth": 0.3, "as": ["value", "density"] + }, + { + "type": "impute", + "field": "density", + "groupby": [], + "key": "value", + "method": "value", + "value": 0 + }, + { + "type": "stack", + "groupby": ["value"], + "field": "density", + "sort": {"field": [], "order": []}, + "as": ["density_start", "density_end"], + "offset": "zero" } ] } @@ -35,8 +51,8 @@ "signal": "\"IMDB Rating: \" + (format(datum[\"value\"], \"\")) + \"; density: \" + (format(datum[\"density\"], \"\"))" }, "x": {"scale": "x", "field": "value"}, - "y": {"scale": "y", "field": "density"}, - "y2": {"scale": "y", "value": 0}, + "y": {"scale": "y", "field": "density_end"}, + "y2": {"scale": "y", "field": "density_start"}, "defined": { "signal": "isValid(datum[\"value\"]) && isFinite(+datum[\"value\"]) && isValid(datum[\"density\"]) && isFinite(+datum[\"density\"])" } @@ -56,7 +72,10 @@ { "name": "y", "type": "linear", - "domain": {"data": "source_0", "field": "density"}, + "domain": { + "data": "source_0", + "fields": ["density_start", "density_end"] + }, "range": [{"signal": "height"}, 0], "nice": true, "zero": true diff --git a/examples/compiled/area_horizon.vg.json b/examples/compiled/area_horizon.vg.json index f57b3a2db2..f879dd7e2e 100644 --- a/examples/compiled/area_horizon.vg.json +++ b/examples/compiled/area_horizon.vg.json @@ -42,7 +42,47 @@ { "name": "data_1", "source": "data_0", - "transform": [{"type": "formula", "expr": "datum.y - 50", "as": "ny"}] + "transform": [ + { + "type": "impute", + "field": "y", + "groupby": [], + "key": "x", + "method": "value", + "value": 0 + }, + { + "type": "stack", + "groupby": ["x"], + "field": "y", + "sort": {"field": [], "order": []}, + "as": ["y_start", "y_end"], + "offset": "zero" + } + ] + }, + { + "name": "data_2", + "source": "data_0", + "transform": [ + {"type": "formula", "expr": "datum.y - 50", "as": "ny"}, + { + "type": "impute", + "field": "ny", + "groupby": [], + "key": "x", + "method": "value", + "value": 0 + }, + { + "type": "stack", + "groupby": ["x"], + "field": "ny", + "sort": {"field": [], "order": []}, + "as": ["ny_start", "ny_end"], + "offset": "zero" + } + ] } ], "marks": [ @@ -52,7 +92,7 @@ "clip": true, "style": ["area"], "sort": {"field": "datum[\"x\"]"}, - "from": {"data": "data_0"}, + "from": {"data": "data_1"}, "encode": { "update": { "opacity": {"value": 0.6}, @@ -62,8 +102,8 @@ "signal": "\"x: \" + (format(datum[\"x\"], \"\")) + \"; y: \" + (format(datum[\"y\"], \"\"))" }, "x": {"scale": "x", "field": "x"}, - "y": {"scale": "y", "field": "y"}, - "y2": {"scale": "y", "value": 0}, + "y": {"scale": "y", "field": "y_end"}, + "y2": {"scale": "y", "field": "y_start"}, "defined": { "signal": "isValid(datum[\"x\"]) && isFinite(+datum[\"x\"]) && isValid(datum[\"y\"]) && isFinite(+datum[\"y\"])" } @@ -76,7 +116,7 @@ "clip": true, "style": ["area"], "sort": {"field": "datum[\"x\"]"}, - "from": {"data": "data_1"}, + "from": {"data": "data_2"}, "encode": { "update": { "orient": {"value": "vertical"}, @@ -86,8 +126,8 @@ "signal": "\"x: \" + (format(datum[\"x\"], \"\")) + \"; ny: \" + (format(datum[\"ny\"], \"\"))" }, "x": {"scale": "x", "field": "x"}, - "y": {"scale": "y", "field": "ny"}, - "y2": {"scale": "y", "value": 0}, + "y": {"scale": "y", "field": "ny_end"}, + "y2": {"scale": "y", "field": "ny_start"}, "defined": { "signal": "isValid(datum[\"x\"]) && isFinite(+datum[\"x\"]) && isValid(datum[\"ny\"]) && isFinite(+datum[\"ny\"])" } @@ -101,8 +141,8 @@ "type": "linear", "domain": { "fields": [ - {"data": "data_0", "field": "x"}, - {"data": "data_1", "field": "x"} + {"data": "data_1", "field": "x"}, + {"data": "data_2", "field": "x"} ] }, "range": [0, {"signal": "width"}], diff --git a/examples/compiled/area_params.vg.json b/examples/compiled/area_params.vg.json index a8e1e758d6..5ce094d0a3 100644 --- a/examples/compiled/area_params.vg.json +++ b/examples/compiled/area_params.vg.json @@ -21,7 +21,23 @@ "name": "data_0", "source": "source_0", "transform": [ - {"type": "formula", "expr": "toNumber(datum[\"u\"])", "as": "u"} + {"type": "formula", "expr": "toNumber(datum[\"u\"])", "as": "u"}, + { + "type": "impute", + "field": "v", + "groupby": [], + "key": "u", + "method": "value", + "value": 0 + }, + { + "type": "stack", + "groupby": ["u"], + "field": "v", + "sort": {"field": [], "order": []}, + "as": ["v_start", "v_end"], + "offset": "zero" + } ] } ], @@ -67,8 +83,8 @@ "signal": "\"u: \" + (format(datum[\"u\"], \"\")) + \"; v: \" + (format(datum[\"v\"], \"\"))" }, "x": {"scale": "x", "field": "u"}, - "y": {"scale": "y", "field": "v"}, - "y2": {"scale": "y", "value": 0}, + "y": {"scale": "y", "field": "v_end"}, + "y2": {"scale": "y", "field": "v_start"}, "defined": { "signal": "isValid(datum[\"u\"]) && isFinite(+datum[\"u\"]) && isValid(datum[\"v\"]) && isFinite(+datum[\"v\"])" } @@ -88,7 +104,7 @@ { "name": "y", "type": "linear", - "domain": {"data": "data_0", "field": "v"}, + "domain": {"data": "data_0", "fields": ["v_start", "v_end"]}, "range": [{"signal": "height"}, 0], "nice": true, "zero": true diff --git a/examples/compiled/stacked_area_without_agg.png b/examples/compiled/stacked_area_without_agg.png index 4f28483b46..bba64b1771 100644 Binary files a/examples/compiled/stacked_area_without_agg.png and b/examples/compiled/stacked_area_without_agg.png differ diff --git a/examples/compiled/stacked_area_without_agg.svg b/examples/compiled/stacked_area_without_agg.svg index b9068665a3..dc749973b7 100644 --- a/examples/compiled/stacked_area_without_agg.svg +++ b/examples/compiled/stacked_area_without_agg.svg @@ -1 +1 @@ -1.01.52.02.53.0a0.00.51.01.52.02.53.0bc1c2c \ No newline at end of file +1.01.52.02.53.0a012345bc1c2c \ No newline at end of file diff --git a/examples/compiled/stacked_area_without_agg.vg.json b/examples/compiled/stacked_area_without_agg.vg.json index ae19847da6..ff5280d46a 100644 --- a/examples/compiled/stacked_area_without_agg.vg.json +++ b/examples/compiled/stacked_area_without_agg.vg.json @@ -21,7 +21,23 @@ "name": "data_0", "source": "source_0", "transform": [ - {"type": "formula", "expr": "toNumber(datum[\"a\"])", "as": "a"} + {"type": "formula", "expr": "toNumber(datum[\"a\"])", "as": "a"}, + { + "type": "impute", + "field": "b", + "groupby": ["c"], + "key": "a", + "method": "value", + "value": 0 + }, + { + "type": "stack", + "groupby": ["a"], + "field": "b", + "sort": {"field": ["c"], "order": ["descending"]}, + "as": ["b_start", "b_end"], + "offset": "zero" + } ] } ], @@ -57,8 +73,8 @@ "signal": "\"a: \" + (format(datum[\"a\"], \"\")) + \"; b: \" + (format(datum[\"b\"], \"\")) + \"; c: \" + (isValid(datum[\"c\"]) ? datum[\"c\"] : \"\"+datum[\"c\"])" }, "x": {"scale": "x", "field": "a"}, - "y": {"scale": "y", "field": "b"}, - "y2": {"scale": "y", "value": 0}, + "y": {"scale": "y", "field": "b_end"}, + "y2": {"scale": "y", "field": "b_start"}, "defined": { "signal": "isValid(datum[\"a\"]) && isFinite(+datum[\"a\"]) && isValid(datum[\"b\"]) && isFinite(+datum[\"b\"])" } @@ -80,7 +96,7 @@ { "name": "y", "type": "linear", - "domain": {"data": "data_0", "field": "b"}, + "domain": {"data": "data_0", "fields": ["b_start", "b_end"]}, "range": [{"signal": "height"}, 0], "nice": true, "zero": true diff --git a/examples/compiled/wheat_wages.vg.json b/examples/compiled/wheat_wages.vg.json index d59661f085..5a60792a74 100644 --- a/examples/compiled/wheat_wages.vg.json +++ b/examples/compiled/wheat_wages.vg.json @@ -30,7 +30,7 @@ ] }, { - "name": "data_0", + "name": "data_1", "source": "source_0", "transform": [ { @@ -48,7 +48,29 @@ ] }, { - "name": "data_1", + "name": "data_2", + "source": "source_0", + "transform": [ + { + "type": "impute", + "field": "wages", + "groupby": [], + "key": "year", + "method": "value", + "value": 0 + }, + { + "type": "stack", + "groupby": ["year"], + "field": "wages", + "sort": {"field": [], "order": []}, + "as": ["wages_start", "wages_end"], + "offset": "zero" + } + ] + }, + { + "name": "data_3", "source": "source_1", "transform": [ { @@ -58,7 +80,7 @@ ] }, { - "name": "data_2", + "name": "data_4", "source": "source_2", "transform": [ { @@ -74,7 +96,7 @@ ] }, { - "name": "data_3", + "name": "data_5", "source": "source_2", "transform": [ { @@ -99,7 +121,7 @@ "name": "layer_0_marks", "type": "rect", "style": ["bar"], - "from": {"data": "data_0"}, + "from": {"data": "data_1"}, "encode": { "update": { "fill": {"value": "#aaa"}, @@ -131,7 +153,7 @@ "name": "layer_1_marks", "type": "rule", "style": ["rule"], - "from": {"data": "data_1"}, + "from": {"data": "data_3"}, "encode": { "update": { "opacity": {"value": 0.5}, @@ -151,7 +173,7 @@ "type": "area", "style": ["area"], "sort": {"field": "datum[\"year\"]"}, - "from": {"data": "source_0"}, + "from": {"data": "data_2"}, "encode": { "update": { "opacity": {"value": 0.7}, @@ -161,8 +183,8 @@ "signal": "\"year: \" + (format(datum[\"year\"], \"d\")) + \"; wages: \" + (format(datum[\"wages\"], \"\"))" }, "x": {"scale": "x", "field": "year"}, - "y": {"scale": "y", "field": "wages"}, - "y2": {"scale": "y", "value": 0}, + "y": {"scale": "y", "field": "wages_end"}, + "y2": {"scale": "y", "field": "wages_start"}, "defined": { "signal": "isValid(datum[\"year\"]) && isFinite(+datum[\"year\"]) && isValid(datum[\"wages\"]) && isFinite(+datum[\"wages\"])" } @@ -214,7 +236,7 @@ "name": "layer_5_marks", "type": "rect", "style": ["rect"], - "from": {"data": "data_2"}, + "from": {"data": "data_4"}, "encode": { "update": { "stroke": {"value": "#000"}, @@ -233,7 +255,7 @@ "name": "layer_6_marks", "type": "text", "style": ["text"], - "from": {"data": "data_3"}, + "from": {"data": "data_5"}, "encode": { "update": { "baseline": {"value": "bottom"}, @@ -259,13 +281,14 @@ "type": "linear", "domain": { "fields": [ - {"data": "data_0", "field": "year"}, - {"data": "data_0", "field": "year_end"}, {"data": "data_1", "field": "year"}, + {"data": "data_1", "field": "year_end"}, + {"data": "data_3", "field": "year"}, + {"data": "data_2", "field": "year"}, {"data": "source_0", "field": "year"}, - {"data": "data_2", "field": "start"}, - {"data": "data_2", "field": "end"}, - {"data": "data_3", "field": "x"} + {"data": "data_4", "field": "start"}, + {"data": "data_4", "field": "end"}, + {"data": "data_5", "field": "x"} ] }, "range": [0, {"signal": "width"}], @@ -277,12 +300,14 @@ "type": "linear", "domain": { "fields": [ - {"data": "data_0", "field": "wheat_start"}, - {"data": "data_0", "field": "wheat_end"}, + {"data": "data_1", "field": "wheat_start"}, + {"data": "data_1", "field": "wheat_end"}, + {"data": "data_2", "field": "wages_start"}, + {"data": "data_2", "field": "wages_end"}, {"data": "source_0", "field": "wages"}, - {"data": "data_2", "field": "y"}, - {"data": "data_2", "field": "offset"}, - {"data": "data_3", "field": "off2"} + {"data": "data_4", "field": "y"}, + {"data": "data_4", "field": "offset"}, + {"data": "data_5", "field": "off2"} ] }, "range": [{"signal": "height"}, 0], @@ -292,7 +317,7 @@ { "name": "fill", "type": "ordinal", - "domain": {"data": "data_2", "field": "commonwealth", "sort": true}, + "domain": {"data": "data_4", "field": "commonwealth", "sort": true}, "range": ["black", "white"] } ],