-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcanvas.html
46 lines (44 loc) · 1.19 KB
/
canvas.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
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title>Scatter Plot</title>
<style>
body {
margin: 0px;
padding: 0px;
}
div {
font-size: 20px;
}
</style>
</head>
<body>
<div id="canvas"></div>
<script type="text/javascript" src="scatterplot-data-1.js"></script>
<script type="module">
import * as d3 from "https://cdn.jsdelivr.net/npm/d3@7/+esm";
let html = document.getElementById("canvas");
const width = 600;
const height = 400;
const margin = {
top: 20,
bottom: 20,
left: 20,
right: 20,
};
const svg = d3
.create("svg")
.attr("width", width + margin.left + margin.right)
.attr("height", height + margin.top + margin.bottom)
.style("border", "1px dashed #000");
const g = svg
.append("g")
.attr("transform", `translate(${margin.left},${margin.top})`);
g.append("rect").attr("width", width).attr("height", height);
window.svg = svg;
html.append(svg.node());
</script>
</body>
</html>