123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177 |
- <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
- <html>
- <head>
- <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
- <title>Flot Examples: Navigation</title>
- <link href="../examples.css" rel="stylesheet" type="text/css">
- <style type="text/css">
- #placeholder .button {
- position: absolute;
- cursor: pointer;
- }
- #placeholder div.button {
- font-size: smaller;
- color: #999;
- background-color: #eee;
- padding: 2px;
- }
- .message {
- padding-left: 50px;
- font-size: smaller;
- }
- </style>
- <script language="javascript" type="text/javascript" src="../../source/jquery.js"></script>
- <script language="javascript" type="text/javascript" src="../../lib/jquery.event.drag.js"></script>
- <script language="javascript" type="text/javascript" src="../../lib/jquery.mousewheel.js"></script>
- <script language="javascript" type="text/javascript" src="../../source/jquery.canvaswrapper.js"></script>
- <script language="javascript" type="text/javascript" src="../../source/jquery.colorhelpers.js"></script>
- <script language="javascript" type="text/javascript" src="../../source/jquery.flot.js"></script>
- <script language="javascript" type="text/javascript" src="../../source/jquery.flot.saturated.js"></script>
- <script language="javascript" type="text/javascript" src="../../source/jquery.flot.browser.js"></script>
- <script language="javascript" type="text/javascript" src="../../source/jquery.flot.drawSeries.js"></script>
- <script language="javascript" type="text/javascript" src="../../source/jquery.flot.errorbars.js"></script>
- <script language="javascript" type="text/javascript" src="../../source/jquery.flot.uiConstants.js"></script>
- <script language="javascript" type="text/javascript" src="../../source/jquery.flot.logaxis.js"></script>
- <script language="javascript" type="text/javascript" src="../../source/jquery.flot.symbol.js"></script>
- <script language="javascript" type="text/javascript" src="../../source/jquery.flot.flatdata.js"></script>
- <script language="javascript" type="text/javascript" src="../../source/jquery.flot.navigate.js"></script>
- <script language="javascript" type="text/javascript" src="../../source/jquery.flot.fillbetween.js"></script>
- <script language="javascript" type="text/javascript" src="../../source/jquery.flot.stack.js"></script>
- <script language="javascript" type="text/javascript" src="../../source/jquery.flot.touchNavigate.js"></script>
- <script language="javascript" type="text/javascript" src="../../source/jquery.flot.hover.js"></script>
- <script language="javascript" type="text/javascript" src="../../source/jquery.flot.touch.js"></script>
- <script language="javascript" type="text/javascript" src="../../source/jquery.flot.time.js"></script>
- <script language="javascript" type="text/javascript" src="../../source/jquery.flot.axislabels.js"></script>
- <script language="javascript" type="text/javascript" src="../../source/jquery.flot.selection.js"></script>
- <script language="javascript" type="text/javascript" src="../../source/jquery.flot.composeImages.js"></script>
- <script language="javascript" type="text/javascript" src="../../source/jquery.flot.legend.js"></script>
- <script type="text/javascript">
- $(function() {
- // generate data set from a parametric function with a fractal look
- function sumf(f, t, m) {
- var res = 0;
- for (var i = 1; i < m; ++i) {
- res += f(i * i * t) / (i * i);
- }
- return res;
- }
- var d1 = [];
- for (var t = 0; t <= 2 * Math.PI; t += 0.01) {
- d1.push([sumf(Math.cos, t, 10), sumf(Math.sin, t, 10)]);
- }
- var data = [ d1 ],
- placeholder = $("#placeholder");
- var plot = $.plot(placeholder, data, {
- series: {
- lines: {
- show: true
- },
- shadowSize: 0
- },
- xaxis: {
- zoomRange: [0.1, 10],
- panRange: [-10, 10],
- gridLines: true
- },
- yaxis: {
- zoomRange: [0.1, 10],
- panRange: [-10, 10],
- gridLines: true,
- autoScale: 'exact'
- },
- zoom: {
- interactive: true
- },
- pan: {
- interactive: true
- }
- });
- // show pan/zoom messages to illustrate events
- placeholder.bind("plotpan", function (event, plot) {
- var axes = plot.getAxes();
- $(".message").html("Panning to x: " + axes.xaxis.min.toFixed(2)
- + " – " + axes.xaxis.max.toFixed(2)
- + " and y: " + axes.yaxis.min.toFixed(2)
- + " – " + axes.yaxis.max.toFixed(2));
- });
- placeholder.bind("plotzoom", function (event, plot) {
- var axes = plot.getAxes();
- $(".message").html("Zooming to x: " + axes.xaxis.min.toFixed(2)
- + " – " + axes.xaxis.max.toFixed(2)
- + " and y: " + axes.yaxis.min.toFixed(2)
- + " – " + axes.yaxis.max.toFixed(2));
- });
- // add zoom out button
- $("<div class='button' style='right:20px;top:20px'>zoom out</div>")
- .appendTo(placeholder)
- .click(function (event) {
- event.preventDefault();
- plot.zoomOut();
- });
- // and add panning buttons
- // little helper for taking the repetitive work out of placing
- // panning arrows
- function addArrow(dir, right, top, offset) {
- $("<img class='button' src='arrow-" + dir + ".gif' style='right:" + right + "px;top:" + top + "px'>")
- .appendTo(placeholder)
- .click(function (e) {
- e.preventDefault();
- plot.pan(offset);
- });
- }
- addArrow("left", 55, 60, { left: -100 });
- addArrow("right", 25, 60, { left: 100 });
- addArrow("up", 40, 45, { top: -100 });
- addArrow("down", 40, 75, { top: 100 });
- // Add the Flot version string to the footer
- $("#footer").prepend("Flot " + $.plot.version + " – ");
- });
- </script>
- </head>
- <body>
- <div id="header">
- <h2>Navigation</h2>
- </div>
- <div id="content">
- <div class="demo-container">
- <div id="placeholder" class="demo-placeholder"></div>
- </div>
- <p class="message"></p>
- <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>
- <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>
- </div>
- <div id="footer">
- Copyright © 2007 - 2014 IOLA and Ole Laursen
- </div>
- </body>
- </html>
|