Simon
unread,Apr 22, 2011, 1:41:29 PM4/22/11Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to Flot graphs
Hi all,
I tried to add a [mousedown] [mouseup] event to the plot DIV, while
also enable [plotpan] and [plotclick] events. how can I make them work
together? I mean in my following code, i simply bind mousedown to the
plot holder, it cant work if i click on the plot, only work on the
label area.
<html>
<head>
<title>A Test Page</title>
<!-- JQUERY/FLOT LIB FILES -->
<!--[if lte IE 8]><script language="javascript" type="text/javascript"
src="lib/jquery/excanvas.min.js"></script><![endif]-->
<script language="javascript" type="text/javascript"
src="lib/jquery/jquery.js"></script>
<script language="javascript" type="text/javascript"
src="lib/jquery/jquery.flot.js"></script>
<script language="javascript" type="text/javascript"
src="lib/jquery/jquery.flot.navigate.js"></script>
<script language="javascript" type="text/javascript"
src="lib/jquery/jquery.flot.symbol.js"></script>
<script type="text/javascript">
$(function () {
// raw data
d1 = [ [ 0, 2 ], [ 1, 2 ] ];
d2 = [ [ 2, 2 ], [ 4, 2 ] ];
//event data
dataSeries = [{
color : "rgb(0, 0, 0)",
data : d1,
label : "point1",
points : {
show : true,
symbol : "square",
radius : 4
}
}, {
color : "rgb(255, 100, 123)",
data : d2,
label : "point2",
points : {
show : true,
radius : 4
}
}];
//container for graph
var placeholder = $("#flotDiv");
if (placeholder.length <= 0) {
return;
}
options= {//graph options
pan : {
interactive : true
},
grid: {
clickable:true
}
};
$.plot(placeholder, dataSeries, options);
placeholder.bind("mousedown",function(e){
alert("mousedown");
})
/*
placeholder.bind("plotclick",function(event, pos, item){
alert("plotclick");
});
*/
});
</script>
</head>
<body>
<!-- SLD PLOT -->
<div id="flotDiv" style="width: 600px; height: 300px; padding:
0px; position: relative;"></div>
</body>
</html>
in the above codes, mousedown event doesnt work because i enable plot
pannable; if i disable plotpan, then mousedown will work; and if I
enable plotclick, still only mousedown works; i know that both plotpan
and plotclick are relevant to "mousedown" event, so there is a
confliction among. however, i need find a way to make them work
together.
appreciate any comments!