-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy path04-external-data.html
65 lines (53 loc) · 1.86 KB
/
04-external-data.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
60
61
62
63
64
65
<html>
<head>
<meta charset="utf-8">
<title>Scatterplots: D3 and external data</title>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta/css/bootstrap.min.css">
<link rel="stylesheet" href="d3-tip.css">
<style>
svg {
background: #f9f9f9;
display: block;
margin: 0 auto;
}
h1 { margin-bottom: 2rem; }
body {
padding-top: 2rem;
padding-bottom: 2rem;
}
h3 {
margin-top: 3rem;
margin-bottom: 1rem;
}
.container {
max-width: 46rem;
}
img.block {
display: block;
border: solid #333 1p;
margin: 0 auto;
}
</style>
</head>
</head>
<body>
<div class="container">
<h1>D3 and external data</h1>
<p>You'll need to run a <strong>local web server</strong> to make this one work. Open up the command line and whichever command is right for your machine:</p>
<ul>
<li><strong>Python 3:</strong><code>python -m http.server</code></li>
<li><strong>Python 2:</strong><code>python -m SimpleHTTPServer</code></li>
</ul>
<p>Then visit <a href="http://localhost:8000/">http://localhost:8000/</a> to see your visualization. If you get an an "address already in use" error you already have a server running.</p>
<p>Our data is <strong>countries.csv</strong></p>
<p>We have a <code>div</code> with the <code>id</code> of <code>chart</code>. No SVG anywhere!</p>
<div id="chart"></div>
<p>If we want tooltips, we're stealing code from <a href="http://bl.ocks.org/Caged/6476579">here</a></p>
<!-- This is D3, our graphing library -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/d3/5.7.0/d3.min.js"></script>
<!-- Now we include our actual visualization -->
<script src="d3-tip.js"></script>
<script src="04-external-data.js"></script>
</div>
</body>
</html>