Skip to content

Commit

Permalink
Add the example
Browse files Browse the repository at this point in the history
  • Loading branch information
yhoonkim committed Jul 19, 2023
1 parent d535812 commit 277e556
Show file tree
Hide file tree
Showing 4 changed files with 165 additions and 0 deletions.
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.
145 changes: 145 additions & 0 deletions examples/compiled/stacked_area_without_agg.vg.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,145 @@
{
"$schema": "https://vega.github.io/schema/vega/v5.json",
"background": "white",
"padding": 5,
"width": 200,
"height": 200,
"style": "cell",
"data": [
{
"name": "source_0",
"values": [
{"a": 1, "b": 2, "c": "c1"},
{"a": 2, "b": 3, "c": "c1"},
{"a": 3, "b": 1, "c": "c1"},
{"a": 1, "b": 2, "c": "c2"},
{"a": 3, "b": 1, "c": "c2"},
{"a": 2, "b": 2, "c": "c2"}
]
},
{
"name": "data_0",
"source": "source_0",
"transform": [
{"type": "formula", "expr": "toNumber(datum[\"a\"])", "as": "a"}
]
}
],
"marks": [
{
"name": "pathgroup",
"type": "group",
"from": {
"facet": {
"name": "faceted_path_main",
"data": "data_0",
"groupby": ["c"]
}
},
"encode": {
"update": {
"width": {"field": {"group": "width"}},
"height": {"field": {"group": "height"}}
}
},
"marks": [
{
"name": "marks",
"type": "area",
"style": ["area"],
"sort": {"field": "datum[\"a\"]"},
"from": {"data": "faceted_path_main"},
"encode": {
"update": {
"orient": {"value": "vertical"},
"fill": {"scale": "color", "field": "c"},
"description": {
"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},
"defined": {
"signal": "isValid(datum[\"a\"]) && isFinite(+datum[\"a\"]) && isValid(datum[\"b\"]) && isFinite(+datum[\"b\"])"
}
}
}
}
]
}
],
"scales": [
{
"name": "x",
"type": "linear",
"domain": {"data": "data_0", "field": "a"},
"range": [0, {"signal": "width"}],
"nice": true,
"zero": false
},
{
"name": "y",
"type": "linear",
"domain": {"data": "data_0", "field": "b"},
"range": [{"signal": "height"}, 0],
"nice": true,
"zero": true
},
{
"name": "color",
"type": "ordinal",
"domain": {"data": "data_0", "field": "c", "sort": true},
"range": "category"
}
],
"axes": [
{
"scale": "x",
"orient": "bottom",
"gridScale": "y",
"grid": true,
"tickCount": {"signal": "ceil(width/40)"},
"domain": false,
"labels": false,
"aria": false,
"maxExtent": 0,
"minExtent": 0,
"ticks": false,
"zindex": 0
},
{
"scale": "y",
"orient": "left",
"gridScale": "x",
"grid": true,
"tickCount": {"signal": "ceil(height/40)"},
"domain": false,
"labels": false,
"aria": false,
"maxExtent": 0,
"minExtent": 0,
"ticks": false,
"zindex": 0
},
{
"scale": "x",
"orient": "bottom",
"grid": false,
"title": "a",
"labelFlush": true,
"labelOverlap": true,
"tickCount": {"signal": "ceil(width/40)"},
"zindex": 0
},
{
"scale": "y",
"orient": "left",
"grid": false,
"title": "b",
"labelOverlap": true,
"tickCount": {"signal": "ceil(height/40)"},
"zindex": 0
}
],
"legends": [{"fill": "color", "symbolType": "circle", "title": "c"}]
}
19 changes: 19 additions & 0 deletions examples/specs/stacked_area_without_agg.vl.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"$schema": "https://vega.github.io/schema/vega-lite/v5.json",
"data": {
"values": [
{"a": 1, "b": 2, "c": "c1"},
{"a": 2, "b": 3, "c": "c1"},
{"a": 3, "b": 1, "c": "c1"},
{"a": 1, "b": 2, "c": "c2"},
{"a": 3, "b": 1, "c": "c2"},
{"a": 2, "b": 2, "c": "c2"}
]
},
"mark": "area",
"encoding": {
"x": {"field": "a", "type": "quantitative"},
"y": {"field": "b", "type": "quantitative"},
"color": {"field": "c"}
}
}

0 comments on commit 277e556

Please sign in to comment.