| | |
| | | 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], |
| | |
| | | }, |
| | | data() { |
| | | return { |
| | | chart: null |
| | | chart: null, |
| | | data: [], |
| | | legendTitle: [], |
| | | } |
| | | }, |
| | | watch: { |
| | |
| | | } |
| | | }, |
| | | mounted() { |
| | | this.$nextTick(() => { |
| | | this.initChart() |
| | | }) |
| | | this.getData() |
| | | |
| | | }, |
| | | beforeDestroy() { |
| | | if (!this.chart) { |
| | |
| | | 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) |
| | |
| | | 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 |
| | | } |
| | | }, |
| | | type: 'category', |
| | | axisLabel: { |
| | | interval: 0, |
| | | rotate: 45, |
| | | }, |
| | | }, |
| | | grid: { |
| | | left: 10, |
| | | right: 10, |
| | | left: 20, |
| | | right: 20, |
| | | bottom: 20, |
| | | top: 30, |
| | | containLabel: true |
| | |
| | | yAxis: { |
| | | axisTick: { |
| | | show: false |
| | | } |
| | | }, |
| | | min:0, |
| | | max: this.data.length === 0 ? 100 : null |
| | | }, |
| | | 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> |