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.

102 lines
2.8 KiB

1 year ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
  1. <hmtl>
  2. <head>
  3. <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
  4. <title>CurvedLines Plugin for flot</title>
  5. <script language="javascript" type="text/javascript" src="../flot/jquery.min.js"></script>
  6. <!--[if lte IE 8]><script language="javascript" type="text/javascript" src="../flot/excanvas.min.js"></script><![endif]-->
  7. <script language="javascript" type="text/javascript" src="../flot/jquery.flot.min.js"></script>
  8. <script language="javascript" type="text/javascript" src="../flot/jquery.flot.threshold.min.js"></script>
  9. <script language="JavaScript" type="text/javascript" src="../curvedLines.js"></script>
  10. <script language="JavaScript" type="text/javascript" src="_TestSetup.js"></script>
  11. <link rel="stylesheet" type="text/css" href="_TestSetup.css"></link>
  12. </head>
  13. <body>
  14. <div id="placeholder" style="width: 800;height: 400;"></div>
  15. <div id="parameters" style="width: 800"></div>
  16. <script id="source" language="javascript" type="text/javascript">
  17. $(function() {
  18. //data
  19. var d1 = [[20, 20], [42, 60], [54, 20], [80, 80]];
  20. //general plot options
  21. var options = {
  22. series : {
  23. curvedLines : {
  24. active : true
  25. },
  26. threshold : {
  27. below : 40,
  28. color : "rgb(0, 0, 0)"
  29. }
  30. },
  31. axis : {
  32. min : 10,
  33. max : 100
  34. },
  35. yaxis : {
  36. min : 10,
  37. max : 90
  38. }
  39. };
  40. //curved line paramters
  41. var defaultParameters = {
  42. apply : true,
  43. legacyOverride : true
  44. }
  45. //plot function
  46. function replot(parameters) {
  47. $.plot($("#placeholder"), [{
  48. data : d1,
  49. lines : {
  50. show : true,
  51. lineWidth : 3
  52. },
  53. curvedLines : parameters
  54. }, {
  55. data : d1,
  56. points : {
  57. show : true
  58. }
  59. }], options);
  60. }
  61. //combine everything
  62. TestSetup($("#parameters"), defaultParameters, [replot]);
  63. function showTooltip(x, y, contents) {
  64. $('<div id="tooltip">' + contents + '</div>').css({
  65. position : 'absolute',
  66. display : 'none',
  67. top : y - 32,
  68. left : x,
  69. border : 'none',
  70. padding : '4px',
  71. 'background-color' : '#000',
  72. 'color' : '#fff',
  73. opacity : 0.80
  74. }).appendTo("body").fadeIn(20);
  75. }
  76. var previousPoint = null;
  77. $("#placeholder").bind("plothover", function(event, pos, item) {
  78. $("#x").text(pos.x.toFixed(2));
  79. $("#y").text(pos.y.toFixed(2));
  80. if (item) {
  81. if (previousPoint != item.datapoint) {
  82. previousPoint = item.datapoint;
  83. $("#tooltip").remove();
  84. var x = item.datapoint[0].toFixed(2), y = item.datapoint[1].toFixed(2);
  85. showTooltip(item.pageX, item.pageY, item.series.label[item.dataIndex]);
  86. }
  87. } else {
  88. $("#tooltip").remove();
  89. previousPoint = null;
  90. }
  91. });
  92. });
  93. </script>
  94. </body>
  95. </hmtl>