2 archive_base="/meteo/archive";
4 var params = window.location.pathname.split('/').slice(-4);
5 var sensor_id = params[1];
6 var sensor = params[2];
9 var sensor_path = sensor_id + "." + sensor + "." + param;
13 function processDataset(dataset,sensorid,sensorname,paramname) {
14 var scale = properties["scale"][sensorid+"."+sensorname+"."+paramname]
17 for (idx in dataset) {
19 newRec.t = dataset[idx].t
20 newRec.y = dataset[idx].y * scale[0];
29 function drawGraph(graphData) {
31 document.getElementById("archive").href = archive_base+"////"+sensor_id + "/" + sensor + "/" + param;
33 var div = document.getElementById("chartdiv");
34 var canvas = document.getElementById("chart");
36 canvas.width = div.style.width;
37 canvas.height = div.style.height;
39 var ctx = canvas.getContext('2d');
40 var color = Chart.helpers.color;
42 var y_label = properties["names"][sensor_path];
43 if (properties["units"][sensor_path]) {
44 y_label = y_label + ", " + properties["units"][sensor_path];
52 label: properties["places"][sensor_path] + ' - ' + properties["names"][sensor_path],
53 backgroundColor: color(properties["colors"][sensor_path]).alpha(0.5).rgbString(),
54 borderColor: properties["colors"][sensor_path],
55 data: processDataset(graphData,sensor_id,sensor,param),
70 responsiveAnimationDuration: 0,
73 fontColor: properties["fonts"]["legend"]["color"],
74 fontSize: properties["fonts"]["legend"]["size"],
75 fontStyle: properties["fonts"]["legend"]["style"],
81 distribution: 'series',
83 fontColor: properties["fonts"]["axes"]["color"],
84 fontSize: properties["fonts"]["axes"]["size"],
85 fontStyle: properties["fonts"]["axes"]["style"],
92 fontColor: properties["fonts"]["axes"]["color"],
93 fontSize: properties["fonts"]["axes"]["size"],
94 fontStyle: properties["fonts"]["axes"]["style"],
100 var chart = new Chart(ctx, cfg);
103 function RefreshGraph() {
105 var req = new XMLHttpRequest();
107 req.onreadystatechange = function () {
108 if (this.readyState != 4) return;
109 if (this.status != 200) {
110 setTimeout(RefreshGraph,60000);
113 var graphData = JSON.parse(this.responseText);
114 drawGraph(graphData);
115 setTimeout(RefreshGraph,60000)
118 req.open("GET", urlbase+"get/"+sensor_id+"/"+sensor+"/"+param, true);
119 req.withCredentials = true;
124 function GetProperties() {
125 var req = new XMLHttpRequest();
127 req.onreadystatechange = function () {
128 if (this.readyState != 4) return;
129 if (this.status != 200) {
130 setTimeout(GetProperties,30000);
133 properties = JSON.parse(this.responseText);
134 setTimeout(RefreshGraph,100)
137 req.open("GET", urlbase+"props", true);
138 req.withCredentials = true;
143 setTimeout(GetProperties,100)