Skip to content

Commit

Permalink
fix: Area with plain quantitative fields on both axes get stacked by …
Browse files Browse the repository at this point in the history
…default (vega#9018)

Co-authored-by: GitHub Actions Bot <[email protected]>
  • Loading branch information
2 people authored and BradyJ27 committed Oct 19, 2023
1 parent 6cc58a2 commit 604b25c
Show file tree
Hide file tree
Showing 16 changed files with 490 additions and 46 deletions.
2 changes: 1 addition & 1 deletion examples/compiled/area_cumulative_freq.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
34 changes: 30 additions & 4 deletions examples/compiled/area_cumulative_freq.vg.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,37 @@
"url": "data/movies.json",
"format": {"type": "json", "parse": {"IMDB Rating": "number"}},
"transform": [
{
"type": "aggregate",
"groupby": ["IMDB Rating"],
"ops": ["count"],
"fields": [null],
"as": ["count"]
},
{
"type": "window",
"params": [null],
"as": ["Cumulative Count"],
"ops": ["count"],
"ops": ["sum"],
"fields": ["count"],
"sort": {"field": ["IMDB Rating"], "order": ["ascending"]},
"frame": [null, 0]
},
{
"type": "impute",
"field": "Cumulative Count",
"groupby": [],
"key": "IMDB Rating",
"method": "value",
"value": 0
},
{
"type": "stack",
"groupby": ["IMDB Rating"],
"field": "Cumulative Count",
"sort": {"field": [], "order": []},
"as": ["Cumulative Count_start", "Cumulative Count_end"],
"offset": "zero"
}
]
}
Expand All @@ -38,8 +61,8 @@
"signal": "\"IMDB Rating: \" + (format(datum[\"IMDB Rating\"], \"\")) + \"; Cumulative Count: \" + (format(datum[\"Cumulative Count\"], \"\"))"
},
"x": {"scale": "x", "field": "IMDB Rating"},
"y": {"scale": "y", "field": "Cumulative Count"},
"y2": {"scale": "y", "value": 0},
"y": {"scale": "y", "field": "Cumulative Count_end"},
"y2": {"scale": "y", "field": "Cumulative Count_start"},
"defined": {
"signal": "isValid(datum[\"IMDB Rating\"]) && isFinite(+datum[\"IMDB Rating\"]) && isValid(datum[\"Cumulative Count\"]) && isFinite(+datum[\"Cumulative Count\"])"
}
Expand All @@ -59,7 +82,10 @@
{
"name": "y",
"type": "linear",
"domain": {"data": "source_0", "field": "Cumulative Count"},
"domain": {
"data": "source_0",
"fields": ["Cumulative Count_start", "Cumulative Count_end"]
},
"range": [{"signal": "height"}, 0],
"nice": true,
"zero": true
Expand Down
25 changes: 22 additions & 3 deletions examples/compiled/area_density.vg.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
]
}
Expand All @@ -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\"])"
}
Expand All @@ -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
Expand Down
58 changes: 49 additions & 9 deletions examples/compiled/area_horizon.vg.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": [
Expand All @@ -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},
Expand All @@ -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\"])"
}
Expand All @@ -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"},
Expand All @@ -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\"])"
}
Expand All @@ -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"}],
Expand Down
24 changes: 20 additions & 4 deletions examples/compiled/area_params.vg.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
]
}
],
Expand Down Expand Up @@ -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\"])"
}
Expand All @@ -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
Expand Down
Binary file added examples/compiled/stacked_area_without_agg.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions examples/compiled/stacked_area_without_agg.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit 604b25c

Please sign in to comment.