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 click="document.getElementById('editor').hidden = false; this.hidden = true;" >Editor</button>
  20. <div id='editor' hidden='true'>
  21. <textarea id="cnsl">
  22. fetch('/fileserver/log/message/log_2022-10-15.txt')
  23. .then(response => {
  24. // handle the response
  25. response.text()
  26. .then( result => {
  27. var lines = result.split("\n");
  28. var trace = {
  29. x: [],
  30. y: [],
  31. type: 'scatter'
  32. };
  33. var timex = 1;
  34. for (let line of lines) {
  35. if (line.includes("PostProcessing - Raw")) {
  36. console.log(line);
  37. var value = line.split(" ")[6];
  38. var time = line.split(" ")[0];
  39. console.log("> "+time+" "+value+"\n");
  40. if (value<1000) {
  41. trace.x.push(timex);
  42. timex += 1;
  43. trace.y.push(value);
  44. }
  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>