pie-digits.html 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. <html>
  2. <head>
  3. <meta charset="utf-8">
  4. <script src="lib/esl.js"></script>
  5. <script src="lib/config.js"></script>
  6. </head>
  7. <body>
  8. <style>
  9. html, body, #main {
  10. width: 100%;
  11. height: 100%;
  12. }
  13. </style>
  14. <div id="main"></div>
  15. <script>
  16. require([
  17. 'echarts'
  18. // 'echarts/chart/pie',
  19. // 'echarts/component/tooltip',
  20. // 'echarts/component/title'
  21. ], function (echarts) {
  22. var chart = echarts.init(document.getElementById('main'), null, {
  23. });
  24. chart.setOption({
  25. tooltip: {
  26. formatter: '{d}%'
  27. },
  28. title: {
  29. text: '饼图百分比始终为 100%'
  30. },
  31. series : [
  32. {
  33. type : 'pie',
  34. center : ['25%', '50%'],
  35. radius : '50%',
  36. percentPrecision: 1,
  37. data : [1235, 6332, 2433],
  38. label: {
  39. normal: {
  40. formatter: '{c} 占 {d}%'
  41. }
  42. }
  43. },
  44. {
  45. type : 'pie',
  46. center : ['75%', '50%'],
  47. radius : '50%',
  48. percentPrecision: 0,
  49. data : [0.27, .14, 2.43, 1.16, '-'],
  50. label: {
  51. normal: {
  52. formatter: '{c} 占 {d}%'
  53. }
  54. }
  55. }
  56. ]
  57. });
  58. })
  59. </script>
  60. </body>
  61. </html>