echarts5.vue 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. <template>
  2. <div>
  3. <div ref="echarts5" class="echarts5"></div>
  4. </div>
  5. </template>
  6. <style scoped>
  7. .echarts5 {
  8. height: 110px;
  9. width: 150px;
  10. }
  11. </style>
  12. <script setup>
  13. import * as echarts from 'echarts'
  14. const echarts5 = ref()
  15. onMounted(() => {
  16. drawEcharts5()
  17. })
  18. function drawEcharts5() {
  19. var myChart5 = echarts.init(echarts5.value)
  20. var b = 298
  21. var c = 523
  22. var d = b + c
  23. var option5 = {
  24. series: [
  25. {
  26. type: 'pie',
  27. radius: ['60%', '70%'],
  28. color: '#49bcf7',
  29. label: {
  30. normal: {
  31. position: 'center'
  32. }
  33. },
  34. data: [
  35. {
  36. value: c,
  37. name: '女消费',
  38. label: {
  39. normal: {
  40. formatter: c + '',
  41. textStyle: {
  42. fontSize: 20,
  43. color: '#fff'
  44. }
  45. }
  46. }
  47. },
  48. {
  49. value: b,
  50. name: '男消费',
  51. label: {
  52. normal: {
  53. formatter: function () {
  54. return '占比' + Math.round((c / d) * 100) + '%'
  55. },
  56. textStyle: {
  57. color: '#aaa',
  58. fontSize: 12
  59. }
  60. }
  61. },
  62. itemStyle: {
  63. normal: {
  64. color: 'rgba(255,255,255,.2)'
  65. },
  66. emphasis: {
  67. color: '#fff'
  68. }
  69. }
  70. }
  71. ]
  72. }
  73. ]
  74. }
  75. myChart5.setOption(option5)
  76. }
  77. </script>