{
"$schema": "https://vega.github.io/schema/vega/v3.0.json",
"width": 500,
"height": 300,
"padding": 5,
"data": [
{
"name": "table",
"transform": [
{
"type": "stack",
"groupby": [
"x"
],
"sort": {
"field": "z"
},
"field": "y"
}
],
"values": [
{
"x": 0,
"y": 0,
"z": 1
},
{
"x": 0,
"y": 0,
"z": 0
},
{
"x": 1,
"y": 1,
"z": 1
},
{
"x": 1,
"y": 2,
"z": 0
},
{
"x": 2,
"y": 4,
"z": 1
},
{
"x": 2,
"y": 4,
"z": 0
},
{
"x": 3,
"y": 9,
"z": 1
},
{
"x": 3,
"y": 6,
"z": 0
},
{
"x": 4,
"y": 16,
"z": 1
},
{
"x": 4,
"y": 8,
"z": 0
},
{
"x": 5,
"y": 25,
"z": 1
},
{
"x": 5,
"y": 10,
"z": 0
},
{
"x": 6,
"y": 36,
"z": 1
},
{
"x": 6,
"y": 12,
"z": 0
},
{
"x": 7,
"y": 49,
"z": 1
},
{
"x": 7,
"y": 14,
"z": 0
},
{
"x": 8,
"y": 64,
"z": 1
},
{
"x": 8,
"y": 16,
"z": 0
},
{
"x": 9,
"y": 81,
"z": 1
},
{
"x": 9,
"y": 18,
"z": 0
}
]
}
],
"scales": [
{
"name": "x",
"type": "band",
"range": "width",
"domain": {
"data": "table",
"field": "x"
}
},
{
"name": "y",
"type": "linear",
"range": "height",
"domain": {
"data": "table",
"field": "y1"
}
},
{
"name": "color",
"type": "ordinal",
"range": "category",
"domain": {
"data": "table",
"field": "z"
}
}
],
"axes": [
{
"orient": "bottom",
"scale": "x"
},
{
"orient": "left",
"scale": "y"
}
],
"marks": [
{
"type": "rect",
"from": {
"data": "table"
},
"encode": {
"enter": {
"x": {
"field": "x",
"scale": "x"
},
"width": {
"scale": "x",
"band": 1
},
"y": {
"scale": "y",
"field": "y0"
},
"y2": {
"field": "y1",
"scale": "y"
},
"fill": {
"field": "z",
"scale": "color"
}
},
"update": {
"fillOpacity": {
"value": 1.0
}
},
"hover": {
"fillOpacity": {
"value": 0.5
}
}
}
}
]
}