index.html 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172
  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="../../source/jquery.js"></script>
  9. <script language="javascript" type="text/javascript" src="../../lib/jquery.mousewheel.js"></script>
  10. <script language="javascript" type="text/javascript" src="../../source/jquery.canvaswrapper.js"></script>
  11. <script language="javascript" type="text/javascript" src="../../source/jquery.colorhelpers.js"></script>
  12. <script language="javascript" type="text/javascript" src="../../source/jquery.flot.js"></script>
  13. <script language="javascript" type="text/javascript" src="../../source/jquery.flot.saturated.js"></script>
  14. <script language="javascript" type="text/javascript" src="../../source/jquery.flot.browser.js"></script>
  15. <script language="javascript" type="text/javascript" src="../../source/jquery.flot.drawSeries.js"></script>
  16. <script language="javascript" type="text/javascript" src="../../source/jquery.flot.errorbars.js"></script>
  17. <script language="javascript" type="text/javascript" src="../../source/jquery.flot.uiConstants.js"></script>
  18. <script language="javascript" type="text/javascript" src="../../source/jquery.flot.logaxis.js"></script>
  19. <script language="javascript" type="text/javascript" src="../../source/jquery.flot.symbol.js"></script>
  20. <script language="javascript" type="text/javascript" src="../../source/jquery.flot.flatdata.js"></script>
  21. <script language="javascript" type="text/javascript" src="../../source/jquery.flot.navigate.js"></script>
  22. <script language="javascript" type="text/javascript" src="../../source/jquery.flot.fillbetween.js"></script>
  23. <script language="javascript" type="text/javascript" src="../../source/jquery.flot.stack.js"></script>
  24. <script language="javascript" type="text/javascript" src="../../source/jquery.flot.touchNavigate.js"></script>
  25. <script language="javascript" type="text/javascript" src="../../source/jquery.flot.hover.js"></script>
  26. <script language="javascript" type="text/javascript" src="../../source/jquery.flot.touch.js"></script>
  27. <script language="javascript" type="text/javascript" src="../../source/jquery.flot.time.js"></script>
  28. <script language="javascript" type="text/javascript" src="../../source/jquery.flot.axislabels.js"></script>
  29. <script language="javascript" type="text/javascript" src="../../source/jquery.flot.selection.js"></script>
  30. <script language="javascript" type="text/javascript" src="../../source/jquery.flot.composeImages.js"></script>
  31. <script language="javascript" type="text/javascript" src="../../source/jquery.flot.legend.js"></script>
  32. <script type="text/javascript">
  33. $(function() {
  34. function drawArrow(ctx, x, y, radius){
  35. ctx.beginPath();
  36. ctx.moveTo(x + radius, y + radius);
  37. ctx.lineTo(x, y);
  38. ctx.lineTo(x - radius, y + radius);
  39. ctx.stroke();
  40. }
  41. function drawSemiCircle(ctx, x, y, radius){
  42. ctx.beginPath();
  43. ctx.arc(x, y, radius, 0, Math.PI, false);
  44. ctx.moveTo(x - radius, y);
  45. ctx.lineTo(x + radius, y);
  46. ctx.stroke();
  47. }
  48. var data1 = [
  49. [1,1,.5,.1,.3],
  50. [2,2,.3,.5,.2],
  51. [3,3,.9,.5,.2],
  52. [1.5,-.05,.5,.1,.3],
  53. [3.15,1.,.5,.1,.3],
  54. [2.5,-1.,.5,.1,.3]
  55. ];
  56. var data1_points = {
  57. show: true,
  58. radius: 5,
  59. fillColor: "blue",
  60. errorbars: "xy",
  61. xerr: {show: true, asymmetric: true, upperCap: "-", lowerCap: "-"},
  62. yerr: {show: true, color: "red", upperCap: "-"}
  63. };
  64. var data2 = [
  65. [.7,3,.2,.4],
  66. [1.5,2.2,.3,.4],
  67. [2.3,1,.5,.2]
  68. ];
  69. var data2_points = {
  70. show: true,
  71. radius: 5,
  72. errorbars: "y",
  73. yerr: {show:true, asymmetric:true, upperCap: drawArrow, lowerCap: drawSemiCircle}
  74. };
  75. var data3 = [
  76. [1,2,.4],
  77. [2,0.5,.3],
  78. [2.7,2,.5]
  79. ];
  80. var data3_points = {
  81. //do not show points
  82. radius: 0,
  83. errorbars: "y",
  84. yerr: {show:true, upperCap: "-", lowerCap: "-", radius: 5}
  85. };
  86. var data4 = [
  87. [1.3, 1],
  88. [1.75, 2.5],
  89. [2.5, 0.5]
  90. ];
  91. var data4_errors = [0.1, 0.4, 0.2];
  92. for (var i = 0; i < data4.length; i++) {
  93. data4_errors[i] = data4[i].concat(data4_errors[i])
  94. }
  95. var data = [
  96. {color: "blue", points: data1_points, data: data1, label: "data1"},
  97. {color: "red", points: data2_points, data: data2, label: "data2"},
  98. {color: "green", lines: {show: true}, points: data3_points, data: data3, label: "data3"},
  99. // bars with errors
  100. {color: "orange", bars: {show: true, align: "center", barWidth: 0.25}, data: data4, label: "data4"},
  101. {color: "orange", points: data3_points, data: data4_errors}
  102. ];
  103. $.plot($("#placeholder"), data , {
  104. legend: {
  105. position: "sw",
  106. show: true
  107. },
  108. series: {
  109. lines: {
  110. show: false
  111. }
  112. },
  113. xaxis: {
  114. autoScale: 'none',
  115. min: 0.6,
  116. max: 3.1
  117. },
  118. yaxis: {
  119. autoScale: 'none',
  120. min: 0,
  121. max: 3.5
  122. },
  123. zoom: {
  124. interactive: true
  125. },
  126. pan: {
  127. interactive: true
  128. }
  129. });
  130. // Add the Flot version string to the footer
  131. $("#footer").prepend("Flot " + $.plot.version + " &ndash; ");
  132. });
  133. </script>
  134. </head>
  135. <body>
  136. <div id="header">
  137. <h2>Error Bars</h2>
  138. </div>
  139. <div id="content">
  140. <div class="demo-container">
  141. <div id="placeholder" class="demo-placeholder"></div>
  142. </div>
  143. <p>With the errorbars plugin you can plot error bars to show standard deviation and other useful statistical properties.</p>
  144. </div>
  145. <div id="footer">
  146. Copyright &copy; 2007 - 2014 IOLA and Ole Laursen
  147. </div>
  148. </body>
  149. </html>