/
test.html
131 lines (119 loc) · 2.79 KB
/
test.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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
<!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">
<script src="https://cdnjs.cloudflare.com/ajax/libs/Chart.js/3.1.0/chart.min.js"></script>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@4.6.0/dist/css/bootstrap.min.css">
<link rel="stylesheet" href="/assets/css/chart.css">
<title>Document</title>
</head>
<body>
<div class=wrapper id="wrapper">
<canvas id="canvas">
<div class="note">
<script>
const colors = {
purple: {
default: "rgba(149, 76, 233, 1)",
half: "rgba(149, 76, 233, 0.5)",
quarter: "rgba(149, 76, 233, 0.25)",
zero: "rgba(149, 76, 233, 0)"
},
indigo: {
default: "rgba(80, 102, 120, 1)",
quarter: "rgba(80, 102, 120, 0.25)"
}
};
const weight = [60.0, 60.2, 59.1, 61.4, 59.9, 60.2, 59.8, 58.6, 59.6, 59.2];
const labels = [
"Week 1",
"Week 2",
"Week 3",
"Week 4",
"Week 5",
"Week 6",
"Week 7",
"Week 8",
"Week 9",
"Week 10"
];
const ctx = document.getElementById("canvas").getContext("2d");
ctx.canvas.height = 100;
gradient = ctx.createLinearGradient(0, 25, 0, 300);
gradient.addColorStop(0, colors.purple.half);
gradient.addColorStop(0.35, colors.purple.quarter);
gradient.addColorStop(1, colors.purple.zero);
const options = {
type: "line",
data: {
labels: labels,
datasets: [
{
fill: true,
backgroundColor: gradient,
pointBackgroundColor: colors.purple.default,
borderColor: colors.purple.default,
data: weight,
lineTension: 0.2,
borderWidth: 2,
pointRadius: 3
}
]
},
options: {
layout: {
padding: 10
},
responsive: true,
legend: {
display: false
},
scales: {
xAxes: [
{
gridLines: {
display: false
},
ticks: {
padding: 10,
autoSkip: false,
maxRotation: 15,
minRotation: 15
}
}
],
yAxes: [
{
scaleLabel: {
display: true,
labelString: "Weight in KG",
padding: 10
},
gridLines: {
display: true,
color: colors.indigo.quarter
},
ticks: {
beginAtZero: false,
max: 63,
min: 57,
padding: 10
}
}
]
}
}
};
window.onload = function () {
window.myLine = new Chart(ctx, options);
Chart.defaults.global.defaultFontColor = colors.indigo.default;
Chart.defaults.global.defaultFontFamily = "Fira Sans";
};
</script>
</div>
</d>
</div>
</body>
</html>