@@ -3,6 +3,10 @@ extends layout
33block content
44 h1= title
55
6+ script( src ='https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.22.2/moment.min.js' )
7+ script( src ='https://cdn.jsdelivr.net/npm/chart.js@2.7.2/dist/Chart.min.js' )
8+ script( src ='https://code.jquery.com/jquery-1.11.1.js' )
9+
610 div.row
711 div.col
812 div( class ="card m-2" )
@@ -53,10 +57,88 @@ block content
5357 dt.col-lg-3 Status:
5458 dd.col-lg-9 #{device .status }
5559
60+ - if (timeseries)
61+ div()
62+ - if (device .heartRate )
63+ div( style ="float: left;" )
64+ h2 Heart Rate
65+ canvas( id ="heartRate" width ="800px" height ="400px" )
66+ - if (device .humidity )
67+ div( style ="float: left;" )
68+ h2 Humidity
69+ canvas( id ="humidity" width ="800px" height ="400px" )
70+ - if (device .fillingLevel )
71+ div( style ="float: left;" )
72+ h2 Filling Level
73+ canvas( id ="fillingLevel" width ="800px" height ="400px" )
74+ - if (device .temperature )
75+ div( style ="float: left;" )
76+ h2 Temperature
77+ canvas( id ="temperature" width ="800px" height ="400px" )
78+ div( style ="clear: both;" )
79+
5680 div.row
5781 div.col
5882 div( class ="card m-2" )
5983 div.card-body
60- summary.list-unstyled
84+ summary.list-unstyled Entity
6185 details
62- pre #{JSON .stringify (device, null , 4 )}
86+ pre #{JSON .stringify (device, null , 4 )}
87+
88+ - if (timeseries)
89+ div.row
90+ div.col
91+ div( class ="card m-2" )
92+ div.card-body
93+ summary.list-unstyled Temporal Entity
94+ details
95+ pre #{JSON .stringify (timeseries, null , 4 )}
96+
97+
98+ - if (timeseries)
99+ script ( type ='text/javascript' ) .
100+
101+ var chartData = ! {JSON .stringify (chartData)};
102+
103+ var text = {
104+ heartRate : " bpm" ,
105+ humidity: " %" ,
106+ temperature: " C" ,
107+ fillingLevel: ' %'
108+
109+ }
110+
111+ Object .keys (chartData).forEach ((key ) => {
112+ var values = chartData[key];
113+ var ctx = document .getElementById (key);
114+ var barChart = new Chart (ctx, {
115+ type: " line" ,
116+ data: {
117+ labels: values .labels ,
118+ datasets: [{
119+ fill: false ,
120+ label: text[key] || ' %' ,
121+ data: values .data ,
122+ backgroundColor : ' #45d3dd' ,
123+ borderColor : ' #45d3dd' ,
124+ pointRadius : 5
125+ }]
126+ },
127+ options: {
128+ responsive: false ,
129+ scales: {
130+ xAxes: [{
131+ ticks: {
132+ source: " labels"
133+ }
134+ }],
135+ yAxes: [{
136+ ticks: {
137+ beginAtZero: true
138+ }
139+ }]
140+ }
141+ }
142+ });
143+ var chart = new Chart (ctx, cfg);
144+ });
0 commit comments