bottomCard.vue 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. <template>
  2. <div id="bottom-card">
  3. <div :class="$style.chart_box">
  4. <!-- <div
  5. v-for="(item, index) in cards"
  6. :key="index"
  7. :class="$style.item"
  8. >
  9. <div :id="item" style="width: 100%; height: 100%"></div>
  10. </div> -->
  11. <div :class="$style.item">
  12. <div id="trust"></div>
  13. </div>
  14. <dv-decoration-2 :reverse="true" :dur="4" style="width:5px;height:100%;" />
  15. <!-- <div :class="$style.item">
  16. <div id="sample"></div>
  17. </div>
  18. <dv-decoration-2 :reverse="true" :dur="6" style="width:5px;height:100%;" /> -->
  19. <div :class="$style.item">
  20. <div id="month"></div>
  21. </div>
  22. <dv-decoration-2 :reverse="true" :dur="8" style="width:5px;height:100%;" />
  23. <div :class="$style.item">
  24. <div id="year"></div>
  25. </div>
  26. </div>
  27. </div>
  28. </template>
  29. <script>
  30. import echarts from 'echarts'
  31. import { trustOption, sampleOption, monthOption, yearOption } from '../data'
  32. export default {
  33. name: 'topBar',
  34. props: {
  35. info: {
  36. type: Object,
  37. default: {}
  38. }
  39. },
  40. components: {},
  41. watch: {
  42. info: {
  43. handler() {
  44. this.init()
  45. },
  46. deep: true
  47. }
  48. },
  49. data() {
  50. return {
  51. cards: ['trust', 'sample', 'month', 'year']
  52. }
  53. },
  54. created() {},
  55. mounted() {
  56. this.init()
  57. },
  58. methods: {
  59. init() {
  60. const trust = echarts.init(document.getElementById('trust'))
  61. // const sample = echarts.init(document.getElementById('sample'))
  62. const month = echarts.init(document.getElementById('month'))
  63. const year = echarts.init(document.getElementById('year'))
  64. // 设置图表数据
  65. trustOption.series[0].data = this.info.trust
  66. trustOption.series[1].data = this.info.accepted
  67. monthOption.series[0].data = this.info.task
  68. monthOption.series[1].data = this.info.complete
  69. // sampleOption.series[0].data = this.info.sample
  70. yearOption.series[0].data = this.info.year
  71. // 渲染
  72. trust.setOption(trustOption)
  73. // sample.setOption(sampleOption)
  74. month.setOption(monthOption)
  75. year.setOption(yearOption)
  76. }
  77. }
  78. }
  79. </script>
  80. <style lang="scss" module>
  81. .chart_box {
  82. position: relative;
  83. display: flex;
  84. justify-content: space-between;
  85. width: 100%;
  86. height: 100%;
  87. .item {
  88. width: 32.5%;
  89. height: 100%;
  90. background-color: rgba(6, 30, 93, 0.5);
  91. > div {
  92. width: 100%;
  93. height: 100%;
  94. }
  95. }
  96. }
  97. :global {
  98. #bottom-card {
  99. width: 96%;
  100. height: calc((100% - 240px) / 2);
  101. padding: 0 2%;
  102. }
  103. }
  104. </style>