-
Notifications
You must be signed in to change notification settings - Fork 1
/
rasp.js
55 lines (51 loc) · 1.83 KB
/
rasp.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
//fetch('http://g0mesp1res.dynip.sapo.pt/rtemp.csv')
fetch('../rtemp.csv')
.then(function (response) {
return response.text();
})
.then(function (text) {
let series = csvToSeries4(text);
renderChart4(series);
console.log(series);
})
.catch(function (error) {
//Something went wrong
console.log(error);
});
function csvToSeries4(text) {
const formatYmd = date => date.toISOString().slice(0, 10);
let dataAsJson = JSC.csv2Json(text);
let rtemp =[];
dataAsJson.forEach(function (row) {
//window.alert('x');
// document.write(row.date);
rtemp.push({x: row.date, y: row.rtemp});
});
return [
{name: 'Raspberry CPU', points: rtemp}
];
}
function renderChart4(series) {
JSC.Chart('chartDiv_raspTemp', {
title_label_text: 'Raspberry PI 2 CPU temperature',
annotations: [{
label_text: 'Source: Raspberry',
position: 'bottom left'
}],
xAxis: {
scale_type: "time",
defaultTick_enabled: true
},
yAxis: {
scale: {
range: { min: 40, max: 70, padding: 0.1 }
},
markers: [{ value: 5 }],
},
legend_visible: false,
xAxis_crosshair_enabled: true,
yAxis_crosshair_enabled: true,
defaultSeries_lastPoint_label_text: '<b>%seriesName</b>',
series: series
});
}