-
-
Notifications
You must be signed in to change notification settings - Fork 2
/
basic.html
32 lines (30 loc) · 958 Bytes
/
basic.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
<!DOCTYPE html>
<html>
<head>
<script src="https://unpkg.com/chart.js@3.8.0/dist/chart.js"></script>
<script src="../build/index.umd.js"></script>
</head>
<body>
<div style="width: 75%">
<canvas id="canvas" style="border: 1px solid black"></canvas>
</div>
<script>
fetch('https://raw.githubusercontent.com/derhuerst/mtcars/master/index.json')
.then((r) => r.json())
.then((mtcars) => {
const attrs = ['mpg', 'hp', 'wt', 'qsec', 'gear', 'drat', 'disp', 'cyl', 'am'];
const chart = new Chart(document.getElementById('canvas').getContext('2d'), {
type: 'pcp',
data: {
labels: mtcars.map((c) => c.model),
datasets: attrs.map((attr) => ({
label: attr,
data: mtcars.map((c) => c[attr]),
})),
},
options: {},
});
});
</script>
</body>
</html>