-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.html
More file actions
47 lines (45 loc) · 1.35 KB
/
index.html
File metadata and controls
47 lines (45 loc) · 1.35 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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Chart with quickchart</title>
</head>
<style>
.img {
margin: auto;
display: block;
user-select: none;
padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}
</style>
<body id="body">
<h1>CLICK FOR GENERATE RANDOM CHARTS</h1>
</body>
<script>
document.addEventListener("click", () => {
const randomNumber = () => Math.floor(Math.random() * 20)
const plans = [
["planVargas", randomNumber()],
["planOni", randomNumber()],
["planPeña", randomNumber()],
]
const chart = {
type: "bar",
data: {
labels: plans.map(([planName]) => `'${planName}'`),
datasets: [
{
label: "Servicios",
data: plans.map(([_, serviceCount]) => serviceCount),
},
],
},
}
const body = document.getElementById("body")
const rawSrc = `{type:%27pie%27,data:{labels:[${chart.data.labels}],datasets:[{label:%27Servicios%27,data:[${chart.data.datasets[0].data}]}]}}`
body.innerHTML += `<img class="img" src="https://quickchart.io/chart?bkg=white&c=${rawSrc}" width="601" height="361" />`
})
</script>
</html>