preWorkChart.vue 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164
  1. <template>
  2. <div class="statisticsPage" :style="{width:width,height:height}">
  3. <div v-show="show" :id="'prew'+id" :style="{height:'100%',width:'100%'}"/>
  4. <div v-show="!show" :style="{height:'100%'}">
  5. <div style="height:8%;font-size:24px;font-weight: 600;"> {{ title }} </div>
  6. <div class="nullShow">暂无数据</div>
  7. </div>
  8. </div>
  9. </template>
  10. <script>
  11. import * as echarts from 'echarts'
  12. import { getFormatDate } from '../utils/config.js'
  13. export default {
  14. props: {
  15. value: {
  16. type: Array,
  17. },
  18. width:{
  19. type:String,
  20. default:"100%"
  21. },
  22. height:{
  23. type:String,
  24. default: "100%"
  25. },
  26. id:{
  27. type:Number,
  28. default:0
  29. },
  30. click:{
  31. type:String,
  32. default:'true'
  33. },
  34. colorw:{
  35. type:String,
  36. default:'#fff'
  37. },
  38. title:{
  39. type: String
  40. },
  41. data: {
  42. type: Array,
  43. }
  44. },
  45. data () {
  46. return {
  47. show: false
  48. }
  49. },
  50. watch: {
  51. value: {
  52. handler (val, old) {
  53. if(val.length>0){
  54. this.show = true
  55. setTimeout(() => {
  56. this.drawLine()
  57. }, 100)
  58. }else{
  59. this.show = false
  60. }
  61. // this.drawLine()
  62. },
  63. deep: true
  64. }
  65. },
  66. mounted(){
  67. // setTimeout(() => {
  68. // this.drawLine()
  69. // }, 100);
  70. },
  71. methods: {
  72. drawLine(){
  73. let xData = []
  74. let yData = []
  75. // let yData1 = []
  76. // let yData2 = []
  77. this.value.forEach(e => {
  78. xData.push(e.date)
  79. yData.push(e.num)
  80. // yData1.push(e.numUn)
  81. // yData2.push(e.numAll)
  82. })
  83. const that = this
  84. echarts.dispose(document.getElementById('prew'+this.id))
  85. let pre = echarts.init(document.getElementById('prew'+this.id))
  86. let option
  87. option = {
  88. title: {
  89. text: this.title,
  90. left: 'left',
  91. textStyle:{ fontSize:24,color: this.colorw }
  92. },
  93. grid: {
  94. left: '3%',
  95. right: '1%',
  96. bottom: '10%'
  97. },
  98. tooltip: {
  99. trigger: 'axis',
  100. axisPointer: {
  101. type: 'cross',
  102. crossStyle: {
  103. color: '#999'
  104. }
  105. },
  106. },
  107. xAxis: {
  108. type: 'category',
  109. boundaryGap: true,
  110. data: xData,
  111. axisLabel: {
  112. color: '#fff'
  113. },
  114. axisTick: {
  115. alignWithLabel: true
  116. }
  117. },
  118. yAxis: {
  119. type: 'value',
  120. axisLabel: {
  121. color: '#fff'
  122. },
  123. splitLine:{
  124. show:true,
  125. lineStyle:{
  126. type: [15,8],
  127. color: ['rgba(255,255,255,0.5)'],
  128. }
  129. }
  130. },
  131. series: [
  132. {
  133. // name: 'num',
  134. type: 'bar',
  135. barWidth: 20,
  136. color: 'rgb(16,142,233)',
  137. data: yData
  138. }
  139. ]
  140. };
  141. option && pre.setOption(option);
  142. },
  143. }
  144. }
  145. </script>
  146. <style scoped>
  147. /* #zlmbPie:hover{
  148. transition: all 0.5s;
  149. transform:scale(1.03);
  150. } */
  151. .statisticsPage{
  152. box-shadow: 0 2px 12px 0 rgba(0, 0, 0, 0.1);
  153. padding: 1%;
  154. /* background-color: rgba(6, 30, 93, 0.5); */
  155. }
  156. .nullShow{
  157. display: flex;
  158. align-items: center;
  159. justify-content: center;
  160. font-size: 18px;
  161. height: 92%;
  162. }
  163. </style>