bandedLine.html 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <title>Error Bands and Confidence Intervals</title>
  5. <link class="include" rel="stylesheet" type="text/css" href="../jquery.jqplot.min.css" />
  6. <link rel="stylesheet" type="text/css" href="examples.min.css" />
  7. <link type="text/css" rel="stylesheet" href="syntaxhighlighter/styles/shCoreDefault.min.css" />
  8. <link type="text/css" rel="stylesheet" href="syntaxhighlighter/styles/shThemejqPlot.min.css" />
  9. <!--[if lt IE 9]><script language="javascript" type="text/javascript" src="../excanvas.js"></script><![endif]-->
  10. <script class="include" type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
  11. </head>
  12. <body>
  13. <div id="header">
  14. <div class="nav">
  15. <a class="nav" href="../../../index.php"><span>&gt;</span>Home</a>
  16. <a class="nav" href="../../../docs/"><span>&gt;</span>Docs</a>
  17. <a class="nav" href="../../download/"><span>&gt;</span>Download</a>
  18. <a class="nav" href="../../../info.php"><span>&gt;</span>Info</a>
  19. <a class="nav" href="../../../donate.php"><span>&gt;</span>Donate</a>
  20. </div>
  21. </div>
  22. <div class="colmask leftmenu">
  23. <div class="colleft">
  24. <div class="col1" id="example-content">
  25. <!-- Example scripts go here -->
  26. <p>Bands (like confidence intervals or error bands) can be added to line charts through the "bands" option of the line renderer. The band data can be automatically computed or manually assigned. If assigned manually, the simpliest approach is to set the "rendererOptions: { bandData: [] }" array on the series. Note that band data is taken into account when axes scale themselves so bands will not get clipped.</p>
  27. <p>Band data can be supplied as arrays of [x,y] values. One array for the upper band line and one for the lower band line.</p>
  28. <div id="chart01" style="height:300px; width:600px;"></div>
  29. <pre class="code brush:js"></pre>
  30. <p>The number of points in the band data arrays does not have to correspond to the number of points in the data series. Also, band data will be drawn as smoothed lines if the data series is smoothed.</p>
  31. <div id="chart02" style="height:300px; width:600px;"></div>
  32. <pre class="code brush:js"></pre>
  33. <p>In this example, band data is supplied as an array of arrays of y values for the low and hi bands. X values for the bands are taken from the x values of the series. The band data is of the form: [ [y low 1, y hi 1], [y low 2, y hi 2], ... ] and there must be a corresponding array of low/hi y values for each x value in the data series.</p>
  34. <div id="chart1" style="height:300px; width:600px;"></div>
  35. <pre class="code brush:js"></pre>
  36. <p>The band data can also be supplied as an array of [low y values], [hi y values]. In this case there must also be an equal number of low y values and hi y values as there are data points in the series. X values for the low and hi bands will be taken from the series data. Additionally, the order of low/hi values does not matter as long as they are consistent. jqPlot will figure out which is the low values and which are the high values.</p>
  37. <div id="chart2" style="height:300px; width:600px;"></div>
  38. <pre class="code brush:js"></pre>
  39. <p>Band data does not have to be provided. By default, jqPlot will compute +/- 3% band intervals if the "rendererOptions: { bands: { show: true } }" option is set. The band intervals can be customized as well through the "rendererOptions: { bands: { interval: [number|string|arry] } }" option. Valid intervals are:</p>
  40. <ul>
  41. <li> '1.7' - will add bands at y +/- 1.7 above and below the line.</li>
  42. <li> '10%' - will compute +/- 10% interval bands.</li>
  43. <li> [3, '-10%'] - will add bands at y + 3 and y - 10% above and below the line.</li>
  44. </ul>
  45. <p>Examples of such interval specifications are shown below:</p>
  46. <div id="chart3" style="height:300px; width:600px;"></div>
  47. <pre class="code brush:js"></pre>
  48. <div id="chart4" style="height:300px; width:600px;"></div>
  49. <pre class="code brush:js"></pre>
  50. <div id="chart5" style="height:300px; width:600px;"></div>
  51. <pre class="code brush:js"></pre>
  52. <p>You can also customize the fill color of the bands and turn on/off band lines. By default, bands respond to the mouse over event, but they can be set to respond to mouse down as well.</p>
  53. <div id="chart6" style="height:300px; width:600px;"></div>
  54. <pre class="code brush:js"></pre>
  55. <p>Note, the plots on this page all extend the following pre-defined theme:</p>
  56. <pre class="code brush:js"></pre>
  57. <script class="code" type="text/javascript">
  58. $(document).ready(function(){
  59. // Band data in arrays of [x,y] values.
  60. bdat = [[['7/1/2011', 8], ['7/2/2011', 9], ['7/3/2011', 8], ['7/4/2011', 13], ['7/5/2011', 11], ['7/6/2011', 13]],
  61. [['7/1/2011', 12], ['7/2/2011', 13], ['7/3/2011', 12], ['7/4/2011', 17], ['7/5/2011', 15], ['7/6/2011', 17]]];
  62. dat = [['7/1/2011', 10], ['7/2/2011', 11], ['7/3/2011', 10], ['7/4/2011', 15], ['7/5/2011', 13], ['7/6/2011', 15]];
  63. plot01 = $.jqplot('chart01', [dat], $.extend(true, {}, myTheme, {
  64. series: [{
  65. rendererOptions: {
  66. bandData: bdat
  67. }
  68. }],
  69. axes: {
  70. xaxis: {
  71. renderer: $.jqplot.DateAxisRenderer,
  72. min: '7/1/2011',
  73. max: '7/6/2011',
  74. tickInterval: '1 day'
  75. }
  76. }
  77. }));
  78. });
  79. </script>
  80. <script class="code" type="text/javascript">
  81. $(document).ready(function(){
  82. // Band data in arrays of [x,y] values.
  83. // Here the low band line (1st array) has 5 points and the hi band line has 4 points.
  84. bdat = [[['7/1/2011', 9], ['7/3/2011', 7], ['7/4/2011', 13], ['7/5/2011', 11], ['7/6/2011', 13]],
  85. [['7/1/2011', 12], ['7/3/2011', 14], ['7/4/2011', 18], ['7/6/2011', 16]]];
  86. dat = [['7/1/2011', 10], ['7/2/2011', 11], ['7/3/2011', 10], ['7/4/2011', 15], ['7/5/2011', 13], ['7/6/2011', 15]];
  87. plot02 = $.jqplot('chart02', [dat], $.extend(true, {}, myTheme, {
  88. series: [{
  89. rendererOptions: {
  90. bandData: bdat,
  91. // turn on smoothing
  92. smooth: true
  93. }
  94. }],
  95. axes: {
  96. xaxis: {
  97. renderer: $.jqplot.DateAxisRenderer,
  98. min: '7/1/2011',
  99. max: '7/6/2011',
  100. tickInterval: '1 day'
  101. }
  102. }
  103. }));
  104. });
  105. </script>
  106. <script class="code" type="text/javascript">
  107. $(document).ready(function(){
  108. // data points for line.
  109. dat = [[0, 10], [1, 11], [2, 10], [3, 15], [4, 13], [5, 15]];
  110. // band data in [[low_y_1, hi_y_1], [low_y_2, hi_y_2],...] format
  111. bdat = [[7, 13], [8, 14], [7, 13], [12, 18], [10, 16], [12, 18]];
  112. plot1 = $.jqplot('chart1', [dat], $.extend(true, {}, myTheme, {
  113. series: [{
  114. rendererOptions: {
  115. // Set the band data on the series.
  116. // Bands will be turned on automatically if
  117. // valid band data is present.
  118. bandData: bdat,
  119. smooth: true
  120. }
  121. }]
  122. }));
  123. });
  124. </script>
  125. <script class="code" type="text/javascript">
  126. $(document).ready(function(){
  127. // here band data specified as an array of [low y values] and [hi y values]
  128. bdat = [[7, 8, 7, 12, 10, 12], [13, 14, 13, 18, 16, 18]];
  129. // Same plot as before with different band data specification and smoothed lines.
  130. plot2 = $.jqplot('chart2', [dat], $.extend(true, {}, myTheme, {
  131. series: [
  132. {
  133. rendererOptions: {
  134. bandData: bdat,
  135. smooth: true
  136. }
  137. }]
  138. }));
  139. });
  140. </script>
  141. <script class="code" type="text/javascript">
  142. $(document).ready(function(){
  143. plot3 = $.jqplot('chart3', [dat], $.extend(true, {}, myTheme, {
  144. series: [{
  145. rendererOptions: {
  146. bands: {
  147. // draw bands at 1.7 "units" above and below line.
  148. interval: 1.7
  149. },
  150. smooth: true
  151. }
  152. }]
  153. }));
  154. });
  155. </script>
  156. <script class="code" type="text/javascript">
  157. $(document).ready(function(){
  158. plot4 = $.jqplot('chart4', [dat], $.extend(true, {}, myTheme, {
  159. series: [{
  160. rendererOptions: {
  161. bands: {
  162. // draw interval at 10% above and below line.
  163. interval: '10%'
  164. },
  165. smooth: true
  166. }
  167. }]
  168. }));
  169. });
  170. </script>
  171. <script class="code" type="text/javascript">
  172. $(document).ready(function(){
  173. plot5 = $.jqplot('chart5', [dat], $.extend(true, {}, myTheme, {
  174. series: [{
  175. rendererOptions: {
  176. bands: {
  177. // draw interval at 3 units above and 10% below line.
  178. interval: [3, '-10%']
  179. },
  180. smooth: true
  181. }
  182. }]
  183. }));
  184. });
  185. </script>
  186. <script class="code" type="text/javascript">
  187. $(document).ready(function(){
  188. plot6 = $.jqplot('chart6', [dat], $.extend(true, {}, myTheme, {
  189. series: [{
  190. rendererOptions: {
  191. bands: {
  192. // draw interval at 3 units above and 10% below line.
  193. interval: 4,
  194. fillColor: 'rgba(198, 88, 88, 0.6)',
  195. showLines: true
  196. },
  197. // highlight the band on mouse down, not on mouse over.
  198. highlightMouseDown: true,
  199. smooth: true
  200. }
  201. }]
  202. }));
  203. });
  204. </script>
  205. <script class="code" type="text/javascript">
  206. ///////
  207. // A default set of reusable plot options. Note that line
  208. // smoothing is turned on. Bands will be drawn with the same
  209. // smoothing as the line.
  210. //////
  211. myTheme = {
  212. grid: {
  213. drawBorder: false,
  214. shadow: false,
  215. background: 'rgba(255, 255, 255, 0.0)'
  216. },
  217. seriesDefaults: {
  218. shadow: false,
  219. showMarker: false
  220. },
  221. axes: {
  222. xaxis: {
  223. pad: 1.0,
  224. tickOptions: {
  225. showGridline: false
  226. }
  227. },
  228. yaxis: {
  229. pad: 1.05
  230. }
  231. }
  232. };
  233. </script>
  234. <!-- End example scripts -->
  235. <!-- Don't touch this! -->
  236. <script class="include" type="text/javascript" src="../jquery.jqplot.min.js"></script>
  237. <script type="text/javascript" src="syntaxhighlighter/scripts/shCore.min.js"></script>
  238. <script type="text/javascript" src="syntaxhighlighter/scripts/shBrushJScript.min.js"></script>
  239. <script type="text/javascript" src="syntaxhighlighter/scripts/shBrushXml.min.js"></script>
  240. <!-- Additional plugins go here -->
  241. <script class="include" type="text/javascript" src="../plugins/jqplot.highlighter.min.js"></script>
  242. <script class="include" type="text/javascript" src="../plugins/jqplot.cursor.min.js"></script>
  243. <script class="include" type="text/javascript" src="../plugins/jqplot.pointLabels.min.js"></script>
  244. <script class="include" type="text/javascript" src="../plugins/jqplot.dateAxisRenderer.min.js"></script>
  245. <!-- End additional plugins -->
  246. </div>
  247. <div class="col2">
  248. <div class="example-link"><a class="example-link" href="data-renderers.html">AJAX and JSON Data Loading via Data Renderers</a></div>
  249. <div class="example-link"><a class="example-link" href="barLineAnimated.html">Animated Charts</a></div>
  250. <div class="example-link"><a class="example-link" href="dashboardWidget.html">Animated Dashboard Sample - Filled Line with Log Axis</a></div>
  251. <div class="example-link"><a class="example-link" href="kcp_area.html">Area Chart</a></div>
  252. <div class="example-link"><a class="example-link" href="kcp_area2.html">Area Chart 2</a></div>
  253. <div class="example-link"><a class="example-link" href="axisLabelTests.html">Axis Labels</a></div>
  254. <div class="example-link"><a class="example-link" href="axisLabelsRotatedText.html">Axis Labels and Rotated Text</a></div>
  255. <div class="example-link"><a class="example-link" href="barTest.html">Bar Charts</a></div>
  256. <div class="example-link"><a class="example-link" href="multipleBarColors.html">Bar Colors Example</a></div>
  257. <div class="example-link"><a class="example-link" href="bezierCurve.html">Bezier Curve Plots</a></div>
  258. <div class="example-link"><a class="example-link" href="blockPlot.html">Block Plots</a></div>
  259. <div class="example-link"><a class="example-link" href="bubbleChart.html">Bubble Charts</a></div>
  260. <div class="example-link"><a class="example-link" href="bubble-plots.html">Bubble Plots</a></div>
  261. <div class="example-link"><a class="example-link" href="candlestick.html">Candlestick and Open Hi Low Close Charts</a></div>
  262. <div class="example-link"><a class="example-link" href="theming.html">Chart Theming</a></div>
  263. <div class="example-link"><a class="example-link" href="fillBetweenLines.html">Charts with Fill Between Lines</a></div>
  264. <div class="example-link"><a class="example-link" href="kcp_cdf.html">Cumulative Density Function Chart</a></div>
  265. <div class="example-link"><a class="example-link" href="dashedLines.html">Dashed Lines with Smoothing</a></div>
  266. <div class="example-link"><a class="example-link" href="cursor-highlighter.html">Data Point Highlighting, Tooltips and Cursor Tracking</a></div>
  267. <div class="example-link"><a class="example-link" href="point-labels.html">Data Point labels</a></div>
  268. <div class="example-link"><a class="example-link" href="date-axes.html">Date Axes</a></div>
  269. <div class="example-link"><a class="example-link" href="dateAxisRenderer.html">Date Axes 2</a></div>
  270. <div class="example-link"><a class="example-link" href="rotatedTickLabelsZoom.html">Date Axes, Rotated Labels and Zooming</a></div>
  271. <div class="example-link"><a class="example-link" href="canvas-overlay.html">Draw Lines on Plots - Canvas Overlay</a></div>
  272. <div class="example-link"><a class="example-link" href="draw-rectangles.html">Draw Rectangles on Plots</a></div>
  273. <div class="example-link"><a class="example-link" href="kcp_engel.html">Engel Curves</a></div>
  274. <div class="example-link"><a class="example-link" href="bandedLine.html">Error Bands and Confidence Intervals</a></div>
  275. <div class="example-link"><a class="example-link" href="area.html">Filled (Area) Charts</a></div>
  276. <div class="example-link"><a class="example-link" href="axisScalingForceTickAt.html">Force Plot to Have Tick at 0 or 100</a></div>
  277. <div class="example-link"><a class="example-link" href="hiddenPlotsInTabs.html">Hidden Plots</a></div>
  278. <div class="example-link"><a class="example-link" href="customHighlighterCursorTrendline.html">Highlighting, Dragging Points, Cursor and Trend Lines</a></div>
  279. <div class="example-link"><a class="example-link" href="line-charts.html">Line Charts and Options</a></div>
  280. <div class="example-link"><a class="example-link" href="kcp_lorenz.html">Lorenz Curves</a></div>
  281. <div class="example-link"><a class="example-link" href="mekkoCharts.html">Mekko Charts</a></div>
  282. <div class="example-link"><a class="example-link" href="meterGauge.html">Meter Gauge</a></div>
  283. <div class="example-link"><a class="example-link" href="candlestick-charts.html">Open Hi Low Close and Candlestick Charts</a></div>
  284. <div class="example-link"><a class="example-link" href="pieTest.html">Pie Charts and Options</a></div>
  285. <div class="example-link"><a class="example-link" href="pieTest4.html">Pie Charts and Options 2</a></div>
  286. <div class="example-link"><a class="example-link" href="pie-donut-charts.html">Pie and Donut Charts</a></div>
  287. <div class="example-link"><a class="example-link" href="selectorSyntax.html">Plot Creation with jQuery Selectors</a></div>
  288. <div class="example-link"><a class="example-link" href="zooming.html">Plot Zooming and Cursor Control</a></div>
  289. <div class="example-link"><a class="example-link" href="kcp_pdf.html">Probability Density Function Chart</a></div>
  290. <div class="example-link"><a class="example-link" href="kcp_pyramid_by_age.html">Pyramid Chart By Age</a></div>
  291. <div class="example-link"><a class="example-link" href="kcp_pyramid.html">Pyramid Charts</a></div>
  292. <div class="example-link"><a class="example-link" href="kcp_pyramid2.html">Pyramid Charts 2</a></div>
  293. <div class="example-link"><a class="example-link" href="kcp_quintiles.html">Quintile Pyramid Charts</a></div>
  294. <div class="example-link"><a class="example-link" href="resizablePlot.html">Resizable Plots</a></div>
  295. <div class="example-link"><a class="example-link" href="rotated-tick-labels.html">Rotated Labels and Font Styling</a></div>
  296. <div class="example-link"><a class="example-link" href="smoothedLine.html">Smoothed Lines</a></div>
  297. <div class="example-link"><a class="example-link" href="bar-charts.html">Vertical and Horizontal Bar Charts</a></div>
  298. <div class="example-link"><a class="example-link" href="waterfall.html">Waterfall Charts</a></div>
  299. <div class="example-link"><a class="example-link" href="waterfall2.html">Waterfall Charts 2</a></div>
  300. <div class="example-link"><a class="example-link" href="zoomOptions.html">Zoom Options</a></div>
  301. <div class="example-link"><a class="example-link" href="zoomProxy.html">Zoom Proxy - Control one plot from another</a></div>
  302. <div class="example-link"><a class="example-link" href="zoom1.html">Zooming</a></div>
  303. <div class="example-link"><a class="example-link" href="dateAxisLogAxisZooming.html">Zooming with Date and Log Axes</a></div>
  304. </div>
  305. </div>
  306. </div>
  307. <script type="text/javascript" src="example.min.js"></script>
  308. </body>
  309. </html>