市长热线演示版

index.htm 4.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172
  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: 'pie'
  69. },
  70. title: {
  71. text: 'Browser market shares. November, 2013.'
  72. },
  73. subtitle: {
  74. text: 'Click the slices to view versions. Source: netmarketshare.com.'
  75. },
  76. plotOptions: {
  77. series: {
  78. dataLabels: {
  79. enabled: true,
  80. format: '{point.name}: {point.y:.1f}%'
  81. }
  82. }
  83. },
  84. tooltip: {
  85. headerFormat: '<span style="font-size:11px">{series.name}</span><br>',
  86. pointFormat: '<span style="color:{point.color}">{point.name}</span>: <b>{point.y:.2f}%</b> of total<br/>'
  87. },
  88. series: [{
  89. name: 'Brands',
  90. colorByPoint: true,
  91. data: brandsData
  92. }],
  93. drilldown: {
  94. series: drilldownSeries
  95. }
  96. })
  97. }
  98. });
  99. });
  100. </script>
  101. </head>
  102. <body>
  103. <script src="../../js/highcharts.js"></script>
  104. <script src="../../js/modules/data.js"></script>
  105. <script src="../../js/modules/drilldown.js"></script>
  106. <div id="container" style="min-width: 310px; max-width: 600px; height: 400px; margin: 0 auto"></div>
  107. <!-- Data from www.netmarketshare.com. Select Browsers => Desktop share by version. Download as tsv. -->
  108. <pre id="tsv" style="display:none">Browser Version Total Market Share
  109. Microsoft Internet Explorer 8.0 26.61%
  110. Microsoft Internet Explorer 9.0 16.96%
  111. Chrome 18.0 8.01%
  112. Chrome 19.0 7.73%
  113. Firefox 12 6.72%
  114. Microsoft Internet Explorer 6.0 6.40%
  115. Firefox 11 4.72%
  116. Microsoft Internet Explorer 7.0 3.55%
  117. Safari 5.1 3.53%
  118. Firefox 13 2.16%
  119. Firefox 3.6 1.87%
  120. Opera 11.x 1.30%
  121. Chrome 17.0 1.13%
  122. Firefox 10 0.90%
  123. Safari 5.0 0.85%
  124. Firefox 9.0 0.65%
  125. Firefox 8.0 0.55%
  126. Firefox 4.0 0.50%
  127. Chrome 16.0 0.45%
  128. Firefox 3.0 0.36%
  129. Firefox 3.5 0.36%
  130. Firefox 6.0 0.32%
  131. Firefox 5.0 0.31%
  132. Firefox 7.0 0.29%
  133. Proprietary or Undetectable 0.29%
  134. Chrome 18.0 - Maxthon Edition 0.26%
  135. Chrome 14.0 0.25%
  136. Chrome 20.0 0.24%
  137. Chrome 15.0 0.18%
  138. Chrome 12.0 0.16%
  139. Opera 12.x 0.15%
  140. Safari 4.0 0.14%
  141. Chrome 13.0 0.13%
  142. Safari 4.1 0.12%
  143. Chrome 11.0 0.10%
  144. Firefox 14 0.10%
  145. Firefox 2.0 0.09%
  146. Chrome 10.0 0.09%
  147. Opera 10.x 0.09%
  148. Microsoft Internet Explorer 8.0 - Tencent Traveler Edition 0.09%</pre>
  149. </body>
  150. </html>