Current File : //home/tradevaly/www/node_modules/flot.curvedlines/tests/testTooltip.htm |
<hmtl>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>CurvedLines Plugin for flot</title>
<script language="javascript" type="text/javascript" src="../flot/jquery.min.js"></script>
<!--[if lte IE 8]><script language="javascript" type="text/javascript" src="flot/excanvas.min.js"></script><![endif]-->
<script language="javascript" type="text/javascript" src="../flot/jquery.flot.min.js"></script>
<script language="JavaScript" type="text/javascript" src="../curvedLines.js"></script>
<script language="JavaScript" type="text/javascript" src="_TestSetup.js"></script>
<link rel="stylesheet" type="text/css" href="_TestSetup.css"></link>
</head>
<body>
<div id="placeholder" style="width: 800;height: 400;"></div>
<div id="parameters" style="width: 800"></div>
<script language="javascript" type="text/javascript">
$(function () {
//data
var data = [
{
label: [["Label 1"], ["Label 2"], ["Label 3"]],
data: [[10, 10], [20, 14], [30, 12]],
},
{
label: [["Label 1_2"], ["Label 2_2"], ["Label 3_2"]],
data: [[8, 12], [22, 18], [25, 12]],
}
];
//general plot options
var options = {
series: {curvedLines : {
active : true,
},
lines: { lineWidth: 5},
points: { radius: 4 }
},
legend: { show: false },
grid: { borderWidth: 2, clickable: true, hoverable: true, autoHighlight: true}
};
//curved line paramters
var defaultParameters = {
apply : true,
legacyOverride : true
}
//plot function
function replot(parameters) {
$.plot($("#placeholder"), [
{
data: data[0].data,
label: data[0].label,
curvedLines: defaultParameters,
clickable: false,
hoverable: false
},
{
data: data[0].data,
label: data[0].label,
points: {show : true}
},
{
data: data[1].data,
label: data[1].label,
lines: {show : true},
points: {show : true}
}
], options);
}
//combine everything
TestSetup($("#parameters"), defaultParameters, [replot]);
var placeholder = $("#placeholder");
function showTooltip(x, y, contents) {
$('<div id="tooltip">' + contents + '</div>').css( {
position: 'absolute',
display: 'none',
top: y - 32,
left: x,
border: 'none',
padding: '4px',
'background-color': '#000',
'color':'#fff',
opacity: 0.80
}).appendTo("body").fadeIn(20);
}
var previousPoint = null;
$("#placeholder").bind("plothover", function (event, pos, item) {
$("#x").text(pos.x.toFixed(2));
$("#y").text(pos.y.toFixed(2));
if (item) {
if (previousPoint != item.datapoint) {
previousPoint = item.datapoint;
$("#tooltip").remove();
var x = item.datapoint[0].toFixed(2),
y = item.datapoint[1].toFixed(2);
showTooltip(item.pageX, item.pageY, item.series.label[item.dataIndex]);
}
}
else {
$("#tooltip").remove();
previousPoint = null;
}
});
});
</script>
</body>
</hmtl>