-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathview-api.html
47 lines (44 loc) · 1.49 KB
/
view-api.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<link rel="stylesheet" type="text/css" href="style.css">
<!--<script src="https://cdn.jsdelivr.net/npm/vega@5"></script>-->
<script src="https://vega.github.io/vega/vega.js"></script>
<script src="datamanagement.js"></script>
<title>Vega / forTEXT: View API</title>
</head>
<body>
<div id="page">
<h1>Vega / forTEXT: View-API</h1>
<nav>
<ul>
<li><a href="https://github.com/olafgrabienski/vega-fortext">GitHub Repo</a></li>
<li><a href="embed-module.html">Vega Embed</a></li>
<li>View API</li>
</ul>
</nav>
<div id="view"></div>
</div>
<script type="text/javascript">
fetch('visualization-edge-bundling.vg.json')
.then(res => res.json())
.then(spec => loadData(spec))
.catch(err => console.error(err));
function loadData(spec) {
let baseUrl = window.location.protocol + '//' + window.location.host + '/';
fetch(baseUrl + 'vega-fortext/api/views/json_articles_category')
.then(res => res.json())
.then(data => render(data, spec))
.catch(err => console.error(err));
}
function render(data, spec) {
injectData(spec, data.results);
let view = new vega.View(vega.parse(spec), {
renderer: 'canvas', // renderer (canvas or svg)
container: '#view', // parent DOM container
hover: true // enable hover processing
});
return view.runAsync();
}
</script>
</body>