index.html 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
  2. <html>
  3. <head>
  4. <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  5. <title>Flot Examples: Navigation</title>
  6. <link href="../examples.css" rel="stylesheet" type="text/css">
  7. <style type="text/css">
  8. #placeholder .button {
  9. position: absolute;
  10. cursor: pointer;
  11. }
  12. #placeholder div.button {
  13. font-size: smaller;
  14. color: #999;
  15. background-color: #eee;
  16. padding: 2px;
  17. }
  18. .message {
  19. padding-left: 50px;
  20. font-size: smaller;
  21. }
  22. </style>
  23. <script language="javascript" type="text/javascript" src="../../source/jquery.js"></script>
  24. <script language="javascript" type="text/javascript" src="../../lib/jquery.event.drag.js"></script>
  25. <script language="javascript" type="text/javascript" src="../../lib/jquery.mousewheel.js"></script>
  26. <script language="javascript" type="text/javascript" src="../../source/jquery.canvaswrapper.js"></script>
  27. <script language="javascript" type="text/javascript" src="../../source/jquery.colorhelpers.js"></script>
  28. <script language="javascript" type="text/javascript" src="../../source/jquery.flot.js"></script>
  29. <script language="javascript" type="text/javascript" src="../../source/jquery.flot.saturated.js"></script>
  30. <script language="javascript" type="text/javascript" src="../../source/jquery.flot.browser.js"></script>
  31. <script language="javascript" type="text/javascript" src="../../source/jquery.flot.drawSeries.js"></script>
  32. <script language="javascript" type="text/javascript" src="../../source/jquery.flot.errorbars.js"></script>
  33. <script language="javascript" type="text/javascript" src="../../source/jquery.flot.uiConstants.js"></script>
  34. <script language="javascript" type="text/javascript" src="../../source/jquery.flot.logaxis.js"></script>
  35. <script language="javascript" type="text/javascript" src="../../source/jquery.flot.symbol.js"></script>
  36. <script language="javascript" type="text/javascript" src="../../source/jquery.flot.flatdata.js"></script>
  37. <script language="javascript" type="text/javascript" src="../../source/jquery.flot.navigate.js"></script>
  38. <script language="javascript" type="text/javascript" src="../../source/jquery.flot.fillbetween.js"></script>
  39. <script language="javascript" type="text/javascript" src="../../source/jquery.flot.stack.js"></script>
  40. <script language="javascript" type="text/javascript" src="../../source/jquery.flot.touchNavigate.js"></script>
  41. <script language="javascript" type="text/javascript" src="../../source/jquery.flot.hover.js"></script>
  42. <script language="javascript" type="text/javascript" src="../../source/jquery.flot.touch.js"></script>
  43. <script language="javascript" type="text/javascript" src="../../source/jquery.flot.time.js"></script>
  44. <script language="javascript" type="text/javascript" src="../../source/jquery.flot.axislabels.js"></script>
  45. <script language="javascript" type="text/javascript" src="../../source/jquery.flot.selection.js"></script>
  46. <script language="javascript" type="text/javascript" src="../../source/jquery.flot.composeImages.js"></script>
  47. <script language="javascript" type="text/javascript" src="../../source/jquery.flot.legend.js"></script>
  48. <script type="text/javascript">
  49. $(function() {
  50. // generate data set from a parametric function with a fractal look
  51. function sumf(f, t, m) {
  52. var res = 0;
  53. for (var i = 1; i < m; ++i) {
  54. res += f(i * i * t) / (i * i);
  55. }
  56. return res;
  57. }
  58. var d1 = [];
  59. for (var t = 0; t <= 2 * Math.PI; t += 0.01) {
  60. d1.push([sumf(Math.cos, t, 10), sumf(Math.sin, t, 10)]);
  61. }
  62. var data = [ d1 ],
  63. placeholder = $("#placeholder");
  64. var plot = $.plot(placeholder, data, {
  65. series: {
  66. lines: {
  67. show: true
  68. },
  69. shadowSize: 0
  70. },
  71. xaxis: {
  72. zoomRange: [0.1, 10],
  73. panRange: [-10, 10],
  74. gridLines: true
  75. },
  76. yaxis: {
  77. zoomRange: [0.1, 10],
  78. panRange: [-10, 10],
  79. gridLines: true,
  80. autoScale: 'exact'
  81. },
  82. zoom: {
  83. interactive: true
  84. },
  85. pan: {
  86. interactive: true
  87. }
  88. });
  89. // show pan/zoom messages to illustrate events
  90. placeholder.bind("plotpan", function (event, plot) {
  91. var axes = plot.getAxes();
  92. $(".message").html("Panning to x: " + axes.xaxis.min.toFixed(2)
  93. + " &ndash; " + axes.xaxis.max.toFixed(2)
  94. + " and y: " + axes.yaxis.min.toFixed(2)
  95. + " &ndash; " + axes.yaxis.max.toFixed(2));
  96. });
  97. placeholder.bind("plotzoom", function (event, plot) {
  98. var axes = plot.getAxes();
  99. $(".message").html("Zooming to x: " + axes.xaxis.min.toFixed(2)
  100. + " &ndash; " + axes.xaxis.max.toFixed(2)
  101. + " and y: " + axes.yaxis.min.toFixed(2)
  102. + " &ndash; " + axes.yaxis.max.toFixed(2));
  103. });
  104. // add zoom out button
  105. $("<div class='button' style='right:20px;top:20px'>zoom out</div>")
  106. .appendTo(placeholder)
  107. .click(function (event) {
  108. event.preventDefault();
  109. plot.zoomOut();
  110. });
  111. // and add panning buttons
  112. // little helper for taking the repetitive work out of placing
  113. // panning arrows
  114. function addArrow(dir, right, top, offset) {
  115. $("<img class='button' src='arrow-" + dir + ".gif' style='right:" + right + "px;top:" + top + "px'>")
  116. .appendTo(placeholder)
  117. .click(function (e) {
  118. e.preventDefault();
  119. plot.pan(offset);
  120. });
  121. }
  122. addArrow("left", 55, 60, { left: -100 });
  123. addArrow("right", 25, 60, { left: 100 });
  124. addArrow("up", 40, 45, { top: -100 });
  125. addArrow("down", 40, 75, { top: 100 });
  126. // Add the Flot version string to the footer
  127. $("#footer").prepend("Flot " + $.plot.version + " &ndash; ");
  128. });
  129. </script>
  130. </head>
  131. <body>
  132. <div id="header">
  133. <h2>Navigation</h2>
  134. </div>
  135. <div id="content">
  136. <div class="demo-container">
  137. <div id="placeholder" class="demo-placeholder"></div>
  138. </div>
  139. <p class="message"></p>
  140. <p>With the navigate plugin it is easy to add panning and zooming. Drag to pan, double click to zoom (or use the mouse scrollwheel).</p>
  141. <p>The plugin fires events (useful for synchronizing several plots) and adds a couple of public methods so you can easily build a little user interface around it, like the little buttons at the top right in the plot.</p>
  142. </div>
  143. <div id="footer">
  144. Copyright &copy; 2007 - 2014 IOLA and Ole Laursen
  145. </div>
  146. </body>
  147. </html>