PHP/JavaScript webapp to analyse spending habits
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

annotating.html 2.7KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
  2. <html>
  3. <head>
  4. <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  5. <title>Flot Examples</title>
  6. <link href="layout.css" rel="stylesheet" type="text/css"></link>
  7. <!--[if IE]><script language="javascript" type="text/javascript" src="../excanvas.min.js"></script><![endif]-->
  8. <script language="javascript" type="text/javascript" src="../jquery.js"></script>
  9. <script language="javascript" type="text/javascript" src="../jquery.flot.js"></script>
  10. </head>
  11. <body>
  12. <h1>Flot Examples</h1>
  13. <div id="placeholder" style="width:600px;height:300px;"></div>
  14. <p>Flot has support for simple background decorations such as
  15. lines and rectangles. They can be useful for marking up certain
  16. areas. You can easily add any HTML you need with standard DOM
  17. manipulation, e.g. for labels. For drawing custom shapes there is
  18. also direct access to the canvas.</p>
  19. <script id="source" language="javascript" type="text/javascript">
  20. $(function () {
  21. // generate a dataset
  22. var d1 = [];
  23. for (var i = 0; i < 20; ++i)
  24. d1.push([i, Math.sin(i)]);
  25. var data = [{ data: d1, label: "Pressure", color: "#333" }];
  26. // setup background areas
  27. var markings = [
  28. { color: '#f6f6f6', yaxis: { from: 1 } },
  29. { color: '#f6f6f6', yaxis: { to: -1 } },
  30. { color: '#000', lineWidth: 1, xaxis: { from: 2, to: 2 } },
  31. { color: '#000', lineWidth: 1, xaxis: { from: 8, to: 8 } }
  32. ];
  33. var placeholder = $("#placeholder");
  34. // plot it
  35. var plot = $.plot(placeholder, data, {
  36. bars: { show: true, barWidth: 0.5, fill: 0.9 },
  37. xaxis: { ticks: [], autoscaleMargin: 0.02 },
  38. yaxis: { min: -2, max: 2 },
  39. grid: { markings: markings }
  40. });
  41. // add labels
  42. var o;
  43. o = plot.pointOffset({ x: 2, y: -1.2});
  44. // we just append it to the placeholder which Flot already uses
  45. // for positioning
  46. placeholder.append('<div style="position:absolute;left:' + (o.left + 4) + 'px;top:' + o.top + 'px;color:#666;font-size:smaller">Warming up</div>');
  47. o = plot.pointOffset({ x: 8, y: -1.2});
  48. placeholder.append('<div style="position:absolute;left:' + (o.left + 4) + 'px;top:' + o.top + 'px;color:#666;font-size:smaller">Actual measurements</div>');
  49. // draw a little arrow on top of the last label to demonstrate
  50. // canvas drawing
  51. var ctx = plot.getCanvas().getContext("2d");
  52. ctx.beginPath();
  53. o.left += 4;
  54. ctx.moveTo(o.left, o.top);
  55. ctx.lineTo(o.left, o.top - 10);
  56. ctx.lineTo(o.left + 10, o.top - 5);
  57. ctx.lineTo(o.left, o.top);
  58. ctx.fillStyle = "#000";
  59. ctx.fill();
  60. });
  61. </script>
  62. </body>
  63. </html>