From 1721e42cc30e38148c0b3cf7dcbc2d04821a2704 Mon Sep 17 00:00:00 2001 From: little4 <360013221@qq.com> Date: Thu, 19 Sep 2024 11:10:19 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0chart1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../pages/service/analysis/charts.js | 61 +++---------------- .../pages/service/analysis/index.vue | 19 +++--- .../pages/service/analysis/search/index.vue | 16 +++-- 3 files changed, 28 insertions(+), 68 deletions(-) diff --git a/ruoyi-ui/src/views/JiHeExpressway/pages/service/analysis/charts.js b/ruoyi-ui/src/views/JiHeExpressway/pages/service/analysis/charts.js index d4a07e27..064bd531 100644 --- a/ruoyi-ui/src/views/JiHeExpressway/pages/service/analysis/charts.js +++ b/ruoyi-ui/src/views/JiHeExpressway/pages/service/analysis/charts.js @@ -1,7 +1,6 @@ import * as echarts from "echarts"; let options = { - color:['#00A3FF'], tooltip: { show: true, trigger: "axis", @@ -86,62 +85,16 @@ let options = { }, series: [ { - name: "事件数量", + name: "", + type: "bar", + barWidth: "10px", + selectedMode: false, + data: [], + },{ + name: "", type: "bar", barWidth: "10px", selectedMode: false, - select: { - itemStyle: { - opacity: 1, - color: function (params) { - var a = params; - - return new echarts.graphic.LinearGradient( - 0, - 0, - 0, - 1, - [ - { - offset: 0, - color: "#1AC5FD", // 0% 处的颜色 - }, - { - offset: 1, - color: "#003B4E", // 100% 处的颜色 - }, - ], - false - ); - }, - }, - }, - itemStyle: { - barBorderRadius: [10, 10, 10, 10], // 圆角(左上、右上、右下、左下) - // lenged文本 - opacity: 1, - color: function (params) { - var a = params.name; - // console.log("==========a=============", a); - return new echarts.graphic.LinearGradient( - 0, - 0, - 0, - 1, - [ - { - offset: 0, - color: "#00A3FF", // 0% 处的颜色 - }, - { - offset: 1, - color: "#00A3FF00", // 100% 处的颜色 - }, - ], - false - ); - }, - }, data: [], } ], diff --git a/ruoyi-ui/src/views/JiHeExpressway/pages/service/analysis/index.vue b/ruoyi-ui/src/views/JiHeExpressway/pages/service/analysis/index.vue index 911fd106..dedeb73e 100644 --- a/ruoyi-ui/src/views/JiHeExpressway/pages/service/analysis/index.vue +++ b/ruoyi-ui/src/views/JiHeExpressway/pages/service/analysis/index.vue @@ -144,26 +144,25 @@ export default { }).then(result=>{ if (result.code != 200) return this.$message.error(result?.msg); - this.tableCols = [{label:'路段桩号',value:'stake'},{label:'数量(起)',value:'num'}] + this.tableCols = [{label:'路段桩号',value:'stakeMark'},{label:query.thisTime+' 数量(起)',value:query.thisTime},{label:query.lastTime+' 数量(起)',value:query.lastTime}] let _tableData = [] - if(_.keys(result.data).length === 0){ + chartsOptions.series[0].name = query.thisTime; + chartsOptions.series[1].name = query.lastTime; + if(result.data.length === 0){ this.tableData = [] chartsOptions.series[0].data = [] + chartsOptions.series[1].data = [] this.myChart.setOption(chartsOptions); this.myChart.resize(); this.$message.warning('暂无数据') return; } - for(let i in result.data){ - _tableData.push({ - stake:i, num:result.data[i] - }) - } - this.tableData = _tableData; + this.tableData = result.data; this.curid = id; setTimeout(() => { - chartsOptions.series[0].data = _tableData.map(x=>x.num) - chartsOptions.xAxis.data = _tableData.map(x=>x.stake); + chartsOptions.series[0].data = _tableData.map(x=>x[query.thisTime]) + chartsOptions.series[1].data = _tableData.map(x=>x[query.lastTime]) + chartsOptions.xAxis.data = _tableData.map(x=>x.stakeMark); this.myChart.setOption(chartsOptions); this.myChart.resize(); }, 200); diff --git a/ruoyi-ui/src/views/JiHeExpressway/pages/service/analysis/search/index.vue b/ruoyi-ui/src/views/JiHeExpressway/pages/service/analysis/search/index.vue index 2b6dce55..bac2e84e 100644 --- a/ruoyi-ui/src/views/JiHeExpressway/pages/service/analysis/search/index.vue +++ b/ruoyi-ui/src/views/JiHeExpressway/pages/service/analysis/search/index.vue @@ -87,7 +87,7 @@ export default { } ], quarter: "2", - dateTime: [moment().format("YYYY-MM-DD"),moment().format("YYYY-MM-DD")], + dateTime: [moment().subtract(1,'years').format("YYYY-MM-DD"),moment().format("YYYY-MM-DD")], dataList: [], year: "", @@ -110,6 +110,7 @@ export default { this.dateTime = n; } } + } }, methods: { // 上传成功 @@ -144,11 +145,18 @@ export default { return filter; }, getStartTime(){ + if(this.dateTime.length === 1){ + if (this.type == 2) { + this.dateTime.unshift(moment(this.dateTime[0]).subtract(1,'days').format("YYYY-MM-DD")) + } else if(this.type == 1){ + this.dateTime.unshift(moment(this.dateTime[0]).subtract(1,'months').subtract.format("YYYY-MM-DD")) + } else { + this.dateTime.unshift(moment(this.dateTime[0]).subtract(1,'years').subtract.format("YYYY-MM-DD")) + } + } let thisTime = this.dateTime[0]; let lastTime = this.dateTime[1]; if (this.type == 2) { //日 - // startTime = moment(this.dateTime).format("YYYY-MM-DD 00:00:00"); - // endTime = moment(this.dateTime).format("YYYY-MM-DD 23:59:59"); thisTime = moment(this.dateTime[0]).format("YYYY-MM-DD"); lastTime = moment(this.dateTime[1]).format("YYYY-MM-DD"); } else if (this.type == 1) { //月 @@ -166,7 +174,7 @@ export default { this.reset = true; this.direction = "1"; this.type = "1"; - this.dateTime = moment().format("YYYY-MM-DD HH:mm:ss"); + this.dateTime = [moment().subtract(1,'years').format("YYYY-MM-DD"),moment().format("YYYY-MM-DD")]; this.$parent.bind() }, onQuery(){