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.

navigate.html 4.0KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  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. <script language="javascript" type="text/javascript" src="../jquery.flot.navigate.js"></script>
  11. <style>
  12. #placeholder .button {
  13. position: absolute;
  14. cursor: pointer;
  15. }
  16. #placeholder div.button {
  17. font-size: smaller;
  18. color: #999;
  19. background-color: #eee;
  20. padding: 2px;
  21. }
  22. .message {
  23. padding-left: 50px;
  24. font-size: smaller;
  25. }
  26. </style>
  27. </head>
  28. <body>
  29. <h1>Flot Examples</h1>
  30. <div id="placeholder" style="width:600px;height:300px;"></div>
  31. <p class="message"></p>
  32. <p>With the navigate plugin it is easy to add panning and zooming.
  33. Drag to pan, double click to zoom (or use the mouse scrollwheel).</p>
  34. <p>The plugin fires events (useful for synchronizing several
  35. plots) and adds a couple of public methods so you can easily build
  36. a little user interface around it, like the little buttons at the
  37. top right in the plot.</p>
  38. <script id="source" language="javascript" type="text/javascript">
  39. $(function () {
  40. // generate data set from a parametric function with a fractal
  41. // look
  42. function sumf(f, t, m) {
  43. var res = 0;
  44. for (var i = 1; i < m; ++i)
  45. res += f(i * i * t) / (i * i);
  46. return res;
  47. }
  48. var d1 = [];
  49. for (var t = 0; t <= 2 * Math.PI; t += 0.01)
  50. d1.push([sumf(Math.cos, t, 10), sumf(Math.sin, t, 10)]);
  51. var data = [ d1 ];
  52. var placeholder = $("#placeholder");
  53. var options = {
  54. series: { lines: { show: true }, shadowSize: 0 },
  55. xaxis: { zoomRange: [0.1, 10], panRange: [-10, 10] },
  56. yaxis: { zoomRange: [0.1, 10], panRange: [-10, 10] },
  57. zoom: {
  58. interactive: true
  59. },
  60. pan: {
  61. interactive: true
  62. }
  63. };
  64. var plot = $.plot(placeholder, data, options);
  65. // show pan/zoom messages to illustrate events
  66. placeholder.bind('plotpan', function (event, plot) {
  67. var axes = plot.getAxes();
  68. $(".message").html("Panning to x: " + axes.xaxis.min.toFixed(2)
  69. + " &ndash; " + axes.xaxis.max.toFixed(2)
  70. + " and y: " + axes.yaxis.min.toFixed(2)
  71. + " &ndash; " + axes.yaxis.max.toFixed(2));
  72. });
  73. placeholder.bind('plotzoom', function (event, plot) {
  74. var axes = plot.getAxes();
  75. $(".message").html("Zooming to x: " + axes.xaxis.min.toFixed(2)
  76. + " &ndash; " + axes.xaxis.max.toFixed(2)
  77. + " and y: " + axes.yaxis.min.toFixed(2)
  78. + " &ndash; " + axes.yaxis.max.toFixed(2));
  79. });
  80. // add zoom out button
  81. $('<div class="button" style="right:20px;top:20px">zoom out</div>').appendTo(placeholder).click(function (e) {
  82. e.preventDefault();
  83. plot.zoomOut();
  84. });
  85. // and add panning buttons
  86. // little helper for taking the repetitive work out of placing
  87. // panning arrows
  88. function addArrow(dir, right, top, offset) {
  89. $('<img class="button" src="arrow-' + dir + '.gif" style="right:' + right + 'px;top:' + top + 'px">').appendTo(placeholder).click(function (e) {
  90. e.preventDefault();
  91. plot.pan(offset);
  92. });
  93. }
  94. addArrow('left', 55, 60, { left: -100 });
  95. addArrow('right', 25, 60, { left: 100 });
  96. addArrow('up', 40, 45, { top: -100 });
  97. addArrow('down', 40, 75, { top: 100 });
  98. });
  99. </script>
  100. </body>
  101. </html>