Built with blockbuilder.org
Last active
June 13, 2020 02:38
-
-
Save domoritz/7d3b8ed06c079608491a6d4a185f7fd1 to your computer and use it in GitHub Desktop.
Vega CSP test
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> | |
<html> | |
<head> | |
<meta charset="utf-8" /> | |
<meta name="viewport" content="width=device-width, initial-scale=1" /> | |
<meta http-equiv="Content-Security-Policy" content="script-src self cdn.jsdelivr.net bl.ocks.org blockbuilder.org" /> | |
<title>Vega CSP Test</title> | |
<script src="https://cdn.jsdelivr.net/npm/vega@5"></script> | |
<script src="https://cdn.jsdelivr.net/npm/vega-interpreter"></script> | |
</head> | |
<body> | |
<div id="view"></div> | |
<script src="main.js"></script> | |
</body> | |
</html> |
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
let view; | |
fetch('https://vega.github.io/vega/examples/bar-chart.vg.json') | |
.then(res => res.json()) | |
.then(spec => render(spec)) | |
.catch(err => console.error(err)); | |
function render(spec) { | |
// Parse the Vega specification with AST output enabled | |
// Pass a null configuration value as the second argument | |
const runtime = vega.parse(spec, null, { ast: true }); | |
// Call Vega View constructor with an 'expr' interpreter option | |
view = new vega.View(runtime, { | |
expr: vega.expressionInterpreter, | |
renderer: 'svg', // renderer (canvas or svg) | |
container: '#view', // parent DOM container | |
hover: true // enable hover processing | |
}); | |
return view.runAsync(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment