echarts3.vue 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. <template>
  2. <div ref="echarts2" class="echarts2"></div>
  3. </template>
  4. <style scoped lang="scss">
  5. .echarts2 {
  6. height: 18vh;
  7. width: 100%;
  8. }
  9. </style>
  10. <script setup>
  11. import * as echarts from 'echarts'
  12. const echarts2 = ref()
  13. onMounted(() => {
  14. echarts2View()
  15. })
  16. function echarts2View() {
  17. const myChart2 = echarts.init(echarts2.value)
  18. const option2 = {
  19. series: [
  20. {
  21. type: 'pie',
  22. radius: ['55%', '70%'],
  23. color: ['#1E90FF', '#00FFFF', '#B0E0E6', '#00BFFF'],
  24. avoidLabelOverlap: false,
  25. label: {
  26. alignTo: 'labelLine',
  27. lineHeight: 15,
  28. edgeDistance: 10,
  29. color: '#FFFFFF',
  30. fontSize: '14'
  31. },
  32. emphasis: {
  33. label: {
  34. show: false
  35. }
  36. },
  37. labelLine: {
  38. show: true
  39. },
  40. data: [
  41. { value: 1048, name: '软件' },
  42. { value: 735, name: '互联网' },
  43. { value: 1048, name: '大数据' },
  44. { value: 735, name: '通信' }
  45. ]
  46. }
  47. ]
  48. }
  49. myChart2.setOption(option2)
  50. window.addEventListener('resize', function () {
  51. myChart2.resize()
  52. })
  53. }
  54. </script>