charts.html 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <meta charset="utf-8">
  5. <title>Charts</title>
  6. </head>
  7. <body style="font-size:30px; font-family: Arial;">
  8. <!-- Page -->
  9. <div style="position:absolute; width:100%; height:100%; top:0px; left:0px; overflow: hidden;">
  10. <!-- Canvas -->
  11. <canvas id="canvas" style="position:absolute; width:100%; height:100%; top:0px; left:0px;"></canvas>
  12. </div>
  13. <!-- Code -->
  14. <script type="text/javascript" src="../build/escher.js"></script>
  15. <script type="text/javascript">
  16. // Canvas
  17. var canvas = document.getElementById("canvas");
  18. canvas.width = window.innerWidth;
  19. canvas.height = window.innerHeight;
  20. // Resize canvas on window resize
  21. window.onresize = function()
  22. {
  23. canvas.width = window.innerWidth;
  24. canvas.height = window.innerHeight;
  25. };
  26. var group = new Escher.Object2D();
  27. // Gauge data
  28. var gauge = new Escher.Gauge();
  29. gauge.radius = 100;
  30. gauge.position.set(100, 50);
  31. gauge.draggable = true;
  32. group.add(gauge);
  33. // Graph data
  34. var graph = new Escher.Graph();
  35. graph.box.min.set(-500, -50);
  36. graph.box.max.set(500, 50);
  37. graph.position.set(300, 400);
  38. graph.draggable = true;
  39. group.add(graph);
  40. Escher.Helpers.boxResizeTool(graph);
  41. for(var i = 0; i < 300; i++)
  42. {
  43. graph.data.push(Math.random() * 9 + 1);
  44. }
  45. var scatter = new Escher.ScatterGraph();
  46. scatter.radius = 5;
  47. scatter.box.min.set(-500, -50);
  48. scatter.box.max.set(500, 50);
  49. scatter.position.set(800, 600);
  50. scatter.draggable = true;
  51. group.add(scatter);
  52. Escher.Helpers.boxResizeTool(scatter);
  53. for(var i = 0; i < 100; i++)
  54. {
  55. scatter.data.push((Math.cos(i / 3) + 1) * 3);
  56. }
  57. var scatterLine = new Escher.ScatterGraph();
  58. scatterLine.radius = 5;
  59. scatterLine.box.min.set(-500, -50);
  60. scatterLine.box.max.set(500, 50);
  61. scatterLine.position.set(800, 600);
  62. scatterLine.draggable = true;
  63. scatterLine.drawLine = true;
  64. group.add(scatterLine);
  65. Escher.Helpers.boxResizeTool(scatterLine);
  66. for(var i = 0; i < 100; i++)
  67. {
  68. scatterLine.data.push((Math.cos(i / 3) + 1) * 3);
  69. }
  70. var bar = new Escher.BarGraph();
  71. bar.box.min.set(-500, -50);
  72. bar.box.max.set(500, 50);
  73. bar.position.set(500, 1000);
  74. bar.draggable = true;
  75. group.add(bar);
  76. Escher.Helpers.boxResizeTool(bar);
  77. for(var i = 0; i < 100; i++)
  78. {
  79. bar.data.push((Math.cos(i / 3) + 1) * 3);
  80. }
  81. var pieData = [
  82. {value: 10, fillStyle: new Escher.ColorStyle("#FD5748"), strokeStyle: null},
  83. {value: 15, fillStyle: new Escher.ColorStyle("#23AB48"), strokeStyle: null},
  84. {value: 5, fillStyle: new Escher.ColorStyle("#6285F8"), strokeStyle: null}
  85. ];
  86. var pie = new Escher.PieChart(pieData);
  87. pie.radius = 100;
  88. pie.position.set(1000, 1000);
  89. pie.draggable = true;
  90. group.add(pie);
  91. var pie = new Escher.PieChart(pieData);
  92. pie.sliceSize = true;
  93. pie.radius = 200;
  94. pie.position.set(500, 800);
  95. pie.draggable = true;
  96. group.add(pie);
  97. var path = new Path2D("M10 10 h 80 v 80 h -80 Z");
  98. var shape = new Escher.Path(path);
  99. group.add(shape);
  100. var viewport = new Escher.Viewport(canvas);
  101. var renderer = new Escher.Renderer(canvas);
  102. renderer.createRenderLoop(group, viewport);
  103. </script>
  104. </body>
  105. </html>