A simple Vega-lite bar chart example for vega-tooltip
Last active
February 3, 2018 18:19
-
-
Save sirahd/9520d2f95f3f13ec3756da1a4b713501 to your computer and use it in GitHub Desktop.
Vega-lite Bar Chart with Tooltip
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: mit |
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-lite@2"></script> | |
<script src="https://cdn.jsdelivr.net/npm/vega-embed@3"></script> | |
<link rel="stylesheet" type="text/css" href="https://cdn.jsdelivr.net/npm/vega-tooltip@0/build/vega-tooltip.min.css"> | |
<script src="https://cdn.jsdelivr.net/npm/vega-tooltip@0"></script> | |
</head> | |
<body> | |
<div id="vis-bar"></div> | |
<script> | |
var vlSpec = { | |
"$schema": "https://vega.github.io/schema/vega-lite/v2.json", | |
"description": "A simple bar chart with embedded data.", | |
"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" }, | |
"y": { "field": "b", "type": "quantitative" } | |
} | |
} | |
var opt = { | |
mode: "vega-lite", | |
actions: false | |
}; | |
vegaEmbed("#vis-bar", vlSpec, opt).then(function (result) { | |
vegaTooltip.vegaLite(result.view, vlSpec); | |
}).catch(console.error); | |
</script> | |
</body> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment