市长热线演示版

index.htm 5.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184
  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://cdn.hcharts.cn/jquery/jquery-1.8.3.min.js"></script>
  7. <script type="text/javascript">
  8. $(function () {
  9. Highcharts.data({
  10. csv: document.getElementById('tsv').innerHTML,
  11. itemDelimiter: '\t',
  12. parsed: function (columns) {
  13. var brands = {},
  14. brandsData = [],
  15. versions = {},
  16. drilldownSeries = [];
  17. // Parse percentage strings
  18. columns[1] = $.map(columns[1], function (value) {
  19. if (value.indexOf('%') === value.length - 1) {
  20. value = parseFloat(value);
  21. }
  22. return value;
  23. });
  24. $.each(columns[0], function (i, name) {
  25. var brand,
  26. version;
  27. if (i > 0) {
  28. // Remove special edition notes
  29. name = name.split(' -')[0];
  30. // Split into brand and version
  31. version = name.match(/([0-9]+[\.0-9x]*)/);
  32. if (version) {
  33. version = version[0];
  34. }
  35. brand = name.replace(version, '');
  36. // Create the main data
  37. if (!brands[brand]) {
  38. brands[brand] = columns[1][i];
  39. } else {
  40. brands[brand] += columns[1][i];
  41. }
  42. // Create the version data
  43. if (version !== null) {
  44. if (!versions[brand]) {
  45. versions[brand] = [];
  46. }
  47. versions[brand].push(['v' + version, columns[1][i]]);
  48. }
  49. }
  50. });
  51. $.each(brands, function (name, y) {
  52. brandsData.push({
  53. name: name,
  54. y: y,
  55. drilldown: versions[name] ? name : null
  56. });
  57. });
  58. $.each(versions, function (key, value) {
  59. drilldownSeries.push({
  60. name: key,
  61. id: key,
  62. data: value
  63. });
  64. });
  65. // Create the chart
  66. $('#container').highcharts({
  67. chart: {
  68. type: 'column'
  69. },
  70. title: {
  71. text: 'Browser market shares. November, 2013'
  72. },
  73. subtitle: {
  74. text: 'Click the columns to view versions. Source: netmarketshare.com.'
  75. },
  76. xAxis: {
  77. type: 'category'
  78. },
  79. yAxis: {
  80. title: {
  81. text: 'Total percent market share'
  82. }
  83. },
  84. legend: {
  85. enabled: false
  86. },
  87. plotOptions: {
  88. series: {
  89. borderWidth: 0,
  90. dataLabels: {
  91. enabled: true,
  92. format: '{point.y:.1f}%'
  93. }
  94. }
  95. },
  96. tooltip: {
  97. headerFormat: '<span style="font-size:11px">{series.name}</span><br>',
  98. pointFormat: '<span style="color:{point.color}">{point.name}</span>: <b>{point.y:.2f}%</b> of total<br/>'
  99. },
  100. series: [{
  101. name: 'Brands',
  102. colorByPoint: true,
  103. data: brandsData
  104. }],
  105. drilldown: {
  106. series: drilldownSeries
  107. }
  108. })
  109. }
  110. });
  111. });
  112. </script>
  113. </head>
  114. <body>
  115. <script src="../../js/highcharts.js"></script>
  116. <script src="../../js/modules/data.js"></script>
  117. <script src="../../js/modules/drilldown.js"></script>
  118. <div id="container" style="min-width: 310px; height: 400px; margin: 0 auto"></div>
  119. <!-- Data from www.netmarketshare.com. Select Browsers => Desktop share by version. Download as tsv. -->
  120. <pre id="tsv" style="display:none">Browser Version Total Market Share
  121. Microsoft Internet Explorer 8.0 26.61%
  122. Microsoft Internet Explorer 9.0 16.96%
  123. Chrome 18.0 8.01%
  124. Chrome 19.0 7.73%
  125. Firefox 12 6.72%
  126. Microsoft Internet Explorer 6.0 6.40%
  127. Firefox 11 4.72%
  128. Microsoft Internet Explorer 7.0 3.55%
  129. Safari 5.1 3.53%
  130. Firefox 13 2.16%
  131. Firefox 3.6 1.87%
  132. Opera 11.x 1.30%
  133. Chrome 17.0 1.13%
  134. Firefox 10 0.90%
  135. Safari 5.0 0.85%
  136. Firefox 9.0 0.65%
  137. Firefox 8.0 0.55%
  138. Firefox 4.0 0.50%
  139. Chrome 16.0 0.45%
  140. Firefox 3.0 0.36%
  141. Firefox 3.5 0.36%
  142. Firefox 6.0 0.32%
  143. Firefox 5.0 0.31%
  144. Firefox 7.0 0.29%
  145. Proprietary or Undetectable 0.29%
  146. Chrome 18.0 - Maxthon Edition 0.26%
  147. Chrome 14.0 0.25%
  148. Chrome 20.0 0.24%
  149. Chrome 15.0 0.18%
  150. Chrome 12.0 0.16%
  151. Opera 12.x 0.15%
  152. Safari 4.0 0.14%
  153. Chrome 13.0 0.13%
  154. Safari 4.1 0.12%
  155. Chrome 11.0 0.10%
  156. Firefox 14 0.10%
  157. Firefox 2.0 0.09%
  158. Chrome 10.0 0.09%
  159. Opera 10.x 0.09%
  160. Microsoft Internet Explorer 8.0 - Tencent Traveler Edition 0.09%</pre>
  161. </body>
  162. </html>