index.html 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
  2. <html>
  3. <head>
  4. <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  5. <title>Flot Examples: Error Bars</title>
  6. <link href="../examples.css" rel="stylesheet" type="text/css">
  7. <!--[if lte IE 8]><script language="javascript" type="text/javascript" src="../../excanvas.min.js"></script><![endif]-->
  8. <script language="javascript" type="text/javascript" src="../../jquery.js"></script>
  9. <script language="javascript" type="text/javascript" src="../../jquery.flot.js"></script>
  10. <script language="javascript" type="text/javascript" src="../../jquery.flot.errorbars.js"></script>
  11. <script language="javascript" type="text/javascript" src="../../jquery.flot.navigate.js"></script>
  12. <script type="text/javascript">
  13. $(function() {
  14. function drawArrow(ctx, x, y, radius){
  15. ctx.beginPath();
  16. ctx.moveTo(x + radius, y + radius);
  17. ctx.lineTo(x, y);
  18. ctx.lineTo(x - radius, y + radius);
  19. ctx.stroke();
  20. }
  21. function drawSemiCircle(ctx, x, y, radius){
  22. ctx.beginPath();
  23. ctx.arc(x, y, radius, 0, Math.PI, false);
  24. ctx.moveTo(x - radius, y);
  25. ctx.lineTo(x + radius, y);
  26. ctx.stroke();
  27. }
  28. var data1 = [
  29. [1,1,.5,.1,.3],
  30. [2,2,.3,.5,.2],
  31. [3,3,.9,.5,.2],
  32. [1.5,-.05,.5,.1,.3],
  33. [3.15,1.,.5,.1,.3],
  34. [2.5,-1.,.5,.1,.3]
  35. ];
  36. var data1_points = {
  37. show: true,
  38. radius: 5,
  39. fillColor: "blue",
  40. errorbars: "xy",
  41. xerr: {show: true, asymmetric: true, upperCap: "-", lowerCap: "-"},
  42. yerr: {show: true, color: "red", upperCap: "-"}
  43. };
  44. var data2 = [
  45. [.7,3,.2,.4],
  46. [1.5,2.2,.3,.4],
  47. [2.3,1,.5,.2]
  48. ];
  49. var data2_points = {
  50. show: true,
  51. radius: 5,
  52. errorbars: "y",
  53. yerr: {show:true, asymmetric:true, upperCap: drawArrow, lowerCap: drawSemiCircle}
  54. };
  55. var data3 = [
  56. [1,2,.4],
  57. [2,0.5,.3],
  58. [2.7,2,.5]
  59. ];
  60. var data3_points = {
  61. //do not show points
  62. radius: 0,
  63. errorbars: "y",
  64. yerr: {show:true, upperCap: "-", lowerCap: "-", radius: 5}
  65. };
  66. var data4 = [
  67. [1.3, 1],
  68. [1.75, 2.5],
  69. [2.5, 0.5]
  70. ];
  71. var data4_errors = [0.1, 0.4, 0.2];
  72. for (var i = 0; i < data4.length; i++) {
  73. data4_errors[i] = data4[i].concat(data4_errors[i])
  74. }
  75. var data = [
  76. {color: "blue", points: data1_points, data: data1, label: "data1"},
  77. {color: "red", points: data2_points, data: data2, label: "data2"},
  78. {color: "green", lines: {show: true}, points: data3_points, data: data3, label: "data3"},
  79. // bars with errors
  80. {color: "orange", bars: {show: true, align: "center", barWidth: 0.25}, data: data4, label: "data4"},
  81. {color: "orange", points: data3_points, data: data4_errors}
  82. ];
  83. $.plot($("#placeholder"), data , {
  84. legend: {
  85. position: "sw",
  86. show: true
  87. },
  88. series: {
  89. lines: {
  90. show: false
  91. }
  92. },
  93. xaxis: {
  94. min: 0.6,
  95. max: 3.1
  96. },
  97. yaxis: {
  98. min: 0,
  99. max: 3.5
  100. },
  101. zoom: {
  102. interactive: true
  103. },
  104. pan: {
  105. interactive: true
  106. }
  107. });
  108. // Add the Flot version string to the footer
  109. $("#footer").prepend("Flot " + $.plot.version + " &ndash; ");
  110. });
  111. </script>
  112. </head>
  113. <body>
  114. <div id="header">
  115. <h2>Error Bars</h2>
  116. </div>
  117. <div id="content">
  118. <div class="demo-container">
  119. <div id="placeholder" class="demo-placeholder"></div>
  120. </div>
  121. <p>With the errorbars plugin you can plot error bars to show standard deviation and other useful statistical properties.</p>
  122. </div>
  123. <div id="footer">
  124. Copyright &copy; 2007 - 2014 IOLA and Ole Laursen
  125. </div>
  126. </body>
  127. </html>