-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscript.js
92 lines (92 loc) · 3.33 KB
/
script.js
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
document.getElementById('chart').width = window.innerWidth;
var ctx = document.getElementById('chart').getContext('2d');
var myChart = new Chart(ctx, {
type: 'bar',
data: {
labels: ['S1', 'S2', 'S3', 'S4'],
datasets: [
{
data: [
[new Date('2021-09-11T00:00:01'), new Date('2021-09-11T00:00:10')],
[new Date('2021-09-11T00:00:00'), new Date('2021-09-11T00:00:11')],
null,
[new Date('2021-09-11T00:00:00'), new Date('2021-09-11T00:00:11')],
],
label: 'O1'
},
{
data: [
[new Date('2021-09-11T00:00:02'), new Date('2021-09-11T00:00:07')],
[new Date('2021-09-11T00:01:01'), new Date('2021-09-11T00:01:07')],
[new Date('2021-09-11T00:01:01'), new Date('2021-09-11T00:01:07')],
null,
],
label: 'O2'
},
{
data: [
[new Date('2021-09-11T00:01:09'), new Date('2021-09-11T00:02:01')],
[new Date('2021-09-11T00:01:09'), new Date('2021-09-11T00:02:01')],
null,
[new Date('2021-09-11T00:01:09'), new Date('2021-09-11T00:02:01')],
],
label: 'O3'
},
{
data: [
[new Date('2021-09-11T00:01:09'), new Date('2021-09-11T00:02:01')],
[new Date('2021-09-11T00:01:09'), new Date('2021-09-11T00:02:01')],
null,
[new Date('2021-09-11T00:01:09'), new Date('2021-09-11T00:02:01')],
],
label: 'O4'
},
{
data: [
[new Date('2021-09-11T00:01:09'), new Date('2021-09-11T00:02:01')],
[new Date('2021-09-11T00:01:09'), new Date('2021-09-11T00:02:01')],
null,
[new Date('2021-09-11T00:01:09'), new Date('2021-09-11T00:02:01')],
],
label: 'O5'
},
],
},
options: {
indexAxis: 'y',
plugins: {
title: {
display: true,
text: 'Event Timeline'
},
tooltip: {
callbacks: {
label: function (context) {
return context.dataset.label;
},
afterLabel: function (context) {
var start = context.dataset.data[context.dataIndex][0];
var end = context.dataset.data[context.dataIndex][1];
var a = moment(start).format("YYYY-MM-DD h:mm:ss a");
var b = moment(end).format("YYYY-MM-DD h:mm:ss a");
return a + " to " + b;
}
}
}
},
scales: {
y: {
stacked: false
},
x: {
type: 'time',
time: {
unit: 'second'
},
min: new Date('2021-09-11T00:00:00'),
max: new Date('2021-09-11T00:02:11')
}
},
maintainAspectRatio: false
}
});