index.vue 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. <template>
  2. <div>
  3. <Echart
  4. :options="options"
  5. id="up2Chart"
  6. height="200px"
  7. width="100%"
  8. ></Echart>
  9. </div>
  10. </template>
  11. <script>
  12. import Echart from '@/common/echart'
  13. export default {
  14. data() {
  15. return {
  16. options: {},
  17. // 定义颜色
  18. }
  19. },
  20. components: {
  21. Echart
  22. },
  23. props: {
  24. bardata: {
  25. type: Object,
  26. default: () => ({})
  27. }
  28. },
  29. watch: {
  30. bardata: {
  31. handler(newData) {
  32. this.options = {
  33. tooltip: {
  34. trigger: 'axis',
  35. axisPointer: {
  36. type: 'shadow'
  37. }
  38. },
  39. legend: {
  40. bottom: "80%",
  41. textStyle: {
  42. fontSize: 20
  43. }
  44. },
  45. grid: {
  46. left: '3%',
  47. right: '4%',
  48. bottom: 20,
  49. containLabel: true
  50. },
  51. xAxis: {
  52. type: 'value',
  53. max: newData.max
  54. },
  55. // 下方Y轴
  56. yAxis: {
  57. type:'category',
  58. data:newData.yAxis,
  59. axisLabel: {
  60. fontSize: 25,
  61. // fontWeight: "bold"
  62. }
  63. },
  64. series: [
  65. {
  66. name: '计划数',
  67. type: 'bar',
  68. data: newData.planData,
  69. label: {
  70. show: true,
  71. position: 'right',
  72. fontSize:16,
  73. fontWeight: "bold",
  74. color: "inherit"
  75. },
  76. barWidth: 16,
  77. itemStyle: {
  78. color: "#ABA5FC"
  79. },
  80. },
  81. {
  82. name: '实际数',
  83. type: 'bar',
  84. data: newData.actData,
  85. label: {
  86. show: true,
  87. position: 'right',
  88. fontSize:16,
  89. fontWeight: "bold",
  90. color: "inherit"
  91. },
  92. barWidth: 16,
  93. itemStyle: {
  94. color: "#8CF9B8"
  95. },
  96. }
  97. ]
  98. }
  99. },
  100. immediate: true,
  101. deep: true
  102. }
  103. }
  104. }
  105. </script>