ScreenSyjhbydxqk.vue 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  1. <template>
  2. <div class="common-wrap">
  3. <div class="chart">
  4. <v-chart :option="option" autoresize/>
  5. </div>
  6. </div>
  7. </template>
  8. <script>
  9. import {chartSyjhbydxqk} from '@/api/dashboard-json'
  10. export default {
  11. name: 'ScreenSyjhbydxqk',
  12. data() {
  13. return {
  14. option: {}
  15. }
  16. },
  17. created() {
  18. this.getOption()
  19. },
  20. methods: {
  21. async getOption() {
  22. const arrMap = {
  23. '计划': [],
  24. '完成': []
  25. }
  26. const res = await chartSyjhbydxqk()
  27. if (res?.code === 200) {
  28. arrMap['计划'] = [
  29. res.info.series[0].data[0],
  30. res.info.series[2].data[0],
  31. res.info.series[4].data[0],
  32. res.info.series[6].data[0]
  33. ]
  34. arrMap['完成'] = [
  35. res.info.series[1].data[0],
  36. res.info.series[3].data[0],
  37. res.info.series[5].data[0],
  38. res.info.series[7].data[0]
  39. ]
  40. }
  41. this.option = {
  42. title: {},
  43. color: ['rgb(86, 202, 149)', 'rgb(96, 150, 230)'],
  44. tooltip: {
  45. trigger: 'axis'
  46. },
  47. legend: {
  48. data: ['计划', '完成'],
  49. position: 'top',
  50. textStyle: {
  51. color: '#ffffff',
  52. fontSize: this.EchartfontSize(18)
  53. }
  54. },
  55. toolbox: {
  56. show: true
  57. },
  58. calculable: true,
  59. xAxis: {
  60. type: 'category',
  61. // prettier-ignore
  62. data: ['开关分合本月', '开关分合本周', '单体本月', '单体本周'],
  63. axisLabel: {
  64. show: true,
  65. textStyle: {
  66. color: '#ffffff',
  67. fontSize: this.EchartfontSize(18)
  68. }
  69. }
  70. },
  71. yAxis: [
  72. {
  73. type: 'value'
  74. }
  75. ],
  76. series: [
  77. {
  78. name: '计划',
  79. type: 'bar',
  80. data: arrMap['计划']
  81. },
  82. {
  83. name: '完成',
  84. type: 'bar',
  85. data: arrMap['完成']
  86. }
  87. ]
  88. }
  89. }
  90. }
  91. }
  92. </script>
  93. <style lang="scss" scoped>
  94. .common-wrap {
  95. width: 100%;
  96. height: 100%;
  97. display: flex;
  98. align-items: center;
  99. justify-content: center;
  100. .chart {
  101. width: 90%;
  102. height: 90%;
  103. }
  104. }
  105. </style>