Skip to content

Instantly share code, notes, and snippets.

@djbarnwal
Created May 1, 2019 21:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save djbarnwal/7edcc45d2dda403b23a50294af6976f4 to your computer and use it in GitHub Desktop.
Save djbarnwal/7edcc45d2dda403b23a50294af6976f4 to your computer and use it in GitHub Desktop.
Prototype for New Grammar
{
"$schema": "https://vega.github.io/schema/vega/v5.json",
"width": 500,
"height": 200,
"padding": 5,
"data": [
{
"name": "table",
"values": [
{"x": 0, "y": 28, "c":0, "pointer": 0}, {"x": 0, "y": 55, "c":1, "pointer": 1},
{"x": 1, "y": 43, "c":0, "pointer": 2}, {"x": 1, "y": 91, "c":1, "pointer": 3},
{"x": 2, "y": 81, "c":0, "pointer": 4}, {"x": 2, "y": 53, "c":1, "pointer": 5},
{"x": 3, "y": 19, "c":0, "pointer": 6}, {"x": 3, "y": 87, "c":1, "pointer": 7},
{"x": 4, "y": 52, "c":0, "pointer": 8}, {"x": 4, "y": 48, "c":1, "pointer": 9},
{"x": 5, "y": 24, "c":0, "pointer": 10}, {"x": 5, "y": 49, "c":1, "pointer": 11},
{"x": 6, "y": 87, "c":0, "pointer": 12}, {"x": 6, "y": 66, "c":1, "pointer": 13},
{"x": 7, "y": 17, "c":0, "pointer": 14}, {"x": 7, "y": 27, "c":1, "pointer": 15},
{"x": 8, "y": 68, "c":0, "pointer": 16}, {"x": 8, "y": 16, "c":1, "pointer": 17},
{"x": 9, "y": 49, "c":0, "pointer": 18}, {"x": 9, "y": 15, "c":1, "pointer": 19}
],
"transform": [
{
"type": "stack",
"groupby": ["x"],
"field": "y"
}
]
}
],
"scales": [
{
"name": "x",
"type": "band",
"range": "width",
"domain": {"data": "table", "field": "x"}
},
{
"name": "y",
"type": "linear",
"range": "height",
"nice": true, "zero": true,
"domain": {"data": "table", "field": "y1"}
},
{
"name": "color",
"type": "ordinal",
"range": "category",
"domain": {"data": "table", "field": "c"}
}
],
"axes": [
{"orient": "bottom", "scale": "x", "zindex": 1},
{"orient": "left", "scale": "y", "zindex": 1}
],
"marks": [
{
"type": "rect",
"from": {"data": "table"},
"encode": {
"enter": {
"x": {"scale": "x", "field": "x"},
"width": {"scale": "x", "band": 1, "offset": -1},
"y": {"scale": "y", "field": "y0"},
"y2": {"scale": "y", "field": "y1"},
"fill": {"scale": "color", "field": "c"}
}
}
}
]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment