From a42a810052e04ea604bd3f0d80ea62110ed40577 Mon Sep 17 00:00:00 2001 From: jiang <1354748262@qq.com> Date: 星期五, 26 一月 2024 09:30:08 +0800 Subject: [PATCH] Merge remote-tracking branch 'origin/master' --- jcdm-ui/src/views/dashboard/LineChart.vue | 67 ++++++++++++--------------------- 1 files changed, 24 insertions(+), 43 deletions(-) diff --git a/jcdm-ui/src/views/dashboard/LineChart.vue b/jcdm-ui/src/views/dashboard/LineChart.vue index 4ab1c09..37320d2 100644 --- a/jcdm-ui/src/views/dashboard/LineChart.vue +++ b/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> -- Gitblit v1.9.3