Skip to content

Instantly share code, notes, and snippets.

@kanitw
Last active October 5, 2017 16:46
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 kanitw/d2e716f1ea4114f247e16c6cac57452e to your computer and use it in GitHub Desktop.
Save kanitw/d2e716f1ea4114f247e16c6cac57452e to your computer and use it in GitHub Desktop.
Vega-Lite block example
license: bsd-3-clause
{
"$schema": "https://vega.github.io/schema/vega-lite/v2.json",
"description": "A simple bar chart with embedded data.",
"width": 15,
"height": 15,
"padding": 0,
"data": {
"values": [
{"a": "A","b": 28}, {"a": "B","b": 55}, {"a": "C","b": 43},
{"a": "D","b": 91}, {"a": "E","b": 81}, {"a": "F","b": 53},
{"a": "G","b": 19}, {"a": "H","b": 87}, {"a": "I","b": 52}
]
},
"mark": "bar",
"encoding": {
"x": {"field": "a", "type": "ordinal", "axis": null},
"y": {"field": "b", "type": "quantitative", "axis": null}
},
"config": {"view": {"stroke": "transparent"}}
}
<!DOCTYPE html>
<head>
<meta charset="utf-8">
<script src="https://cdnjs.cloudflare.com/ajax/libs/vega/3.0.2/vega.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/vega-lite/2.0.0-rc3/vega-lite.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/vega-embed/3.0.0-beta.19/vega-embed.js"></script>
<style>
body {
font-family: sans-serif;
}
.vega-actions a {
padding: 0.2em;
}
.vega-bindings {
display: inline-block;
}
</style>
</head>
<body>
We can embed a visualization inline like this <span id="vis"></span>!
<script>
const spec = "bar.vl.json";
vega.embed('#vis', spec, {actions: false});
</script>
</body>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment