pie3.html 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. <html>
  2. <head>
  3. <meta charset="utf-8">
  4. <script src="esl.js"></script>
  5. <script src="config.js"></script>
  6. <meta name="viewport" content="width=device-width, initial-scale=1" />
  7. </head>
  8. <body>
  9. <style>
  10. html, body, #main {
  11. width: 100%;
  12. height: 100%;
  13. }
  14. .tooltip-content {
  15. color: #000;
  16. width: 200px;
  17. text-align: center;
  18. margin-left: -100px;
  19. margin-top: -80px;
  20. }
  21. .tooltip-content h4 {
  22. font-size: 20px;
  23. color: #999;
  24. }
  25. .tooltip-content h5 {
  26. font-size: 28px;
  27. color: #666;
  28. }
  29. </style>
  30. <div id="main"></div>
  31. <script>
  32. require([
  33. 'echarts',
  34. 'echarts/chart/pie',
  35. 'echarts/component/legend',
  36. 'echarts/component/tooltip'
  37. ], function (echarts) {
  38. var chart = echarts.init(document.getElementById('main'), null, {
  39. renderer: 'canvas'
  40. });
  41. chart.setOption({
  42. tooltip: {
  43. position: ['50%', '50%'],
  44. backgroundColor: 'trasparent',
  45. formatter: function (params) {
  46. return '<div class="tooltip-content">\
  47. <h4>' + params.name + '</h4>\
  48. <h5>' + (params.percent * 100).toFixed(1) + '%</h5>\
  49. </div>\
  50. ';
  51. }
  52. },
  53. series: [{
  54. name: 'pie',
  55. type: 'pie',
  56. selectedMode: 'single',
  57. selectedOffset: 30,
  58. clockwise: true,
  59. radius: ['20%', '40%'],
  60. label: {
  61. normal: {
  62. show: false
  63. }
  64. },
  65. labelLine: {
  66. show: false
  67. },
  68. data:[
  69. {value:379.5, name:'前任2:备胎反击战', selected: true},
  70. {value:252.7, name:'移动迷宫:烧痕审判'},
  71. {value:173.4, name:'绝命海拔'},
  72. {value:153.1, name:'剩者为王'},
  73. {value:49.4, name:'史努比:花生大电影'},
  74. {value:32.2, name:'山河故人'},
  75. {value:21.9, name:'蚁人'},
  76. {value:19.5, name:'夏洛特烦恼'}
  77. ]
  78. }]
  79. });
  80. });
  81. </script>
  82. </body>
  83. </html>