Skip to content

Instantly share code, notes, and snippets.

@john-guerra
Last active August 11, 2018 01:37
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 john-guerra/c01232c3fe5ed6fa3af7284af69667fd to your computer and use it in GitHub Desktop.
Save john-guerra/c01232c3fe5ed6fa3af7284af69667fd to your computer and use it in GitHub Desktop.
Vega-Lite Bl.ocks example
license: bsd-3-clause
{
"$schema": "https://vega.github.io/schema/vega-lite/v2.json",
"description": "A simple bar chart with embedded data.",
"width": 360,
"data": {
"values": [
{"name":"John", "age":23, "height":1.93},
{"name":"Mafe", "age":22, "height":1.70},
{"name":"Sonia", "age":27, "height":1.60},
{"name":"Vicente", "age":73, "height":0.32}
]
},
"mark": "bar",
"encoding": {
"x": {"field": "name", "type": "nominal"},
"y": {"field": "age", "type": "quantitative"},
"tooltip": {"field": "name", "type": "nominal"}
}
}
<!DOCTYPE html>
<head>
<meta charset="utf-8">
<script src="https://cdn.jsdelivr.net/npm/vega@4"></script>
<script src="https://cdn.jsdelivr.net/npm/vega-lite@3.0.0-rc3"></script>
<script src="https://cdn.jsdelivr.net/npm/vega-embed@3"></script>
</head>
<body>
<div id="vis"></div>
<script>
const spec = "bar.vl.json";
vegaEmbed('#vis', spec, {defaultStyle: true}).catch(console.warn);
</script>
</body>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment