You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
103 lines
2.8 KiB
103 lines
2.8 KiB
<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="../flot/jquery.flot.threshold.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 id="source" language="javascript" type="text/javascript"> |
|
$(function() { |
|
//data |
|
var d1 = [[20, 20], [42, 60], [54, 20], [80, 80]]; |
|
|
|
//general plot options |
|
var options = { |
|
series : { |
|
curvedLines : { |
|
active : true |
|
}, |
|
threshold : { |
|
below : 40, |
|
color : "rgb(0, 0, 0)" |
|
} |
|
}, |
|
axis : { |
|
min : 10, |
|
max : 100 |
|
}, |
|
yaxis : { |
|
min : 10, |
|
max : 90 |
|
} |
|
}; |
|
|
|
//curved line paramters |
|
var defaultParameters = { |
|
apply : true, |
|
legacyOverride : true |
|
} |
|
|
|
//plot function |
|
function replot(parameters) { |
|
$.plot($("#placeholder"), [{ |
|
data : d1, |
|
lines : { |
|
show : true, |
|
lineWidth : 3 |
|
}, |
|
curvedLines : parameters |
|
}, { |
|
data : d1, |
|
points : { |
|
show : true |
|
} |
|
}], options); |
|
} |
|
|
|
//combine everything |
|
TestSetup($("#parameters"), defaultParameters, [replot]); |
|
|
|
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> |