jomjol 3 лет назад
Родитель
Сommit
a702fbbe86
1 измененных файлов с 62 добавлено и 0 удалено
  1. 62 0
      sd-card/html/graph.html

+ 62 - 0
sd-card/html/graph.html

@@ -0,0 +1,62 @@
+<html>
+<head>
+<script src='https://cdn.plot.ly/plotly-2.14.0.min.js'></script>
+<style>
+    textarea {
+        width: 600px;
+        height: 300px;
+    }
+</style>
+<script>
+function run() {
+  var el = document.getElementById('cnsl');
+  el && eval(el.value);
+}
+</script>
+</head>
+<body>
+<div id='chart'></div>
+<button onclick="document.getElementById('editor').hidden = false; this.hidden = true;" >Editor</button>
+<div id='editor' hidden='true'>
+<textarea id="cnsl">
+const d = new Date();
+var date = d.getFullYear() + "-" + (d.getMonth()+1) + "-" + d.getDate();    
+fetch('/fileserver/log/message/log_'+date+'.txt')
+.then(response => {
+    // handle the response
+    response.text()
+    .then( result => {
+        var lines = result.split("\n");
+        var trace = {
+        x: [],
+        y: [],
+        type: 'scatter'
+        };
+
+        var timex = 1;
+        for (let line of lines) {
+            if (line.includes("PostProcessing - Raw")) {
+                console.log(line);
+                var value = line.split(" ")[6];
+                var time  = line.split(" ")[0];
+                console.log("> "+time+" "+value+"\n");
+                trace.x.push(timex);
+                timex += 1;
+                trace.y.push(value);
+            }
+        }
+        console.log(trace);
+        var data = [trace];
+        Plotly.newPlot('chart', data);
+    });
+})
+.catch(error => {
+    // handle the error
+out.value = "error";
+});        
+</textarea><br />
+<button onclick="run();">run</button>
+</div>
+<script>run();</script>
+</body>
+</html>