-
Notifications
You must be signed in to change notification settings - Fork 0
/
chart_test.html
35 lines (33 loc) · 1.78 KB
/
chart_test.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
<!DOCTYPE html>
<html>
<head>
<style>
.error {
color: red;
}
</style>
<script type="text/javascript" src="https://cdn.jsdelivr.net/npm//vega@5"></script>
<script type="text/javascript" src="https://cdn.jsdelivr.net/npm//[email protected]"></script>
<script type="text/javascript" src="https://cdn.jsdelivr.net/npm//vega-embed@6"></script>
</head>
<body>
<div id="vis"></div>
<script>
(function(vegaEmbed) {
var spec = {"config": {"view": {"continuousWidth": 400, "continuousHeight": 300}}, "data": {"values": [{"hsisid": 4092018375, "score": 98, "date_": "2020-09-03T00:00:00Z"}, {"hsisid": 4092018375, "score": 97.5, "date_": "2021-03-23T00:00:00Z"}, {"hsisid": 4092018375, "score": 96.5, "date_": "2021-06-25T00:00:00Z"}, {"hsisid": 4092018375, "score": 98.5, "date_": "2021-08-05T00:00:00Z"}, {"hsisid": 4092018375, "score": 97, "date_": "2022-01-27T00:00:00Z"}]}, "mark": "point", "encoding": {"x": {"field": "date_", "title": "Time", "type": "temporal"}, "y": {"field": "score", "title": "Score", "type": "quantitative"}}, "title": "Health Scores", "$schema": "https://vega.github.io/schema/vega-lite/v4.17.0.json"};
var embedOpt = {"mode": "vega-lite"};
function showError(el, error){
el.innerHTML = ('<div class="error" style="color:red;">'
+ '<p>JavaScript Error: ' + error.message + '</p>'
+ "<p>This usually means there's a typo in your chart specification. "
+ "See the javascript console for the full traceback.</p>"
+ '</div>');
throw error;
}
const el = document.getElementById('vis');
vegaEmbed("#vis", spec, embedOpt)
.catch(error => showError(el, error));
})(vegaEmbed);
</script>
</body>
</html>