Skip to content

Commit

Permalink
feat: stack area, bar, and arc marks by default (#7098)
Browse files Browse the repository at this point in the history
Co-authored-by: GitHub Actions Bot <vega-actions-bot@users.noreply.github.com>
  • Loading branch information
domoritz and GitHub Actions Bot committed Dec 26, 2020
1 parent 4770d02 commit a47fe9f
Show file tree
Hide file tree
Showing 54 changed files with 910 additions and 218 deletions.
17 changes: 14 additions & 3 deletions examples/compiled/arc_ordinal_theta.vg.json
Expand Up @@ -23,6 +23,14 @@
"name": "data_0",
"source": "source_0",
"transform": [
{
"type": "stack",
"groupby": ["dir"],
"field": "strength",
"sort": {"field": [], "order": []},
"as": ["strength_start", "strength_end"],
"offset": "zero"
},
{
"type": "filter",
"expr": "isValid(datum[\"strength\"]) && isFinite(+datum[\"strength\"])"
Expand All @@ -44,8 +52,8 @@
},
"x": {"signal": "width", "mult": 0.5},
"y": {"signal": "height", "mult": 0.5},
"outerRadius": {"scale": "radius", "field": "strength"},
"innerRadius": {"scale": "radius", "value": 0},
"outerRadius": {"scale": "radius", "field": "strength_end"},
"innerRadius": {"scale": "radius", "field": "strength_start"},
"startAngle": {"scale": "theta", "field": "dir"},
"endAngle": {
"scale": "theta",
Expand All @@ -66,7 +74,10 @@
{
"name": "radius",
"type": "linear",
"domain": {"data": "data_0", "field": "strength"},
"domain": {
"data": "data_0",
"fields": ["strength_start", "strength_end"]
},
"range": [0, {"signal": "min(width,height)/2"}],
"zero": true
},
Expand Down
28 changes: 23 additions & 5 deletions examples/compiled/area_gradient.vg.json
Expand Up @@ -11,7 +11,25 @@
"name": "source_0",
"url": "data/stocks.csv",
"format": {"type": "csv", "parse": {"date": "date"}},
"transform": [{"type": "filter", "expr": "datum.symbol==='GOOG'"}]
"transform": [
{"type": "filter", "expr": "datum.symbol==='GOOG'"},
{
"type": "impute",
"field": "price",
"groupby": [],
"key": "date",
"method": "value",
"value": 0
},
{
"type": "stack",
"groupby": ["date"],
"field": "price",
"sort": {"field": [], "order": []},
"as": ["price_start", "price_end"],
"offset": "zero"
}
]
}
],
"marks": [
Expand Down Expand Up @@ -42,8 +60,8 @@
"signal": "\"date: \" + (timeFormat(datum[\"date\"], '%b %d, %Y')) + \"; price: \" + (format(datum[\"price\"], \"\"))"
},
"x": {"scale": "x", "field": "date"},
"y": {"scale": "y", "field": "price"},
"y2": {"scale": "y", "value": 0},
"y": {"scale": "y", "field": "price_end"},
"y2": {"scale": "y", "field": "price_start"},
"defined": {
"signal": "isValid(datum[\"date\"]) && isFinite(+datum[\"date\"]) && isValid(datum[\"price\"]) && isFinite(+datum[\"price\"])"
}
Expand All @@ -63,7 +81,7 @@
"signal": "\"date: \" + (timeFormat(datum[\"date\"], '%b %d, %Y')) + \"; price: \" + (format(datum[\"price\"], \"\"))"
},
"x": {"scale": "x", "field": "date"},
"y": {"scale": "y", "field": "price"},
"y": {"scale": "y", "field": "price_end"},
"defined": {
"signal": "isValid(datum[\"date\"]) && isFinite(+datum[\"date\"]) && isValid(datum[\"price\"]) && isFinite(+datum[\"price\"])"
}
Expand All @@ -81,7 +99,7 @@
{
"name": "y",
"type": "linear",
"domain": {"data": "source_0", "field": "price"},
"domain": {"data": "source_0", "fields": ["price_start", "price_end"]},
"range": [{"signal": "height"}, 0],
"nice": true,
"zero": true
Expand Down
54 changes: 43 additions & 11 deletions examples/compiled/area_overlay.vg.json
Expand Up @@ -17,6 +17,36 @@
"name": "data_0",
"source": "source_0",
"transform": [
{
"type": "impute",
"field": "price",
"groupby": [],
"key": "date",
"method": "value",
"value": 0
},
{
"type": "stack",
"groupby": ["date"],
"field": "price",
"sort": {"field": [], "order": []},
"as": ["price_start", "price_end"],
"offset": "zero"
}
]
},
{
"name": "data_1",
"source": "source_0",
"transform": [
{
"type": "stack",
"groupby": ["date"],
"field": "price",
"sort": {"field": [], "order": []},
"as": ["price_start", "price_end"],
"offset": "zero"
},
{
"type": "filter",
"expr": "(isDate(datum[\"date\"]) || (isValid(datum[\"date\"]) && isFinite(+datum[\"date\"]))) && isValid(datum[\"price\"]) && isFinite(+datum[\"price\"])"
Expand All @@ -30,7 +60,7 @@
"type": "area",
"style": ["area"],
"sort": {"field": "datum[\"date\"]"},
"from": {"data": "source_0"},
"from": {"data": "data_0"},
"encode": {
"update": {
"opacity": {"value": 0.7},
Expand All @@ -40,8 +70,8 @@
"signal": "\"date: \" + (timeFormat(datum[\"date\"], '%b %d, %Y')) + \"; price: \" + (format(datum[\"price\"], \"\"))"
},
"x": {"scale": "x", "field": "date"},
"y": {"scale": "y", "field": "price"},
"y2": {"scale": "y", "value": 0},
"y": {"scale": "y", "field": "price_end"},
"y2": {"scale": "y", "field": "price_start"},
"defined": {
"signal": "isValid(datum[\"date\"]) && isFinite(+datum[\"date\"]) && isValid(datum[\"price\"]) && isFinite(+datum[\"price\"])"
}
Expand All @@ -53,15 +83,15 @@
"type": "line",
"style": ["line"],
"sort": {"field": "datum[\"date\"]"},
"from": {"data": "source_0"},
"from": {"data": "data_0"},
"encode": {
"update": {
"stroke": {"value": "#4c78a8"},
"description": {
"signal": "\"date: \" + (timeFormat(datum[\"date\"], '%b %d, %Y')) + \"; price: \" + (format(datum[\"price\"], \"\"))"
},
"x": {"scale": "x", "field": "date"},
"y": {"scale": "y", "field": "price"},
"y": {"scale": "y", "field": "price_end"},
"defined": {
"signal": "isValid(datum[\"date\"]) && isFinite(+datum[\"date\"]) && isValid(datum[\"price\"]) && isFinite(+datum[\"price\"])"
}
Expand All @@ -72,7 +102,7 @@
"name": "layer_2_marks",
"type": "symbol",
"style": ["point"],
"from": {"data": "data_0"},
"from": {"data": "data_1"},
"encode": {
"update": {
"opacity": {"value": 1},
Expand All @@ -82,7 +112,7 @@
"signal": "\"date: \" + (timeFormat(datum[\"date\"], '%b %d, %Y')) + \"; price: \" + (format(datum[\"price\"], \"\"))"
},
"x": {"scale": "x", "field": "date"},
"y": {"scale": "y", "field": "price"}
"y": {"scale": "y", "field": "price_end"}
}
}
}
Expand All @@ -93,8 +123,8 @@
"type": "time",
"domain": {
"fields": [
{"data": "source_0", "field": "date"},
{"data": "data_0", "field": "date"}
{"data": "data_0", "field": "date"},
{"data": "data_1", "field": "date"}
]
},
"range": [0, {"signal": "width"}]
Expand All @@ -104,8 +134,10 @@
"type": "linear",
"domain": {
"fields": [
{"data": "source_0", "field": "price"},
{"data": "data_0", "field": "price"}
{"data": "data_0", "field": "price_start"},
{"data": "data_0", "field": "price_end"},
{"data": "data_1", "field": "price_start"},
{"data": "data_1", "field": "price_end"}
]
},
"range": [{"signal": "height"}, 0],
Expand Down
14 changes: 11 additions & 3 deletions examples/compiled/bar.vg.json
Expand Up @@ -24,6 +24,14 @@
"name": "data_0",
"source": "source_0",
"transform": [
{
"type": "stack",
"groupby": ["a"],
"field": "b",
"sort": {"field": [], "order": []},
"as": ["b_start", "b_end"],
"offset": "zero"
},
{
"type": "filter",
"expr": "isValid(datum[\"b\"]) && isFinite(+datum[\"b\"])"
Expand Down Expand Up @@ -53,8 +61,8 @@
},
"x": {"scale": "x", "field": "a"},
"width": {"scale": "x", "band": 1},
"y": {"scale": "y", "field": "b"},
"y2": {"scale": "y", "value": 0}
"y": {"scale": "y", "field": "b_end"},
"y2": {"scale": "y", "field": "b_start"}
}
}
}
Expand All @@ -71,7 +79,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
Expand Down
17 changes: 14 additions & 3 deletions examples/compiled/bar_aggregate_transform.vg.json
Expand Up @@ -17,6 +17,14 @@
"fields": ["Acceleration"],
"as": ["mean_acc"]
},
{
"type": "stack",
"groupby": ["Cylinders"],
"field": "mean_acc",
"sort": {"field": [], "order": []},
"as": ["mean_acc_start", "mean_acc_end"],
"offset": "zero"
},
{
"type": "filter",
"expr": "isValid(datum[\"mean_acc\"]) && isFinite(+datum[\"mean_acc\"])"
Expand Down Expand Up @@ -46,8 +54,8 @@
},
"x": {"scale": "x", "field": "Cylinders"},
"width": {"scale": "x", "band": 1},
"y": {"scale": "y", "field": "mean_acc"},
"y2": {"scale": "y", "value": 0}
"y": {"scale": "y", "field": "mean_acc_end"},
"y2": {"scale": "y", "field": "mean_acc_start"}
}
}
}
Expand All @@ -64,7 +72,10 @@
{
"name": "y",
"type": "linear",
"domain": {"data": "source_0", "field": "mean_acc"},
"domain": {
"data": "source_0",
"fields": ["mean_acc_start", "mean_acc_end"]
},
"range": [{"signal": "height"}, 0],
"nice": true,
"zero": true
Expand Down
26 changes: 23 additions & 3 deletions examples/compiled/bar_argmax_transform.vg.json
Expand Up @@ -23,6 +23,17 @@
"expr": "datum[\"argmax_US_Gross\"] && datum[\"argmax_US_Gross\"][\"Production Budget\"]",
"as": "argmax_US_Gross.Production Budget"
},
{
"type": "stack",
"groupby": ["Major Genre"],
"field": "argmax_US_Gross\\.Production Budget",
"sort": {"field": [], "order": []},
"as": [
"argmax_US_Gross.Production Budget._start",
"argmax_US_Gross.Production Budget._end"
],
"offset": "zero"
},
{
"type": "filter",
"expr": "isValid(datum[\"argmax_US_Gross.Production Budget\"]) && isFinite(+datum[\"argmax_US_Gross.Production Budget\"])"
Expand Down Expand Up @@ -50,8 +61,14 @@
"description": {
"signal": "\"argmax_US_Gross['Production Budget']: \" + (format(datum[\"argmax_US_Gross.Production Budget\"], \"\")) + \"; Major Genre: \" + (isValid(datum[\"Major Genre\"]) ? datum[\"Major Genre\"] : \"\"+datum[\"Major Genre\"])"
},
"x": {"scale": "x", "field": "argmax_US_Gross\\.Production Budget"},
"x2": {"scale": "x", "value": 0},
"x": {
"scale": "x",
"field": "argmax_US_Gross\\.Production Budget\\._end"
},
"x2": {
"scale": "x",
"field": "argmax_US_Gross\\.Production Budget\\._start"
},
"y": {"scale": "y", "field": "Major Genre"},
"height": {"scale": "y", "band": 1}
}
Expand All @@ -64,7 +81,10 @@
"type": "linear",
"domain": {
"data": "source_0",
"field": "argmax_US_Gross\\.Production Budget"
"fields": [
"argmax_US_Gross\\.Production Budget\\._start",
"argmax_US_Gross\\.Production Budget\\._end"
]
},
"range": [0, {"signal": "width"}],
"nice": true,
Expand Down
14 changes: 11 additions & 3 deletions examples/compiled/bar_axis_orient_signal_future.vg.json
Expand Up @@ -25,6 +25,14 @@
"name": "data_0",
"source": "source_0",
"transform": [
{
"type": "stack",
"groupby": ["a"],
"field": "b",
"sort": {"field": [], "order": []},
"as": ["b_start", "b_end"],
"offset": "zero"
},
{
"type": "filter",
"expr": "isValid(datum[\"b\"]) && isFinite(+datum[\"b\"])"
Expand Down Expand Up @@ -54,8 +62,8 @@
},
"x": {"scale": "x", "field": "a"},
"width": {"scale": "x", "band": 1},
"y": {"scale": "y", "field": "b"},
"y2": {"scale": "y", "value": 0}
"y": {"scale": "y", "field": "b_end"},
"y2": {"scale": "y", "field": "b_start"}
}
}
}
Expand All @@ -72,7 +80,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
Expand Down

0 comments on commit a47fe9f

Please sign in to comment.