DeliveryRateLine.vue 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141
  1. <template>
  2. <div class="delivery-rate-line" ref="DeliveryRateLine" v-if="workOrderOnTime.length>0"></div>
  3. </template>
  4. <script>
  5. import echarts from 'echarts'
  6. export default {
  7. name: 'DeliveryRateLine',
  8. data () {
  9. return {
  10. myChart: null,
  11. workOrderOnTimeNum: [],
  12. workOrderOnTimeName: []
  13. }
  14. },
  15. props: {
  16. workOrderOnTime: {
  17. type: Array,
  18. default: () => []
  19. }
  20. },
  21. methods: {
  22. // 画图
  23. draw () {
  24. this.myChart = echarts.init(this.$refs.DeliveryRateLine)
  25. const option = {
  26. title: {
  27. text: '按时送达率(%)',
  28. left: 15,
  29. textStyle: {
  30. color: '#d4d6d7',
  31. fontSize: 12
  32. }
  33. },
  34. xAxis: {
  35. type: 'category',
  36. axisLabel: {
  37. show: true,
  38. textStyle: {
  39. color: '#d4d6d7', // 更改坐标轴文字颜色
  40. fontSize: 12 // 更改坐标轴文字大小
  41. }
  42. },
  43. axisLine: {
  44. lineStyle: {
  45. color: '#709cc2' // 更改坐标轴颜色
  46. }
  47. },
  48. axisTick: {
  49. show: false
  50. },
  51. data: this.workOrderOnTimeName
  52. },
  53. yAxis: {
  54. type: 'value',
  55. max: 1,
  56. min: 0,
  57. interval: 0.25,
  58. axisLabel: {
  59. formatter (value) {
  60. return value * 100
  61. },
  62. show: true,
  63. textStyle: {
  64. color: '#d4d6d7', // 更改坐标轴文字颜色
  65. fontSize: 12 // 更改坐标轴文字大小
  66. }
  67. },
  68. axisLine: {
  69. lineStyle: {
  70. color: '#709cc2' // 更改坐标轴颜色
  71. }
  72. },
  73. axisTick: {
  74. show: false
  75. },
  76. splitLine: {
  77. // 网格线
  78. lineStyle: {
  79. color: ['rgba(255,255,255,0.1)'],
  80. type: 'dashed' // 设置网格线类型 dotted:虚线 solid:实线
  81. },
  82. show: true // 隐藏或显示
  83. }
  84. },
  85. grid: {
  86. top: '20%',
  87. bottom: '25%',
  88. left: '5%',
  89. right: '2%',
  90. borderColor: 'rgba(255,255,255,0.1)'
  91. },
  92. series: [
  93. {
  94. data: this.workOrderOnTimeNum,
  95. type: 'line',
  96. symbol: 'circle',
  97. symbolSize: 4,
  98. label: {
  99. show: true,
  100. position: 'top',
  101. textStyle: '#fff',
  102. formatter (params) {
  103. return (params.value * 100).toFixed(2) + '%'
  104. }
  105. },
  106. itemStyle: {
  107. normal: {
  108. color: '#70c282', // 折点颜色
  109. lineStyle: {
  110. color: '#70c282' // 折线颜色
  111. }
  112. }
  113. }
  114. }
  115. ]
  116. }
  117. this.myChart.setOption(option)
  118. }
  119. },
  120. updated () {
  121. this.workOrderOnTimeNum = []
  122. this.workOrderOnTimeName = []
  123. if (this.workOrderOnTime.length > 0) {
  124. this.workOrderOnTime.forEach(item => {
  125. this.workOrderOnTimeNum.push(item[1] / 100)
  126. this.workOrderOnTimeName.push(item[0])
  127. })
  128. this.draw()
  129. }
  130. }
  131. }
  132. </script>
  133. <style lang="less">
  134. .delivery-rate-line {
  135. height: 1.9375rem;
  136. margin: 0.2rem auto 0;
  137. }
  138. </style>