LeftChart2.vue 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  1. <template>
  2. <div class="left-chart-2">
  3. <dv-charts class="lc2-chart" :option="option" />
  4. </div>
  5. </template>
  6. <script>
  7. import { addDevice } from "@/api/system/equdata";
  8. export default {
  9. name: "LeftChart2",
  10. props:{
  11. xlist:{
  12. type:Array,
  13. default:[],
  14. },
  15. ylist:{
  16. type:Array,
  17. default:[],
  18. }
  19. },
  20. data() {
  21. return {
  22. option: {
  23. title: {
  24. show: false,
  25. },
  26. grid: {
  27. top: 30,
  28. bottom: 20,
  29. },
  30. xAxis: {
  31. name: "",
  32. data: this.xlist,
  33. boundaryGap: false,
  34. // data: ['周一', '周二', '周三'],
  35. axisLine: {
  36. style: {
  37. stroke: "#324686",
  38. lineWidth: 1,
  39. },
  40. },
  41. axisLabel: {
  42. style: {
  43. fill: "#fff",
  44. fontSize: 10,
  45. rotate: 0,
  46. },
  47. },
  48. axisTick:{
  49. show: false,
  50. },
  51. },
  52. yAxis: {
  53. name: "",
  54. data: "value",
  55. min:0,
  56. splitLine: {
  57. // show:false,
  58. style: {
  59. stroke: "#09111e",
  60. lineWidth: 1,
  61. },
  62. },
  63. nameTextStyle:{
  64. fill: '#09111e',
  65. fontSize: 10
  66. },
  67. axisLabel: {
  68. style: {
  69. fill: "#fff",
  70. fontSize: 10,
  71. rotate: 0,
  72. },
  73. },
  74. axisLine: {
  75. style: {
  76. stroke: "#324686",
  77. lineWidth: 1,
  78. },
  79. },
  80. axisTick:{
  81. show: false,
  82. }
  83. },
  84. series: [
  85. {
  86. data: this.ylist,
  87. type: "line",
  88. label:{
  89. show:true,
  90. },
  91. // animationCurve:'easeOutCubic',
  92. lineArea: {
  93. show: true,
  94. gradient: ["rgba(55, 162, 218, 0.6)", "rgba(55, 162, 218, 0)"],
  95. },
  96. },
  97. ],
  98. },
  99. };
  100. },
  101. created() {
  102. this.getEquData();
  103. },
  104. methods: {
  105. getEquData() {
  106. addDevice().then(res=>{
  107. let xlist=res.data.map(item=>item.month)
  108. let ylist=res.data.map(item=>item.count)
  109. this.option.xAxis.data=xlist
  110. this.option.series[0].data=ylist
  111. })
  112. },
  113. },
  114. };
  115. </script>
  116. <style lang="scss" scoped>
  117. .left-chart-2 {
  118. width: 100%;
  119. height: 100%;
  120. display: flex;
  121. flex-direction: column;
  122. .lc2-chart {
  123. height: calc(100% - 80px);
  124. position: relative;
  125. }
  126. }
  127. </style>