Skip to content

Commit

Permalink
testing: add case for quantitative stacked scale theta graphs
Browse files Browse the repository at this point in the history
  • Loading branch information
hydrosquall committed Jan 26, 2025
1 parent 369fa1e commit 5bfb7f9
Show file tree
Hide file tree
Showing 2 changed files with 175 additions and 0 deletions.
135 changes: 135 additions & 0 deletions examples/compiled/arc_quantitative_stacked_theta.vg.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,135 @@
{
"$schema": "https://vega.github.io/schema/vega/v5.json",
"background": "white",
"padding": 5,
"width": 200,
"height": 200,
"style": "view",
"data": [
{
"name": "source_0",
"values": [
{
"segment": 1,
"value": 8
},
{
"segment": 2,
"value": 7
},
{
"segment": 3,
"value": 6
}
]
},
{
"name": "data_0",
"source": "source_0",
"transform": [
{
"type": "stack",
"groupby": [],
"field": "segment",
"sort": {
"field": [],
"order": []
},
"as": [
"segment_start",
"segment_end"
],
"offset": "zero"
},
{
"type": "filter",
"expr": "isValid(datum[\"segment\"]) && isFinite(+datum[\"segment\"]) && isValid(datum[\"value\"]) && isFinite(+datum[\"value\"])"
}
]
}
],
"marks": [
{
"name": "marks",
"type": "arc",
"style": [
"arc"
],
"from": {
"data": "data_0"
},
"encode": {
"update": {
"opacity": {
"value": 0.5
},
"stroke": {
"value": "#fff"
},
"innerRadius": {
"value": 20
},
"fill": {
"value": "#4c78a8"
},
"description": {
"signal": "\"segment: \" + (format(datum[\"segment\"], \"\")) + \"; value: \" + (format(datum[\"value\"], \"\"))"
},
"x": {
"signal": "width",
"mult": 0.5
},
"y": {
"signal": "height",
"mult": 0.5
},
"outerRadius": {
"scale": "radius",
"field": "value"
},
"startAngle": {
"scale": "theta",
"field": "segment_end"
},
"endAngle": {
"scale": "theta",
"field": "segment_start"
}
}
}
}
],
"scales": [
{
"name": "theta",
"type": "linear",
"domain": {
"data": "data_0",
"fields": [
"segment_start",
"segment_end"
]
},
"range": [
0,
6.283185307179586
],
"zero": true
},
{
"name": "radius",
"type": "sqrt",
"domain": {
"data": "data_0",
"field": "value"
},
"range": [
20,
{
"signal": "min(width,height)/2"
}
],
"zero": true
}
]
}
40 changes: 40 additions & 0 deletions examples/specs/arc_quantitative_stacked_theta.vl.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
{
"$schema": "https://vega.github.io/schema/vega-lite/v5.json",
"data": {
"values": [
{
"segment": 1,
"value": 8
},
{
"segment": 2,
"value": 7
},
{
"segment": 3,
"value": 6
}
]
},
"mark": {
"type": "arc",
"innerRadius": 20,
"stroke": "#fff",
"opacity": 0.5
},
"encoding": {
"theta": {
"field": "segment",
"type": "quantitative",
"stack": true
},
"radius": {
"field": "value",
"scale": {
"type": "sqrt",
"zero": true,
"rangeMin": 20
}
}
}
}

0 comments on commit 5bfb7f9

Please sign in to comment.