-
Notifications
You must be signed in to change notification settings - Fork 0
/
client.js
45 lines (38 loc) · 921 Bytes
/
client.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
function plotTimeSeries(data,label,elementID){
const ctx = document.getElementById(elementID);
const chart = new Chart(ctx, {
type: 'line',
data: {
datasets: [
{
label: 'reanalysis',
borderColor: 'rgb(0, 0, 0)',
backgroundColor: 'rgb(0, 0, 0)',
xAxisID: 'x',
parsing: { xAxisKey: 'time', yAxisKey: 'values' },
data: data[1]
},
{
label: 'observations',
borderColor: 'rgb(75, 192, 192)',
backgroundColor: 'rgb(75, 192, 192)',
xAxisID: 'x',
parsing: { xAxisKey: 'DATE', yAxisKey: 'TAVG' },
data: data[0]
},
]
},
options: {
scales: {
x: { type: 'time', time: { unit: 'month' } }
},
plugins: {
title: {
display: true,
text: 'Surface temperature from reanalysis and observations'
}
}
}
});
return chart;
}