echarts4.vue 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  1. <template>
  2. <div ref="echarts4" class="echarts4"></div>
  3. </template>
  4. <style scoped lang="scss">
  5. .echarts4 {
  6. height: 100%;
  7. width: 100%;
  8. }
  9. </style>
  10. <script setup>
  11. import * as echarts from 'echarts'
  12. const echarts4 = ref()
  13. onMounted(() => {
  14. echarts4View()
  15. })
  16. function echarts4View() {
  17. const myChart4 = echarts.init(echarts4.value)
  18. const option4 = {
  19. tooltip: {
  20. trigger: 'axis'
  21. },
  22. grid: {
  23. left: '5%',
  24. right: '0%',
  25. bottom: '10%',
  26. top: '5%'
  27. },
  28. legend: {
  29. orient: 'horizontal',
  30. x: '20px',
  31. y: '10px',
  32. itemGap: 50, //图例之间间距
  33. itemWidth: 12, //图例宽
  34. itemHeight: 12, //图例高
  35. icon: 'circle',
  36. textStyle: {
  37. fontSize: 14 //更改坐标轴文字大小
  38. }
  39. },
  40. xAxis: {
  41. type: 'category',
  42. axisTick: {
  43. //x轴刻度尺
  44. show: false,
  45. alignWithLabel: true
  46. },
  47. axisLine: {
  48. //x轴线条颜色
  49. show: true,
  50. lineStyle: {
  51. color: '#dadada',
  52. width: 0.5
  53. }
  54. },
  55. axisLabel: {
  56. //x轴文字倾斜
  57. show: true,
  58. textStyle: {
  59. color: '#333', //更改坐标轴文字颜色
  60. fontSize: 14 //更改坐标轴文字大小
  61. }
  62. },
  63. data: ['1月', '2月', '3月', '4月', '5月', '6月', '7月', '8月', '9月', '10月', '11月', '12月']
  64. },
  65. yAxis: {
  66. type: 'value',
  67. name: '',
  68. nameTextStyle: {
  69. padding: [0, 30, 5, 0], // y轴name位置
  70. color: '#333', //更改坐标轴文字颜色
  71. fontSize: 14 //更改坐标轴文字大小
  72. },
  73. splitLine: {
  74. show: true, //关闭网格线
  75. lineStyle: {
  76. color: '#dadada',
  77. width: 0.5
  78. }
  79. },
  80. axisLine: {
  81. //y轴线条颜色
  82. show: false
  83. },
  84. axisTick: {
  85. //x轴刻度
  86. show: false
  87. },
  88. axisLabel: {
  89. //y轴文字倾斜
  90. textStyle: {
  91. color: '#333', //更改坐标轴文字颜色
  92. fontSize: 14 //更改坐标轴文字大小
  93. }
  94. }
  95. },
  96. series: [
  97. {
  98. type: 'line',
  99. stack: 'Total',
  100. symbolSize: 8, //设定实心点的大小
  101. smooth: true, //面积图改成弧形状
  102. lineStyle: {
  103. normal: {
  104. color: '#168eff', //外边线颜色
  105. width: 3, //外边线宽度
  106. shadowColor: '#168eff', //线阴影颜色
  107. shadowOffsetY: 10, //阴影大小
  108. shadowBlur: 15
  109. }
  110. },
  111. itemStyle: {
  112. normal: {
  113. //节点颜色
  114. color: '#168eff'
  115. }
  116. },
  117. showSymbol: true, //去除面积图节点圆
  118. data: [148, 108, 96, 95, 84, 69, 123, 160, 190, 123, 251, 220]
  119. }
  120. ]
  121. }
  122. myChart4.setOption(option4)
  123. window.addEventListener('resize', function () {
  124. myChart4.resize()
  125. })
  126. }
  127. </script>