Browse Source

修改数据查询不规则数据在统计图中展示

zhoupeng 1 year ago
parent
commit
ba7cd41850

+ 11 - 1
industry-admin/src/views/source/dataQuery/index.vue

@@ -371,6 +371,7 @@ export default {
                 let data = res.data
                 this.chart = echarts.init(this.$refs.chart)
                 let legendData = []
+                let xAxisData = []
                 let seriesData = []
                 for (let a of data) {
                     legendData.push(a.describe ? a.describe : a.itemReadName)
@@ -394,6 +395,7 @@ export default {
                     }
                     let c = []
                     if (a.dataTimeList) {
+                        xAxisData = xAxisData.concat(a.dataTimeList)
                         for (let i in a.dataTimeList) {
                             const d = []
                             d.push(a.dataTimeList[i])
@@ -415,6 +417,7 @@ export default {
                     return b
                 }
                 this.legend.data = legendData
+                this.xAxis.data = xAxisData.filter((item, index) => xAxisData.indexOf(item) === index).sort()
                 this.yAxis[0].max = null
                 if (this.chartForm.range) {
                     this.yAxis[0].max = parseInt(this.chartForm.range)
@@ -498,10 +501,12 @@ export default {
         updateChartData() {
             this.getItemListValue((res) => {
                 let data = res.data
+                let xArr = this.xAxis.data
                 for (let i in data) {
                     let a = data[i]
                     let arr = this.series[i].data
                     if (a.dataTimeList) {
+                        xArr = xArr.concat(a.dataTimeList)
                         for (let j in a.dataTimeList) {
                             const b = []
                             b.push(a.dataTimeList[j])
@@ -509,8 +514,9 @@ export default {
                             arr.push(b)
                         }
                     }
-                    //删除多余数据
+                    //排序,并删除多余数据
                     if (arr) {
+                        // arr.sort((c, d) => c[0] - d[0])
                         let count = new Date(arr[arr.length - 1][0]).getTime() - this.count
                         let num = 0
                         for (let j in arr) {
@@ -522,6 +528,10 @@ export default {
                         this.series[i].data = arr.splice(num)
                     }
                 }
+                //更新x轴全部数据
+                xArr = xArr.filter((item, index) => xArr.indexOf(item) === index).sort()
+                this.xAxis.data = xArr.filter((i) =>
+                    new Date(i).getTime() >= (new Date(xArr[xArr.length - 1]).getTime() - this.count))
                 //更新统计图
                 if (this.chart) {
                     this.chart.setOption({ xAxis: this.xAxis, series: this.series })

File diff suppressed because it is too large
+ 1 - 1
industry-system/industry-da/src/main/resources/static/page/index.html


File diff suppressed because it is too large
+ 0 - 0
industry-system/industry-da/src/main/resources/static/page/static/js/app.a3375c01.js


File diff suppressed because it is too large
+ 0 - 0
industry-system/industry-da/src/main/resources/static/page/static/js/chunk-47652eb0.2b7c5839.js


File diff suppressed because it is too large
+ 0 - 0
industry-system/industry-da/src/main/resources/static/page/static/js/chunk-48625d50.02c45c15.js


File diff suppressed because it is too large
+ 0 - 0
industry-system/industry-da/src/main/resources/static/page/static/js/chunk-6e808086.718d54d6.js


Some files were not shown because too many files changed in this diff