graph.html 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  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. var date = getFullYear() + "-" + (getMonth()+1) + "-" + getDate();
  23. fetch('/fileserver/log/message/log_'+date+'.txt')
  24. .then(response => {
  25. // handle the response
  26. response.text()
  27. .then( result => {
  28. var lines = result.split("\n");
  29. var trace = {
  30. x: [],
  31. y: [],
  32. type: 'scatter'
  33. };
  34. var timex = 1;
  35. for (let line of lines) {
  36. if (line.includes("PostProcessing - Raw")) {
  37. console.log(line);
  38. var value = line.split(" ")[6];
  39. var time = line.split(" ")[0];
  40. console.log("> "+time+" "+value+"\n");
  41. if (value<1000) {
  42. trace.x.push(timex);
  43. timex += 1;
  44. trace.y.push(value);
  45. }
  46. }
  47. }
  48. console.log(trace);
  49. var data = [trace];
  50. Plotly.newPlot('chart', data);
  51. });
  52. })
  53. .catch(error => {
  54. // handle the error
  55. out.value = "error";
  56. });
  57. </textarea><br />
  58. <button onclick="run();">run</button>
  59. </div>
  60. <script>run();</script>
  61. </body>
  62. </html>