echarts1.vue 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. <template>
  2. <div ref="echarts1" class="echarts1"></div>
  3. </template>
  4. <style scoped lang="scss">
  5. .echarts1 {
  6. height: 100%;
  7. width: 100%;
  8. }
  9. </style>
  10. <script setup>
  11. import * as echarts from 'echarts'
  12. const echarts1 = ref()
  13. onMounted(() => {
  14. echarts1View()
  15. })
  16. function echarts1View() {
  17. const myChart1 = echarts.init(echarts1.value)
  18. const option1 = {
  19. tooltip: {
  20. trigger: 'item'
  21. },
  22. legend: {
  23. orient: 'vertical',
  24. left: 'left'
  25. },
  26. series: [
  27. {
  28. name: '分区状态',
  29. type: 'pie',
  30. radius: '80%',
  31. itemStyle: {
  32. normal: {
  33. label: {
  34. show: true,
  35. formatter: '{b} : ({c})'
  36. }
  37. },
  38. labelLine: { show: true }
  39. },
  40. data: [
  41. { value: 5, name: '满载' },
  42. { value: 24, name: '空闲' }
  43. ],
  44. emphasis: {
  45. itemStyle: {
  46. shadowBlur: 10,
  47. shadowOffsetX: 0,
  48. shadowColor: 'rgba(0, 0, 0, 0.5)'
  49. }
  50. }
  51. }
  52. ]
  53. }
  54. myChart1.setOption(option1)
  55. window.addEventListener('resize', function () {
  56. myChart1.resize()
  57. })
  58. }
  59. </script>