forked from domoritz's block: Vega Bl.ocks example
Last active
May 20, 2018 22:11
-
-
Save domoritz/0ec5a1df8d19a0fa935206a6e3bbb0ae to your computer and use it in GitHub Desktop.
Vega slider example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
license: bsd-3-clause |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"$schema": "https://vega.github.io/schema/vega/v3.json", | |
"width": 400, | |
"height": 200, | |
"padding": 5, | |
"data": [ | |
{ | |
"name": "table", | |
"values": [ | |
{"category": "A", "amount": 28}, | |
{"category": "B", "amount": 55}, | |
{"category": "C", "amount": 43}, | |
{"category": "D", "amount": 91}, | |
{"category": "E", "amount": 81}, | |
{"category": "F", "amount": 53}, | |
{"category": "G", "amount": 19}, | |
{"category": "H", "amount": 87} | |
] | |
} | |
], | |
"signals": [ | |
{"name":"test", | |
"value":1, | |
"bind":{ | |
"type":"range", | |
"max":10, | |
"min":1, | |
"step":1 | |
}} | |
], | |
"scales": [ | |
{ | |
"name": "xscale", | |
"type": "band", | |
"domain": {"data": "table", "field": "category"}, | |
"range": "width", | |
"padding": 0.05, | |
"round": true | |
}, | |
{ | |
"name": "yscale", | |
"domain": {"data": "table", "field": "amount"}, | |
"nice": true, | |
"range": "height" | |
} | |
], | |
"axes": [ | |
{ "orient": "bottom", "scale": "xscale" }, | |
{ "orient": "left", "scale": "yscale" } | |
], | |
"marks": [ | |
{ | |
"type": "rect", | |
"from": {"data":"table"}, | |
"encode": { | |
"enter": { | |
"x": {"scale": "xscale", "field": "category"}, | |
"width": {"scale": "xscale", "band": 1}, | |
"y": {"scale": "yscale", "field": "amount"}, | |
"y2": {"scale": "yscale", "value": 0} | |
}, | |
"update": { | |
"fill": {"value": "steelblue"} | |
}, | |
"hover": { | |
"fill": {"value": "red"} | |
} | |
} | |
} | |
] | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<head> | |
<meta charset="utf-8"> | |
<script src="https://cdn.jsdelivr.net/npm/vega@3"></script> | |
<script src="https://cdn.jsdelivr.net/npm/vega-embed@3"></script> | |
<style> | |
body { | |
font-family: sans-serif; | |
} | |
.vega-actions a { | |
padding: 0.2em; | |
} | |
</style> | |
</head> | |
<body> | |
<div id="vis"></div> | |
<script> | |
const spec = "bar.vg.json"; | |
vegaEmbed('#vis', spec); | |
</script> | |
</body> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment