春风项目四线(合箱线、总装线)
wujian
2024-01-25 c6e06980cccbb86fa224633d3585f9164295bff1
jcdm-ui/src/views/dashboard/LineChart.vue
@@ -6,6 +6,7 @@
import * as echarts from 'echarts'
require('echarts/theme/macarons') // echarts theme
import resize from './mixins/resize'
import { getOffLineNum } from "@/api/main/bs/orderScheduling/orderScheduling";
export default {
  mixins: [resize],
@@ -33,7 +34,9 @@
  },
  data() {
    return {
      chart: null
      chart: null,
      data: [],
      legendTitle: [],
    }
  },
  watch: {
@@ -45,9 +48,8 @@
    }
  },
  mounted() {
    this.$nextTick(() => {
      this.initChart()
    })
    this.getData()
  },
  beforeDestroy() {
    if (!this.chart) {
@@ -57,6 +59,19 @@
    this.chart = null
  },
  methods: {
    getData(){
      getOffLineNum().then(res => {
        if (res.code === 200){
          this.data = res.rows
          this.data.forEach(x => {
            this.legendTitle.push(x.name)
          })
          this.$nextTick(() => {
            this.initChart()
          })
        }
      })
    },
    initChart() {
      this.chart = echarts.init(this.$el, 'macarons')
      this.setOptions(this.chartData)
@@ -68,7 +83,7 @@
          left: 'left' // 标题位置
        },
        xAxis: {
          data: ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun'],
          data: ['8:00', '9:00', '10:00','11:00', '12:00', '13:00', '14:00', '15:00', '16:00', '17:00', '18:00', '19:00', '20:00','21:00','22:00'],
          boundaryGap: false,
          axisTick: {
            show: false
@@ -94,46 +109,12 @@
          }
        },
        legend: {
          data: ['expected', 'actual']
          data: this.legendTitle
        },
        series: [{
          name: 'expected', itemStyle: {
            normal: {
              color: '#FF005A',
              lineStyle: {
                color: '#FF005A',
                width: 2
              }
            }
          },
          smooth: true,
          type: 'line',
          data: expectedData,
          animationDuration: 2800,
          animationEasing: 'cubicInOut'
        },
        {
          name: 'actual',
          smooth: true,
          type: 'line',
          itemStyle: {
            normal: {
              color: '#3888fa',
              lineStyle: {
                color: '#3888fa',
                width: 2
              },
              areaStyle: {
                color: '#f3f8ff'
              }
            }
          },
          data: actualData,
          animationDuration: 2800,
          animationEasing: 'quadraticOut'
        }]
        series: this.data
      })
    }
  }
  },
}
</script>