博客列表 >highcharts下鉆功能

highcharts下鉆功能

手机用户843026802
手机用户843026802原创
2019年12月19日 16:35:37714浏览

highcharts下鉆功能

  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <meta charset="utf-8">
  5. <!-- 引入 ECharts 文件 -->
  6. <script src='jquery-1.10.2.min.js'></script>
  7. <script src="echarts.min.js"></script>
  8. <script src="highcharts.js"></script>
  9. <script src="drilldown.js"></script>
  10. </head>
  11. <body>
  12. <!-- 准备一个具备大小(宽高)的 DOM -->
  13. <div id="main" style="width: 700px;height:500px;"></div>
  14. <script type="text/javascript">
  15. // Create the chart
  16. Highcharts.chart('main', {
  17. chart: {
  18. type: 'bar',
  19. events: {
  20. drilldown: function (e) {
  21. if (!e.seriesOptions) {
  22. var chart = this,
  23. drilldowns = result,
  24. series = drilldowns[e.point.id];
  25. console.info(drilldowns[e.point.id]);
  26. console.info(drilldowns[2]);
  27. // Show the loading label
  28. chart.showLoading('Simulating Ajax ...');
  29. setTimeout(function () {
  30. chart.hideLoading();
  31. if(series.length>1){//多图显示
  32. chart.addSingleSeriesAsDrilldown(e.point, series[0]);
  33. chart.addSingleSeriesAsDrilldown(e.point, series[1]);
  34. chart.applyDrilldown();
  35. }else{
  36. chart.addSeriesAsDrilldown(e.point, series[0]);
  37. }
  38. }, 1000);
  39. }
  40. }
  41. }
  42. },
  43. title: {
  44. text: 'Async drilldown'
  45. },
  46. xAxis: {
  47. type: 'category'
  48. },
  49. legend: {
  50. enabled: true
  51. },
  52. plotOptions: {
  53. pie: {
  54. allowPointSelect: true,
  55. cursor: 'pointer',
  56. dataLabels: {
  57. enabled: true,
  58. format: '{point.name}: {point.percentage:.1f}%'
  59. },
  60. showInLegend: true
  61. },
  62. series: {
  63. borderWidth: 0,
  64. dataLabels: {
  65. enabled: true
  66. },
  67. events:{
  68. click:function(e){
  69. if(e.point.toDetail){
  70. result={
  71. '22': [{
  72. "center": ["200", null],
  73. "id":'Fruitsid',
  74. "name": 'Fruits',
  75. "data": [
  76. ['Apples', 5],
  77. ['Oranges', 7],
  78. ['Bananas', 2]
  79. ],
  80. "type": 'pie',
  81. "size":300,
  82. },
  83. {
  84. "id":'Carsid',
  85. "name": 'Cars',
  86. "type": 'pie',
  87. "center": ["900", null],
  88. "size":300,
  89. "data": [
  90. ['Toyota', 1],
  91. ['Volkswagen', 2],
  92. ['Opel', 5]
  93. ]
  94. }]
  95. }
  96. }else{
  97. result={
  98. '1': [{
  99. id:'Animalsid',
  100. name: 'Animalsn',
  101. data:[{
  102. id:'22',
  103. name:'Cows',
  104. toDetail:true,
  105. y:2,
  106. drilldown: true
  107. },{
  108. id:'2',
  109. name:'Sheep',
  110. y:3,
  111. drilldown: true
  112. }
  113. ]
  114. }]
  115. }
  116. }
  117. }
  118. }
  119. }
  120. },
  121. series: [{
  122. name: 'Things1',
  123. colorByPoint: true,
  124. center: [200, null],
  125. size:300,
  126. data: [{
  127. id:'1',
  128. name: 'Animals',
  129. y: 5,
  130. drilldown: true
  131. }, {
  132. id:'2',
  133. name: 'Fruits',
  134. y: 2,
  135. drilldown: true
  136. }, {
  137. id:'3',
  138. name: 'Cars',
  139. y: 4,
  140. drilldown: true
  141. }]
  142. }
  143. ],
  144. drilldown: {
  145. series: [2]
  146. }
  147. });
  148. </script>
  149. </body>
  150. </html>

轉載收藏
版权声明:本文为博主原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。
本文链接:https://blog.csdn.net/u011320740/article/details/70800565

声明:本文内容转载自脚本之家,由网友自发贡献,版权归原作者所有,如您发现涉嫌抄袭侵权,请联系admin@php.cn 核实处理。
全部评论
文明上网理性发言,请遵守新闻评论服务协议