-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathindex.html
59 lines (48 loc) · 1.42 KB
/
index.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
48
49
50
51
52
53
54
55
56
57
58
59
<!DOCTYPE html>
<head>
<meta charset="utf-8">
<title>Bar Chart Race</title>
<style>
:root {
--sans-serif: sans-serif;
}
body {
max-width: 960px;
margin: 1em auto;
font-family: var(--sans-serif);
}
a:link:not(:hover) {
text-decoration: none;
}
</style>
</head>
<body>
<p>This example demonstrates a standalone Observable notebook with no external dependencies.</p>
<h2>The most populous cities in the world, 1575–2020</h2>
<div name="viewof replay"></div>
<div name="chart"></div>
<script src="d3.js"></script>
<script type="module">
import {Runtime, Library, Inspector} from "./runtime.js";
import notebook from "./barchart.js";
// Initialize the Observable Runtime, telling it to use our local copy of D3
// rather than loading one from a CDN.
const runtime = new Runtime(new Library(name => {
switch (name) {
case "d3@6": return d3;
}
}));
// Show the output of the “chart” and “viewof replay” cells in the DIV elements
// with the corresponding name.
const main = runtime.module(notebook, name => {
if (["chart", "viewof replay"].includes(name)) {
return new Inspector(document.querySelector(`[name='${name}']`));
}
});
// Redefine the “data” cell to use our CSV file (in the same format).
main.redefine("data", d3.csv("./cities.csv", d3.autoType));
// Redefine the “k” cell to disable tweening between keyframes. (This dataset is
// already interpolated.)
main.redefine("k", 1);
</script>
</body>