-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path03.html
30 lines (28 loc) · 871 Bytes
/
03.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
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>03 - D3 Bar</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
</head>
<body>
<script src="https://cdnjs.cloudflare.com/ajax/libs/d3/7.0.0/d3.js"></script>
<script>
const data = [4, 8, 15, 16, 23, 42];
const container = d3.create('div')
.style('font', '10px sans-serif')
.style('text-align', 'right')
.style('color', 'white');
document.body.appendChild(container.node());
container
.selectAll('div')
.data(data)
.join('div')
.style('background', 'steelblue')
.style('padding', '3px')
.style('margin', '1px')
.style('width', d => `${d * 10}px`)
.text(d => d);
</script>
</body>
</html>