metrics.html 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <meta charset="UTF-8">
  5. <style>
  6. h1 { text-align: center; }
  7. .graph { margin: 0 auto; width: 900px; height: 500px; }
  8. #select { text-align: center; }
  9. .choices { text-align: center; }
  10. </style>
  11. <script src="js/jquery-1.10.2.min.js"></script>
  12. <script src="js/jquery.flot.js"></script>
  13. <script>
  14. function plot(data, measurements, plotElem) {
  15. var bits = { "total": [] };
  16. for (var i = 0; i < data.length; i++) {
  17. $.each(data[i][measurements], function(key, val) {
  18. bits[key] = bits[key] || new Array();
  19. bits[key].push([data[i].frame, val]);
  20. });
  21. bits["total"].push([data[i].frame, data[i].total]);
  22. }
  23. var color = 0;
  24. var datasets = new Object();
  25. $.each(bits, function(key, val) {
  26. datasets[key] = { label: key, data: val, color: color };
  27. color++;
  28. });
  29. var choices = $("<div>");
  30. choices.appendTo(plotElem);
  31. choices.addClass("choices");
  32. $.each(datasets, function(key, val) {
  33. choices.append("<input type=checkbox name=" + key +
  34. " checked id=choice_" + key + ">" +
  35. "<label for=choice_" + key + ">" +
  36. val.label +
  37. "</label>");
  38. });
  39. var graph = $("<div>");
  40. graph.appendTo(plotElem);
  41. graph.addClass("graph");
  42. function plot_choices() {
  43. var data = [];
  44. choices.find("input:checked").each(function() {
  45. var key = $(this).attr("name");
  46. if (key && datasets[key]) {
  47. data.push(datasets[key]);
  48. }
  49. });
  50. var options = {
  51. yaxis: { min: 0 },
  52. xaxis: { tickDecimals: 0 }
  53. };
  54. $.plot(graph, data, options);
  55. }
  56. choices.find("input").on("click", plot_choices);
  57. plot_choices();
  58. }
  59. $(function() {
  60. $("#filebox").on("change", function() {
  61. console.log(this.files);
  62. var file = this.files[0];
  63. var reader = new FileReader();
  64. reader.onload = function (e) {
  65. var data = JSON.parse(e.target.result);
  66. plot(data, "technique", $("#techniques"));
  67. plot(data, "plane", $("#planes"));
  68. };
  69. console.log(reader);
  70. reader.readAsText(file);
  71. });
  72. });
  73. </script>
  74. </head>
  75. <body>
  76. <div id="header">
  77. <h1>Bitrate Metrics</h1>
  78. </div>
  79. <div id="select">
  80. <input type="file" id="filebox">
  81. </div>
  82. <div id="content">
  83. <div id="techniques"></div>
  84. <hr>
  85. <div id="planes"></div>
  86. </div>
  87. </body>
  88. </html>