This repository was archived by the owner on May 3, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathexample4.html
More file actions
64 lines (59 loc) · 1.42 KB
/
Copy pathexample4.html
File metadata and controls
64 lines (59 loc) · 1.42 KB
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
<html>
<head>
<title>MAS.S70 | D3 workshop</title>
<link href="https://fonts.googleapis.com/css?family=PT+Sans" rel="stylesheet">
<style>
body {
margin: 0;
padding: 3%;
font-family: 'PT Sans', sans-serif;
}
.page {
margin: 0 auto;
max-width: 800px;
width: 90%;
}
h1 {
font-weight: normal;
text-rendering: optimizeLegibility;
}
.chart rect {
fill: rgba(3, 168, 124, 0.8);
}
.chart text {
fill: white;
font: 10px sans-serif;
text-anchor: end;
}
</style>
</head>
<body>
<div class="page">
<h1>Updating the chart dynamically | Functions</h1>
<br />
<h2> What is a function? </h2>
<p>
A function is a block of code that takes some inputs and transforms it
into an output. (This is a simplification).
</p>
<br />
<svg id="svg1">
</svg>
</div>
<script src="http://d3js.org/d3.v3.min.js"></script>
<script>
// Let's put everything in two functions
function generateData() {
// Fill this out
}
function drawChart(data) {
d3.select("#svg1").selectAll("*").remove()
// Put in your bar chart code
}
function repeatedTask() {
// What goes here?
}
// How do you call the repeatedTask again and again every second?
</script>
</body>
</html>