graph.html 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. <html>
  2. <head>
  3. <script src='https://cdn.plot.ly/plotly-2.14.0.min.js'></script>
  4. <style>
  5. textarea {
  6. width: 600px;
  7. height: 300px;
  8. }
  9. </style>
  10. <script>
  11. function run() {
  12. var el = document.getElementById('cnsl');
  13. el && eval(el.value);
  14. }
  15. </script>
  16. </head>
  17. <body>
  18. <div id='chart'></div>
  19. <button onclick="document.getElementById('editor').hidden = false; this.hidden = true;" >Editor</button>
  20. <div id='editor' hidden='true'>
  21. <textarea id="cnsl">
  22. const d = new Date();
  23. var date = d.getFullYear() + "-" + (d.getMonth()+1) + "-" + d.getDate();
  24. fetch('/fileserver/log/message/log_'+date+'.txt')
  25. .then(response => {
  26. // handle the response
  27. response.text()
  28. .then( result => {
  29. var lines = result.split("\n");
  30. var trace = {
  31. x: [],
  32. y: [],
  33. type: 'scatter'
  34. };
  35. var timex = 1;
  36. for (let line of lines) {
  37. if (line.includes("PostProcessing - Raw")) {
  38. console.log(line);
  39. var value = line.split(" ")[6];
  40. var time = line.split(" ")[0];
  41. console.log("> "+time+" "+value+"\n");
  42. trace.x.push(timex);
  43. timex += 1;
  44. trace.y.push(value);
  45. }
  46. }
  47. console.log(trace);
  48. var data = [trace];
  49. Plotly.newPlot('chart', data);
  50. });
  51. })
  52. .catch(error => {
  53. // handle the error
  54. out.value = "error";
  55. });
  56. </textarea><br />
  57. <button onclick="run();">run</button>
  58. </div>
  59. <script>run();</script>
  60. </body>
  61. </html>