pie3.html 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147
  1. <html>
  2. <head>
  3. <meta charset="utf-8">
  4. <script src="lib/esl.js"></script>
  5. <script src="lib/config.js"></script>
  6. <meta name="viewport" content="width=device-width, initial-scale=1" />
  7. </head>
  8. <body>
  9. <style>
  10. html, body {
  11. width: 100%;
  12. height: 100%;
  13. }
  14. .chart {
  15. width: 50%;
  16. height: 100%;
  17. float: left;
  18. }
  19. .tooltip-content {
  20. color: #000;
  21. width: 200px;
  22. text-align: center;
  23. margin-left: -100px;
  24. margin-top: -80px;
  25. }
  26. .tooltip-content h4 {
  27. font-size: 20px;
  28. color: #999;
  29. }
  30. .tooltip-content h5 {
  31. font-size: 28px;
  32. color: #666;
  33. }
  34. </style>
  35. <div id="main1" class="chart"></div>
  36. <div id="main2" class="chart"></div>
  37. <script>
  38. require([
  39. 'echarts'
  40. // 'echarts/chart/pie',
  41. // 'echarts/component/title',
  42. // 'echarts/component/legend',
  43. // 'echarts/component/tooltip'
  44. ], function (echarts) {
  45. var chart1 = echarts.init(document.getElementById('main1'), null, {
  46. });
  47. chart1.setOption({
  48. title: {
  49. text: 'hoverOffset: 10'
  50. },
  51. tooltip: {
  52. position: ['50%', '50%'],
  53. backgroundColor: 'trasparent',
  54. formatter: function (params) {
  55. return '<div class="tooltip-content">\
  56. <h4>' + params.name + '</h4>\
  57. <h5>' + (params.percent * 100).toFixed(1) + '%</h5>\
  58. </div>\
  59. ';
  60. }
  61. },
  62. series: [{
  63. name: 'pie',
  64. type: 'pie',
  65. selectedMode: 'single',
  66. selectedOffset: 30,
  67. clockwise: true,
  68. radius: ['20%', '40%'],
  69. label: {
  70. normal: {
  71. show: false
  72. }
  73. },
  74. labelLine: {
  75. show: false
  76. },
  77. data:[
  78. {value:379.5, name:'前任2:备胎反击战', selected: true},
  79. {value:252.7, name:'移动迷宫:烧痕审判'},
  80. {value:173.4, name:'绝命海拔'},
  81. {value:153.1, name:'剩者为王'},
  82. {value:49.4, name:'史努比:花生大电影'},
  83. {value:32.2, name:'山河故人'},
  84. {value:21.9, name:'蚁人'},
  85. {value:19.5, name:'夏洛特烦恼'}
  86. ]
  87. }]
  88. });
  89. var chart2 = echarts.init(document.getElementById('main2'), null, {
  90. });
  91. chart2.setOption({
  92. title: {
  93. text: 'hoverOffset: 50'
  94. },
  95. tooltip: {
  96. position: ['50%', '50%'],
  97. backgroundColor: 'trasparent',
  98. formatter: function (params) {
  99. return '<div class="tooltip-content">\
  100. <h4>' + params.name + '</h4>\
  101. <h5>' + (params.percent * 100).toFixed(1) + '%</h5>\
  102. </div>\
  103. ';
  104. }
  105. },
  106. series: [{
  107. name: 'pie',
  108. type: 'pie',
  109. selectedMode: 'single',
  110. selectedOffset: 30,
  111. hoverOffset: 50,
  112. clockwise: true,
  113. radius: ['20%', '40%'],
  114. label: {
  115. normal: {
  116. show: false
  117. }
  118. },
  119. labelLine: {
  120. show: false
  121. },
  122. data:[
  123. {value:379.5, name:'前任2:备胎反击战', selected: true},
  124. {value:252.7, name:'移动迷宫:烧痕审判'},
  125. {value:173.4, name:'绝命海拔'},
  126. {value:153.1, name:'剩者为王'},
  127. {value:49.4, name:'史努比:花生大电影'},
  128. {value:32.2, name:'山河故人'},
  129. {value:21.9, name:'蚁人'},
  130. {value:19.5, name:'夏洛特烦恼'}
  131. ]
  132. }]
  133. });
  134. });
  135. </script>
  136. </body>
  137. </html>