investCategoryNum.vue 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. <template>
  2. <div class="myChart" ref="myChart" :style="{height: height+'px'}">
  3. </div>
  4. </template>
  5. <script>
  6. import apiDashboard from "@/api/dashboard/apiDashboard";
  7. export default {
  8. data() {
  9. return {
  10. option: {
  11. color: ['#3AA7E6','#9790F8','#4ACFB8','#F4955F','#F8797E'],
  12. legend: {
  13. data: [
  14. '固定资产一级分类',
  15. '平均使用时间',
  16. ],
  17. },
  18. grid: {
  19. left: '2%', //默认10%
  20. right: '2%', //默认10%
  21. bottom: '0%', //默认60
  22. top: '15%',
  23. containLabel: true
  24. //grid区域是否包含坐标轴的刻度标签
  25. },
  26. xAxis: {
  27. type: 'category',
  28. data: ['办公室','局房类','个人办公类']
  29. },
  30. yAxis: [
  31. {
  32. name: '数量(件)',
  33. type: 'value',
  34. },
  35. {
  36. name: '时间(年)',
  37. type: 'value',
  38. },
  39. ],
  40. tooltip: {
  41. trigger: 'axis',
  42. axisPointer: {
  43. type: 'shadow'
  44. },
  45. textStyle: {
  46. color: '#fff',
  47. align: 'left',
  48. fontSize: 14
  49. },
  50. axisLine: {//x坐标轴轴线
  51. show: true,
  52. lineStyle: {//x坐标轴轴线样式
  53. color: '#000',//'#ccc' | 'rgb(128, 128, 128)' | 'rgba(128, 128, 128, 0.5)',设置标签颜色
  54. }
  55. },
  56. backgroundColor: 'rgba(0,0,0,0.8)',
  57. },
  58. series: [
  59. {
  60. name: '固定资产一级分类',
  61. data: [5,8,12],
  62. type: 'bar',
  63. yAxisIndex: 0,
  64. stack: 'A',
  65. barWidth: '30px',
  66. },
  67. {
  68. name: '平均使用时间',
  69. data: [2,3,4],
  70. yAxisIndex: 1,
  71. type: 'line',
  72. smooth:true,
  73. showSymbol:false,
  74. },
  75. ]
  76. }
  77. }
  78. },
  79. props: {
  80. height: Number,
  81. queryData: Object
  82. },
  83. mounted() {
  84. this.init()
  85. },
  86. methods: {
  87. init() {
  88. let chart = this.$echarts.init(this.$refs.myChart);
  89. this.chart = chart
  90. chart.setOption(this.option);
  91. this.getData();
  92. },
  93. getData() {
  94. //return apiDashboard.getMoneyDistributionData(this.queryData).then(res=>{
  95. // let data = this.$util.dataUtil.covertDataToEcharts(res, ['investment1','investment2','investment3','investment4','rateReturn'])
  96. // this.$util.dataUtil.refreshEchartsData(this.chart, this.option, data)
  97. //})
  98. }
  99. }
  100. }
  101. </script>
  102. <style lang="less" scoped>
  103. </style>