forked from rfunduk/flot
/
interacting.html
68 lines (58 loc) · 2.34 KB
/
interacting.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
<!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="interacting_files/layout.css" rel="stylesheet" type="text/css">
<!--[if IE]><script language="javascript" type="text/javascript" src="../excanvas.pack.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>Try hovering or clicking on the plot above. <span id="result"></span></p>
<script id="source" language="javascript" type="text/javascript">
$(function () {
var d1 = [];
for (var i = 0; i < 14; i += 0.5)
d1.push( { x: i, y: Math.sin(i) } );
var d2 = [];
for (var i = 0; i < 14; i += 0.5)
d2.push( { x: i, y: Math.cos(i) } );
plot = $.plot($("#placeholder"), [ { data: d1, label: "Yellow" },
{ data: d2, label: "Blue" } ], {
hints: {
show: true,
hintFormatter: function( datapoint ) {
hintStr = "";
for( var key in datapoint ) {
if( key[0] == '_' ) { continue; } // skip internal members
hintStr += "<strong>" + key + ":</strong> " +
datapoint[key].toFixed(2) + "<br/>";
}
return hintStr;
}
},
points: { show: true },
lines: { show: true },
legend: { position: 'sw' },
grid: {
clickable: true,
hoverable: true,
hoverFill: '#444',
hoverRadius: 5
}
});
$("#placeholder").bind("plotclick", function (e, pos) {
if (!pos.selected) { return; }
plot.highlightSelected( pos.selected );
x = pos.selected.x.toFixed(2);
y = pos.selected.y.toFixed(2);
$("#result").text('You clicked on (' + x + ', ' + y + ')');
});
$("#placeholder").bind("plotmousemove", function (e, pos) {
if (!pos.selected) { return; }
plot.highlightSelected( pos.selected );
});
});
</script>
</body></html>