index.htm 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218
  1. <!DOCTYPE HTML>
  2. <html>
  3. <head>
  4. <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  5. <meta name="viewport" content="width=device-width, initial-scale=1">
  6. <title>Highcharts Example</title>
  7. <style type="text/css">
  8. #container {
  9. max-width: 800px;
  10. height: 400px;
  11. margin: 1em auto;
  12. }
  13. caption {
  14. padding-bottom: 5px;
  15. font-family: 'Verdana';
  16. font-size: 14pt;
  17. font-weight: bold;
  18. color:#555555;
  19. }
  20. table {
  21. font-family: 'Verdana';
  22. font-size: 12pt;
  23. color:#555555;
  24. border-collapse: collapse;
  25. border: 3px solid #CCCCCC;
  26. margin: 2px auto;
  27. }
  28. tr {
  29. border-bottom: 2px solid #EEEEEE;
  30. }
  31. th {
  32. border-left: 2px solid #EEEEEE;
  33. border-right: 2px solid #EEEEEE;
  34. padding: 12px 15px;
  35. border-collapse: collapse;
  36. }
  37. th[scope="col"] {
  38. background-color: #ffffee;
  39. }
  40. th[scope="row"] {
  41. background-color: #f0fcff;
  42. text-align:left;
  43. }
  44. td {
  45. border-left: 2px solid #EEEEEE;
  46. border-right: 2px solid #EEEEEE;
  47. padding: 12px 15px;
  48. border-collapse: collapse;
  49. }
  50. </style>
  51. </head>
  52. <body>
  53. <script src="../../code/highcharts.js"></script>
  54. <script src="../../code/highcharts-more.js"></script>
  55. <script src="../../code/modules/exporting.js"></script>
  56. <script src="../../code/modules/export-data.js"></script>
  57. <script src="../../code/modules/accessibility.js"></script>
  58. <div id="container"></div>
  59. <script type="text/javascript">
  60. // Define custom series type for displaying low/med/high values using boxplot as a base
  61. Highcharts.seriesType('lowmedhigh', 'boxplot', {
  62. keys: ['low', 'median', 'high']
  63. }, {
  64. // Change point shape to a line with three crossing lines for low/median/high
  65. // Stroke width is hardcoded to 1 for simplicity
  66. drawPoints: function () {
  67. var series = this;
  68. Highcharts.each(this.points, function (point) {
  69. var graphic = point.graphic,
  70. verb = graphic ? 'animate' : 'attr',
  71. shapeArgs = point.shapeArgs,
  72. width = shapeArgs.width,
  73. left = Math.floor(shapeArgs.x) + 0.5,
  74. right = left + width,
  75. crispX = left + Math.round(width / 2) + 0.5,
  76. highPlot = Math.floor(point.highPlot) + 0.5,
  77. medianPlot = Math.floor(point.medianPlot) + 0.5,
  78. lowPlot = Math.floor(point.lowPlot) + 0.5 - (point.low === 0 ? 1 : 0); // Sneakily draw low marker even if 0
  79. if (!graphic) {
  80. point.graphic = graphic = series.chart.renderer.path('point').add(series.group);
  81. }
  82. graphic.attr({
  83. stroke: point.color || series.color,
  84. "stroke-width": 1
  85. });
  86. graphic[verb]({
  87. d: [
  88. 'M', left, highPlot,
  89. 'H', right,
  90. 'M', left, medianPlot,
  91. 'H', right,
  92. 'M', left, lowPlot,
  93. 'H', right,
  94. 'M', crispX, highPlot,
  95. 'V', lowPlot
  96. ]
  97. });
  98. });
  99. }
  100. });
  101. // Create chart
  102. var chart = Highcharts.chart('container', {
  103. accessibility: {
  104. keyboardNavigation: {
  105. skipNullPoints: true
  106. },
  107. pointDescriptionFormatter: function (point) {
  108. return point.category + ', low ' + point.low + ', median ' + point.median + ', high ' + point.high;
  109. },
  110. seriesDescriptionFormatter: function (series) {
  111. return series.name + ', series ' + (series.index + 1) + ' of ' + series.chart.series.length + ' with ' + series.points.length + ' data points.';
  112. }
  113. },
  114. chart: {
  115. type: 'lowmedhigh',
  116. typeDescription: 'Low, median, high. Each data point has a low, median and high value, depicted vertically as small ticks.', // Describe the chart type to screen reader users, since this is not a traditional boxplot chart
  117. description: 'Chart depicting fictional fruit consumption data, with the minimum, maximum and median values for each month of 2015. Most plums were eaten in spring, and none at all in July or August. Bananas and apples were both consumed in smaller numbers and steadily throughout the year.'
  118. },
  119. title: {
  120. text: 'Daily company fruit consumption 2015'
  121. },
  122. xAxis: [{
  123. crosshair: true,
  124. description: 'Months of the year',
  125. categories: ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December']
  126. }],
  127. yAxis: {
  128. title: {
  129. text: 'Fruits consumed'
  130. },
  131. min: 0
  132. },
  133. plotOptions: {
  134. series: {
  135. stickyTracking: true,
  136. whiskerWidth: 5
  137. }
  138. },
  139. tooltip: {
  140. pointFormat: '<span style="color:{point.color}">\u25CF</span> {series.name}:<br/>Low: <b>{point.low}</b><br/>Median: <b>{point.median}</b><br/>High: <b>{point.high}</b><br/>'
  141. },
  142. series: [{
  143. name: 'Plums',
  144. data: [
  145. [0, 8, 19],
  146. [1, 11, 23],
  147. [3, 16, 28],
  148. [2, 15, 28],
  149. [1, 15, 27],
  150. [0, 9, 21],
  151. null,
  152. null,
  153. [1, 6, 19],
  154. [2, 8, 21],
  155. [2, 9, 22],
  156. [1, 11, 19]
  157. ]
  158. }, {
  159. name: 'Bananas',
  160. data: [
  161. [0, 3, 6],
  162. [1, 2, 4],
  163. [0, 2, 5],
  164. [2, 2, 5],
  165. [1, 3, 6],
  166. [0, 1, 3],
  167. [1, 1, 2],
  168. [0, 1, 3],
  169. [1, 1, 3],
  170. [0, 2, 4],
  171. [1, 2, 5],
  172. [1, 3, 5]
  173. ]
  174. }, {
  175. name: 'Apples',
  176. data: [
  177. [1, 4, 6],
  178. [2, 4, 5],
  179. [1, 3, 6],
  180. [2, 3, 6],
  181. [1, 3, 4],
  182. [0, 2, 4],
  183. [0, 1, 2],
  184. [0, 1, 2],
  185. [0, 1, 2],
  186. [0, 2, 4],
  187. [1, 2, 4],
  188. [1, 3, 4]
  189. ]
  190. }]
  191. });
  192. // Remove click events on container to avoid having "clickable" announced by AT
  193. // These events are needed for custom click events, drag to zoom, and navigator
  194. // support.
  195. chart.container.onmousedown = null;
  196. chart.container.onclick = null;
  197. </script>
  198. </body>
  199. </html>