topLeftChart.vue 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. <template>
  2. <div class="pieView">
  3. <div style=" height:14%;line-height:30px;text-align: left;padding-left: 10px;padding-left: 10px;padding-top: 10px; margin-bottom: -50px;color: white;">
  4. {{ info.title || "" }}
  5. </div>
  6. <div style="width: 100%; height: 95%; display: inline-block; overflow: hidden;padding-left: 10px;">
  7. <div id="topLeftChart" style="width: 100%; height: 100%; overflow: hidden" />
  8. </div>
  9. </div>
  10. </template>
  11. <script>
  12. import * as echarts from 'echarts'
  13. export default {
  14. props: {
  15. info: {
  16. type: Object,
  17. default: function () {
  18. return {}
  19. }
  20. }
  21. },
  22. data () {
  23. return {
  24. showChart: true,
  25. option: {
  26. tooltip: {
  27. trigger: 'axis',
  28. axisPointer: {
  29. type: 'shadow'
  30. }
  31. },
  32. // grid: {
  33. // left: '3%',
  34. // right: '4%',
  35. // bottom: '3%',
  36. // containLabel: true
  37. // },
  38. grid: {
  39. x: 50,
  40. y: 50,
  41. x2: 50,
  42. y2: 50
  43. },
  44. legend: {
  45. orient: 'vertical',
  46. left: 'center',
  47. bottom: 'bottom',
  48. textStyle: {
  49. color: '#ffff',
  50. fontSize: 12
  51. }
  52. },
  53. xAxis: [
  54. {
  55. type: 'category',
  56. data: [],
  57. axisTick: {
  58. alignWithLabel: true
  59. }
  60. }
  61. ],
  62. yAxis: [
  63. {
  64. interval: 10,
  65. type: 'value'
  66. }
  67. ],
  68. series: [
  69. {
  70. name: '计划项目',
  71. type: 'bar',
  72. barWidth: '60%',
  73. barMaxWidth: 30,
  74. data: []
  75. }
  76. ]
  77. }
  78. }
  79. },
  80. watch: {
  81. info: {
  82. handler (newVal, oldVal) {
  83. this.getMiddleLeft()
  84. },
  85. deep: true
  86. }
  87. },
  88. mounted () {
  89. const this_ = this
  90. this.$nextTick(() => {
  91. this_.getMiddleLeft()
  92. })
  93. },
  94. methods: {
  95. getMiddleLeft () {
  96. this.option.xAxis[0].data = this.info.yearArr
  97. this.option.series[0].data = this.info.numArr
  98. const chartDom = document.getElementById(this.info.id)
  99. var myChart = echarts.init(chartDom)
  100. console.log(this.option)
  101. setTimeout(() => {
  102. myChart.setOption(this.option)
  103. }, 500)
  104. }
  105. }
  106. }
  107. </script>
  108. <style lang="scss" scoped>
  109. .pieView {
  110. width: 100%;
  111. height: 100%;
  112. overflow: hidden;
  113. background-color: rgba(6, 30, 93, 0.5);
  114. }
  115. </style>