echarts6.vue 1.5 KB

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