-
-
Notifications
You must be signed in to change notification settings - Fork 22
/
mediancolor.html
53 lines (51 loc) · 1.4 KB
/
mediancolor.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
<!DOCTYPE html>
<html>
<head>
<title>Box Plot Chart</title>
<script src="https://unpkg.com/chart.js@3.8.0/dist/chart.js"></script>
<script src="../build/index.umd.js"></script>
</head>
<body>
<div id="container" style="width: 75%">
<canvas id="canvas"></canvas>
</div>
<script>
function randomValues(count, min, max) {
const delta = max - min;
return Array.from({ length: count }).map(() => Math.random() * delta + min);
}
const boxplotData = {
labels: ['A', 'B'],
datasets: [
{
label: 'Dataset 1',
borderColor: 'green',
medianColor: 'blue',
borderWidth: 1,
outlierRadius: 3,
itemRadius: 3,
outlierBackgroundColor: '#999999',
data: [randomValues(100, 1, 9).concat([14, 16, 0]), randomValues(100, 0, 10)],
},
],
};
window.onload = function () {
const ctx = document.getElementById('canvas').getContext('2d');
const myBar = new Chart(ctx, {
type: 'boxplot',
data: boxplotData,
options: {
responsive: true,
legend: {
position: 'top',
},
title: {
display: true,
text: 'Chart.js Box Plot Chart',
},
},
});
};
</script>
</body>
</html>