-
Notifications
You must be signed in to change notification settings - Fork 0
/
chartEmbed1_single.html
47 lines (32 loc) · 1.54 KB
/
chartEmbed1_single.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
<!DOCTYPE html>
<!-- Richard Davies, Data Science -->
<!-- Example of how to embed a chart in a web page: -->
<!-- /////////////////// HEAD //////////////////////////////////// -->
<head>
<!--The next three lines allow the Vega embed-->
<script src="https://cdn.jsdelivr.net/npm/[email protected]"></script>
<script src="https://cdn.jsdelivr.net/npm/[email protected]"></script>
<script src="https://cdn.jsdelivr.net/npm/[email protected]"></script>
</head>
<!-- /////////////////// HEAD //////////////////////////////////// -->
<!-- /////////////////// BODY //////////////////////////////////// -->
<body>
<h1>Here is my first embedded chart:</h1>
<!--We create a div - this is just an area of our web page-->
<div class="chart" id="firstChart"></div>
<!--We give the Div a class, which can apply to many divs-->
<!--And we give the Div and ID, which can apply to ONE divs-->
<!--To point to an ID, we use the code #ID. So to get to ID=Richard we use #Richard-->
<script>
// Following the script tag we are now using Javascript.
// One way to tell is to see how comments work, they now start with //.
// First job is to set the chart as a JS variable:
var myChart1 = "chart1_covidUKRegions.json";
// Now we simply insert it, using Vega's embed code:
// The embed function needs to be told the location, and what to put there.
vegaEmbed('#firstChart', myChart1);
</script>
</div>
</body>
<!-- /////////////////// BODY //////////////////////////////////// -->
</html>