graph_data.html 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  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. <select id="selector" onchange="document.location.href=document.location.href.split('#')[0]+'#'+this.value;run();"></select>
  20. <button onclick="document.getElementById('editor').hidden = false; this.hidden = true;" >Editor</button>
  21. <div id='editor' hidden='true'>
  22. <textarea id="cnsl">
  23. var hash = window.location.hash;
  24. console.log (hash);
  25. var d = new Date();
  26. var options="<option>Please Select...</option>";
  27. for (var i=0; i<27; i++) {
  28. var currentDate = new Date(d-i*60*60*24*1000);
  29. var option = currentDate.getFullYear()+"-"+(currentDate.getMonth()+1)+"-"+currentDate.getDate()
  30. options += "<option>"+option+"</option>\n";
  31. }
  32. document.getElementById("selector").innerHTML = options;
  33. var dateString = d.getFullYear() + "-" + (d.getMonth()+1) + "-" + d.getDate();
  34. if (hash!="") {
  35. dateString = hash.substring(1);
  36. }
  37. fetch('/fileserver/log/message/log_'+dateString+'.txt')
  38. .then(response => {
  39. // handle the response
  40. if (response.status == 404) {
  41. alert("no log data available for "+dateString);
  42. }
  43. response.text()
  44. .then( result => {
  45. var lines = result.split("\n");
  46. var trace = {
  47. x: [],
  48. y: [],
  49. type: 'scatter'
  50. };
  51. var timex = 1;
  52. for (let line of lines) {
  53. if (line.includes("PostProcessing - Raw")) {
  54. console.log(line);
  55. var value = line.split(" ")[6];
  56. var time = line.split(" ")[0];
  57. console.log("> "+time+" "+value+"\n");
  58. if (value<1000) {
  59. trace.x.push(timex);
  60. timex += 1;
  61. trace.y.push(value);
  62. }
  63. }
  64. }
  65. console.log(trace);
  66. var data = [trace];
  67. Plotly.newPlot('chart', data);
  68. });
  69. }).catch((error) => {
  70. // handle the error
  71. console.log(error);
  72. alert("test");
  73. });
  74. </textarea><br />
  75. <button onclick="run();">run</button>
  76. </div>
  77. <script>run();</script>
  78. </body>
  79. </html>