diff options
author | Yves Fischer <yvesf-git@xapek.org> | 2013-04-18 17:34:27 +0200 |
---|---|---|
committer | Yves Fischer <yvesf-git@xapek.org> | 2013-04-18 17:34:27 +0200 |
commit | 87f4134201f0a0840415aab531e32ca714bc7a36 (patch) | |
tree | cf148ecc810f92ca2e4c177498a56130806ed4e4 /datastore-leveldb/wwwroot/lib/flot-0.7/examples/interacting-axes.html | |
parent | 7c8e064216cc672557cbf3892ff090490505e408 (diff) | |
download | ebus-alt-87f4134201f0a0840415aab531e32ca714bc7a36.tar.gz ebus-alt-87f4134201f0a0840415aab531e32ca714bc7a36.zip |
leveldb geht so
Diffstat (limited to 'datastore-leveldb/wwwroot/lib/flot-0.7/examples/interacting-axes.html')
-rw-r--r-- | datastore-leveldb/wwwroot/lib/flot-0.7/examples/interacting-axes.html | 97 |
1 files changed, 97 insertions, 0 deletions
diff --git a/datastore-leveldb/wwwroot/lib/flot-0.7/examples/interacting-axes.html b/datastore-leveldb/wwwroot/lib/flot-0.7/examples/interacting-axes.html new file mode 100644 index 0000000..5b6e3bb --- /dev/null +++ b/datastore-leveldb/wwwroot/lib/flot-0.7/examples/interacting-axes.html @@ -0,0 +1,97 @@ +<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> +<html> + <head> + <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> + <title>Flot Examples</title> + <link href="layout.css" rel="stylesheet" type="text/css"> + <!--[if lte IE 8]><script language="javascript" type="text/javascript" src="../excanvas.min.js"></script><![endif]--> + <script language="javascript" type="text/javascript" src="../jquery.js"></script> + <script language="javascript" type="text/javascript" src="../jquery.flot.js"></script> + </head> + <body> + <h1>Flot Examples</h1> + + <div id="placeholder" style="width:600px;height:300px;"></div> + + <p>With multiple axes, you sometimes need to interact with them. A + simple way to do this is to draw the plot, deduce the axis + placements and insert a couple of divs on top to catch events. + Try clicking an axis.</p> + + <p id="click"></p> + +<script type="text/javascript"> +$(function () { + function generate(start, end, fn) { + var res = []; + for (var i = 0; i <= 100; ++i) { + var x = start + i / 100 * (end - start); + res.push([x, fn(x)]); + } + return res; + } + + var data = [ + { data: generate(0, 10, function (x) { return Math.sqrt(x)}), xaxis: 1, yaxis:1 }, + { data: generate(0, 10, function (x) { return Math.sin(x)}), xaxis: 1, yaxis:2 }, + { data: generate(0, 10, function (x) { return Math.cos(x)}), xaxis: 1, yaxis:3 }, + { data: generate(2, 10, function (x) { return Math.tan(x)}), xaxis: 2, yaxis: 4 } + ]; + + var plot = $.plot($("#placeholder"), + data, + { + xaxes: [ + { position: 'bottom' }, + { position: 'top'} + ], + yaxes: [ + { position: 'left' }, + { position: 'left' }, + { position: 'right' }, + { position: 'left' } + ] + }); + + // now for each axis, create a div + + function getBoundingBoxForAxis(plot, axis) { + var left = axis.box.left, top = axis.box.top, + right = left + axis.box.width, bottom = top + axis.box.height; + + // some ticks may stick out, enlarge the box to encompass all ticks + var cls = axis.direction + axis.n + 'Axis'; + plot.getPlaceholder().find('.' + cls + ' .tickLabel').each(function () { + var pos = $(this).position(); + left = Math.min(pos.left, left); + top = Math.min(pos.top, top); + right = Math.max(Math.round(pos.left) + $(this).outerWidth(), right); + bottom = Math.max(Math.round(pos.top) + $(this).outerHeight(), bottom); + }); + + return { left: left, top: top, width: right - left, height: bottom - top }; + } + + $.each(plot.getAxes(), function (i, axis) { + if (!axis.show) + return; + + var box = getBoundingBoxForAxis(plot, axis); + + $('<div class="axisTarget" style="position:absolute;left:' + box.left + 'px;top:' + box.top + 'px;width:' + box.width + 'px;height:' + box.height + 'px"></div>') + .data('axis.direction', axis.direction) + .data('axis.n', axis.n) + .css({ backgroundColor: "#f00", opacity: 0, cursor: "pointer" }) + .appendTo(plot.getPlaceholder()) + .hover( + function () { $(this).css({ opacity: 0.10 }) }, + function () { $(this).css({ opacity: 0 }) } + ) + .click(function () { + $("#click").text("You clicked the " + axis.direction + axis.n + "axis!") + }); + }); +}); +</script> + </body> +</html> |