echarts6.vue 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. <template>
  2. <div ref="echarts6" class="echarts6"></div>
  3. </template>
  4. <style scoped lang="scss">
  5. .echarts6 {
  6. height: 18vh;
  7. width: 100%;
  8. }
  9. </style>
  10. <script setup>
  11. import * as echarts from 'echarts'
  12. const echarts6 = ref()
  13. onMounted(() => {
  14. echarts6View()
  15. })
  16. function echarts6View() {
  17. const myChart6 = echarts.init(echarts6.value)
  18. const option6 = {
  19. tooltip: {
  20. // 鼠标悬浮提示数据
  21. trigger: 'axis',
  22. backgroundColor: 'rgba(32, 33, 36,.7)',
  23. borderColor: 'rgba(32, 33, 36,0.20)',
  24. borderWidth: 15,
  25. textStyle: {
  26. // 文字提示样式
  27. color: '#fff',
  28. fontSize: '12'
  29. },
  30. axisPointer: {
  31. // 坐标轴虚线
  32. type: 'cross',
  33. label: {
  34. backgroundColor: '#6a7985'
  35. }
  36. }
  37. },
  38. // },
  39. grid: {
  40. // 控制图表的位置
  41. left: '5%',
  42. right: '5%',
  43. top: '10%',
  44. bottom: '5%',
  45. containLabel: true
  46. },
  47. xAxis: {
  48. axisLabel: {
  49. // X轴线 标签修改
  50. textStyle: {
  51. color: 'white', //坐标值得具体的颜色
  52. fontSize: '10'
  53. }
  54. },
  55. data: ['A', 'B', 'C', 'D', 'E', 'F']
  56. },
  57. yAxis: {
  58. axisLabel: {
  59. // y轴线 标签修改
  60. textStyle: {
  61. color: 'white' //坐标值得具体的颜色
  62. }
  63. }
  64. },
  65. series: [
  66. {
  67. data: [2549, 12421, 2637, 3146, 15189, 9562],
  68. type: 'bar',
  69. barWidth: '48%', //调整柱状图宽度
  70. itemStyle: {
  71. normal: {
  72. /*--------设置柱形图圆角 [左上角,右上角,右下角,左下角]-------------*/
  73. borderRadius: [12, 12, 0, 0],
  74. /*--------设置柱形图渐变色 -------------*/
  75. color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [
  76. {
  77. offset: 0,
  78. color: 'rgba(0,244,255,1)'
  79. },
  80. {
  81. offset: 1,
  82. color: 'rgba(0,77,167,1)'
  83. }
  84. ])
  85. }
  86. }
  87. }
  88. ]
  89. }
  90. myChart6.setOption(option6)
  91. window.addEventListener('resize', function () {
  92. myChart6.resize()
  93. })
  94. }
  95. </script>