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.

163 lines
5.0 KiB

9 years ago
  1. <!DOCTYPE HTML>
  2. <html>
  3. <head>
  4. <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  5. <title>Highcharts Example</title>
  6. <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js"></script>
  7. <style type="text/css">
  8. ${demo.css}
  9. </style>
  10. <script type="text/javascript">
  11. $(function () {
  12. var colors = Highcharts.getOptions().colors,
  13. categories = ['MSIE', 'Firefox', 'Chrome', 'Safari', 'Opera'],
  14. data = [{
  15. y: 56.33,
  16. color: colors[0],
  17. drilldown: {
  18. name: 'MSIE versions',
  19. categories: ['MSIE 6.0', 'MSIE 7.0', 'MSIE 8.0', 'MSIE 9.0', 'MSIE 10.0', 'MSIE 11.0'],
  20. data: [1.06, 0.5, 17.2, 8.11, 5.33, 24.13],
  21. color: colors[0]
  22. }
  23. }, {
  24. y: 10.38,
  25. color: colors[1],
  26. drilldown: {
  27. name: 'Firefox versions',
  28. categories: ['Firefox v31', 'Firefox v32', 'Firefox v33', 'Firefox v35', 'Firefox v36', 'Firefox v37', 'Firefox v38'],
  29. data: [0.33, 0.15, 0.22, 1.27, 2.76, 2.32, 2.31, 1.02],
  30. color: colors[1]
  31. }
  32. }, {
  33. y: 24.03,
  34. color: colors[2],
  35. drilldown: {
  36. name: 'Chrome versions',
  37. categories: ['Chrome v30.0', 'Chrome v31.0', 'Chrome v32.0', 'Chrome v33.0', 'Chrome v34.0',
  38. 'Chrome v35.0', 'Chrome v36.0', 'Chrome v37.0', 'Chrome v38.0', 'Chrome v39.0', 'Chrome v40.0', 'Chrome v41.0', 'Chrome v42.0', 'Chrome v43.0'
  39. ],
  40. data: [0.14, 1.24, 0.55, 0.19, 0.14, 0.85, 2.53, 0.38, 0.6, 2.96, 5, 4.32, 3.68, 1.45],
  41. color: colors[2]
  42. }
  43. }, {
  44. y: 4.77,
  45. color: colors[3],
  46. drilldown: {
  47. name: 'Safari versions',
  48. categories: ['Safari v5.0', 'Safari v5.1', 'Safari v6.1', 'Safari v6.2', 'Safari v7.0', 'Safari v7.1', 'Safari v8.0'],
  49. data: [0.3, 0.42, 0.29, 0.17, 0.26, 0.77, 2.56],
  50. color: colors[3]
  51. }
  52. }, {
  53. y: 0.91,
  54. color: colors[4],
  55. drilldown: {
  56. name: 'Opera versions',
  57. categories: ['Opera v12.x', 'Opera v27', 'Opera v28', 'Opera v29'],
  58. data: [0.34, 0.17, 0.24, 0.16],
  59. color: colors[4]
  60. }
  61. }, {
  62. y: 0.2,
  63. color: colors[5],
  64. drilldown: {
  65. name: 'Proprietary or Undetectable',
  66. categories: [],
  67. data: [],
  68. color: colors[5]
  69. }
  70. }],
  71. browserData = [],
  72. versionsData = [],
  73. i,
  74. j,
  75. dataLen = data.length,
  76. drillDataLen,
  77. brightness;
  78. // Build the data arrays
  79. for (i = 0; i < dataLen; i += 1) {
  80. // add browser data
  81. browserData.push({
  82. name: categories[i],
  83. y: data[i].y,
  84. color: data[i].color
  85. });
  86. // add version data
  87. drillDataLen = data[i].drilldown.data.length;
  88. for (j = 0; j < drillDataLen; j += 1) {
  89. brightness = 0.2 - (j / drillDataLen) / 5;
  90. versionsData.push({
  91. name: data[i].drilldown.categories[j],
  92. y: data[i].drilldown.data[j],
  93. color: Highcharts.Color(data[i].color).brighten(brightness).get()
  94. });
  95. }
  96. }
  97. // Create the chart
  98. $('#container').highcharts({
  99. chart: {
  100. type: 'pie'
  101. },
  102. title: {
  103. text: 'Browser market share, January, 2015 to May, 2015'
  104. },
  105. subtitle: {
  106. text: 'Source: <a href="http://netmarketshare.com/">netmarketshare.com</a>'
  107. },
  108. yAxis: {
  109. title: {
  110. text: 'Total percent market share'
  111. }
  112. },
  113. plotOptions: {
  114. pie: {
  115. shadow: false,
  116. center: ['50%', '50%']
  117. }
  118. },
  119. tooltip: {
  120. valueSuffix: '%'
  121. },
  122. series: [{
  123. name: 'Browsers',
  124. data: browserData,
  125. size: '60%',
  126. dataLabels: {
  127. formatter: function () {
  128. return this.y > 5 ? this.point.name : null;
  129. },
  130. color: 'white',
  131. distance: -30
  132. }
  133. }, {
  134. name: 'Versions',
  135. data: versionsData,
  136. size: '80%',
  137. innerSize: '60%',
  138. dataLabels: {
  139. formatter: function () {
  140. // display only if larger than 1
  141. return this.y > 1 ? '<b>' + this.point.name + ':</b> ' + this.y + '%' : null;
  142. }
  143. }
  144. }]
  145. });
  146. });
  147. </script>
  148. </head>
  149. <body>
  150. <script src="../../js/highcharts.js"></script>
  151. <script src="../../js/modules/exporting.js"></script>
  152. <div id="container" style="width: 600px; height: 400px; margin: 0 auto"></div>
  153. </body>
  154. </html>