emacs-ipython-notebook/AltairTutorial/example.html
2016-10-15 13:11:38 -05:00

91 lines
2 KiB
HTML

<!DOCTYPE html>
<head>
<title>Vega-Lite Chart</title>
<meta charset="utf-8">
<script src="//d3js.org/d3.v3.min.js"></script>
<script src="//vega.github.io/vega/vega.js"></script>
<script src="//vega.github.io/vega-lite/vega-lite.js"></script>
<script src="//vega.github.io/vega-editor/vendor/vega-embed.js" charset="utf-8"></script>
<style media="screen">
/* Add space between vega-embed links */
.vega-actions a {
margin-right: 5px;
}
</style>
</head>
<body>
<!-- Container for the visualization -->
<div id="vis"></div>
<script>
var vlSpec = {
"mark": "bar",
"encoding": {
"y": {
"field": "a",
"type": "nominal"
},
"x": {
"field": "b",
"aggregate": "average",
"type": "quantitative"
}
},
"data": {
"values": [
{
"b": 2,
"a": "C"
},
{
"b": 7,
"a": "C"
},
{
"b": 4,
"a": "C"
},
{
"b": 1,
"a": "D"
},
{
"b": 2,
"a": "D"
},
{
"b": 6,
"a": "D"
},
{
"b": 8,
"a": "E"
},
{
"b": 4,
"a": "E"
},
{
"b": 7,
"a": "E"
}
]
}
}
var embedSpec = {
mode: "vega-lite", // Instruct Vega-Embed to use the Vega-Lite compiler
spec: vlSpec
};
// Embed the visualization in the container with id `vis`
vg.embed("#vis", embedSpec, function(error, result) {
// Callback receiving the View instance and parsed Vega spec
// result.view is the View, which resides under the '#vis' element
});
</script>
</body>
</html>