From 5d7f1158d37b64d5fc6c34df962afc9486fb615b Mon Sep 17 00:00:00 2001 From: zhenghuang <236220500@qq.com> Date: Sun, 28 Nov 2021 15:38:32 +0800 Subject: [PATCH] =?UTF-8?q?=E7=99=BE=E5=88=86=E6=AF=94=E7=BB=84=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../provider/mysql/MysqlQueryProvider.java | 6 +- .../src/components/widget/DeWidget/DeDate.vue | 107 +++--- .../views/chart/components/ChartComponent.vue | 181 +++++++--- .../chart/components/ChartComponentG2.vue | 24 +- .../chart/components/table/TableNormal.vue | 308 +++++++++-------- .../src/views/panel/list/PanelViewShow.vue | 324 ++++++++++-------- 6 files changed, 569 insertions(+), 381 deletions(-) diff --git a/backend/src/main/java/com/ipsos/provider/mysql/MysqlQueryProvider.java b/backend/src/main/java/com/ipsos/provider/mysql/MysqlQueryProvider.java index 01841ce..559fbf3 100644 --- a/backend/src/main/java/com/ipsos/provider/mysql/MysqlQueryProvider.java +++ b/backend/src/main/java/com/ipsos/provider/mysql/MysqlQueryProvider.java @@ -414,7 +414,7 @@ public class MysqlQueryProvider extends QueryProvider { } String fieldAlias = String.format(SQLConstants.FIELD_ALIAS_Y_PREFIX, i); // 处理纵轴字段 - yFields.add(getYFields(y, originField, fieldAlias)); + yFields.add(getYFields(y, originField, fieldAlias, table)); // 处理纵轴过滤 yWheres.addAll(getYWheres(y, originField, fieldAlias)); // 处理纵轴排序 @@ -528,7 +528,7 @@ public class MysqlQueryProvider extends QueryProvider { } String fieldAlias = String.format(SQLConstants.FIELD_ALIAS_Y_PREFIX, i); // 处理纵轴字段 - yFields.add(getYFields(y, originField, fieldAlias)); + yFields.add(getYFields(y, originField, fieldAlias, table)); // 处理纵轴过滤 yWheres.addAll(getYWheres(y, originField, fieldAlias)); // 处理纵轴排序 @@ -615,7 +615,7 @@ public class MysqlQueryProvider extends QueryProvider { } String fieldAlias = String.format(SQLConstants.FIELD_ALIAS_Y_PREFIX, i); // 处理纵轴字段 - yFields.add(getYFields(y, originField, fieldAlias)); + yFields.add(getYFields(y, originField, fieldAlias, table)); // 处理纵轴过滤 yWheres.addAll(getYWheres(y, originField, fieldAlias)); // 处理纵轴排序 diff --git a/frontend/src/components/widget/DeWidget/DeDate.vue b/frontend/src/components/widget/DeWidget/DeDate.vue index 4018dd5..14ac352 100644 --- a/frontend/src/components/widget/DeWidget/DeDate.vue +++ b/frontend/src/components/widget/DeWidget/DeDate.vue @@ -1,6 +1,6 @@ - + diff --git a/frontend/src/views/chart/components/ChartComponent.vue b/frontend/src/views/chart/components/ChartComponent.vue index 5cf336e..0e78713 100644 --- a/frontend/src/views/chart/components/ChartComponent.vue +++ b/frontend/src/views/chart/components/ChartComponent.vue @@ -1,7 +1,17 @@ @@ -19,7 +29,12 @@ import { BASE_TREEMAP, BASE_MIX } from '../chart/chart' -import { baseBarOption, stackBarOption, horizontalBarOption, horizontalStackBarOption } from '../chart/bar/bar' +import { + baseBarOption, + stackBarOption, + horizontalBarOption, + horizontalStackBarOption +} from '../chart/bar/bar' import { baseLineOption, stackLineOption } from '../chart/line/line' import { basePieOption, rosePieOption } from '../chart/pie/pie' import { baseMapOption } from '../chart/map/map' @@ -101,22 +116,30 @@ export default { // 基于准备好的dom,初始化echarts实例 // 渲染echart等待dom加载完毕,渲染之前先尝试销毁具有相同id的echart 放置多次切换仪表板有重复id情况 const that = this - new Promise((resolve) => { resolve() }).then(() => { + new Promise((resolve) => { + resolve() + }).then(() => { // 此dom为echarts图标展示dom - this.myChart = this.$echarts.getInstanceByDom(document.getElementById(this.chartId)) + this.myChart = this.$echarts.getInstanceByDom( + document.getElementById(this.chartId) + ) if (!this.myChart) { - this.myChart = this.$echarts.init(document.getElementById(this.chartId)) + this.myChart = this.$echarts.init( + document.getElementById(this.chartId) + ) } this.drawEcharts() this.myChart.off('click') this.myChart.on('click', function(param) { that.pointParam = param - if (that.trackMenu.length < 2) { // 只有一个事件直接调用 + if (that.trackMenu.length < 2) { + // 只有一个事件直接调用 that.trackClick(that.trackMenu[0]) - } else { // 视图关联多个事件 + } else { + // 视图关联多个事件 that.trackBarStyle.left = param.event.offsetX + 'px' - that.trackBarStyle.top = (param.event.offsetY - 15) + 'px' + that.trackBarStyle.top = param.event.offsetY - 15 + 'px' that.$refs.viewTrack.trackButtonClick() } }) @@ -127,33 +150,75 @@ export default { let chart_option = {} // type if (chart.type === 'bar') { - chart_option = baseBarOption(JSON.parse(JSON.stringify(BASE_BAR)), chart) + chart_option = baseBarOption( + JSON.parse(JSON.stringify(BASE_BAR)), + chart + ) } else if (chart.type === 'bar-stack') { - chart_option = stackBarOption(JSON.parse(JSON.stringify(BASE_BAR)), chart) + chart_option = stackBarOption( + JSON.parse(JSON.stringify(BASE_BAR)), + chart + ) } else if (chart.type === 'bar-horizontal') { - chart_option = horizontalBarOption(JSON.parse(JSON.stringify(HORIZONTAL_BAR)), chart) + chart_option = horizontalBarOption( + JSON.parse(JSON.stringify(HORIZONTAL_BAR)), + chart + ) } else if (chart.type === 'bar-stack-horizontal') { - chart_option = horizontalStackBarOption(JSON.parse(JSON.stringify(HORIZONTAL_BAR)), chart) + chart_option = horizontalStackBarOption( + JSON.parse(JSON.stringify(HORIZONTAL_BAR)), + chart + ) } else if (chart.type === 'line') { - chart_option = baseLineOption(JSON.parse(JSON.stringify(BASE_LINE)), chart) + chart_option = baseLineOption( + JSON.parse(JSON.stringify(BASE_LINE)), + chart + ) } else if (chart.type === 'line-stack') { - chart_option = stackLineOption(JSON.parse(JSON.stringify(BASE_LINE)), chart) + chart_option = stackLineOption( + JSON.parse(JSON.stringify(BASE_LINE)), + chart + ) } else if (chart.type === 'pie') { - chart_option = basePieOption(JSON.parse(JSON.stringify(BASE_PIE)), chart) + chart_option = basePieOption( + JSON.parse(JSON.stringify(BASE_PIE)), + chart + ) } else if (chart.type === 'pie-rose') { - chart_option = rosePieOption(JSON.parse(JSON.stringify(BASE_PIE)), chart) + chart_option = rosePieOption( + JSON.parse(JSON.stringify(BASE_PIE)), + chart + ) } else if (chart.type === 'funnel') { - chart_option = baseFunnelOption(JSON.parse(JSON.stringify(BASE_FUNNEL)), chart) + chart_option = baseFunnelOption( + JSON.parse(JSON.stringify(BASE_FUNNEL)), + chart + ) } else if (chart.type === 'radar') { - chart_option = baseRadarOption(JSON.parse(JSON.stringify(BASE_RADAR)), chart) + chart_option = baseRadarOption( + JSON.parse(JSON.stringify(BASE_RADAR)), + chart + ) } else if (chart.type === 'gauge') { - chart_option = baseGaugeOption(JSON.parse(JSON.stringify(BASE_GAUGE)), chart) + chart_option = baseGaugeOption( + JSON.parse(JSON.stringify(BASE_GAUGE)), + chart + ) } else if (chart.type === 'scatter') { - chart_option = baseScatterOption(JSON.parse(JSON.stringify(BASE_SCATTER)), chart) + chart_option = baseScatterOption( + JSON.parse(JSON.stringify(BASE_SCATTER)), + chart + ) } else if (chart.type === 'treemap') { - chart_option = baseTreemapOption(JSON.parse(JSON.stringify(BASE_TREEMAP)), chart) + chart_option = baseTreemapOption( + JSON.parse(JSON.stringify(BASE_TREEMAP)), + chart + ) } else if (chart.type === 'chart-mix') { - chart_option = baseMixOption(JSON.parse(JSON.stringify(BASE_MIX)), chart) + chart_option = baseMixOption( + JSON.parse(JSON.stringify(BASE_MIX)), + chart + ) } // console.log(JSON.stringify(chart_option)) @@ -167,13 +232,15 @@ export default { return } - geoJson(cCode).then(res => { - this.$store.dispatch('map/setGeo', { - key: cCode, - value: res - }).then(() => { - this.initMapChart(res, chart) - }) + geoJson(cCode).then((res) => { + this.$store + .dispatch('map/setGeo', { + key: cCode, + value: res + }) + .then(() => { + this.initMapChart(res, chart) + }) }) return } @@ -181,25 +248,25 @@ export default { }, registerDynamicMap(areaCode) { this.dynamicAreaCode = areaCode - // if (this.$store.getters.geoMap[areaCode]) { - // const json = this.$store.getters.geoMap[areaCode] - // this.myChart.dispose() - // this.myChart = this.$echarts.getInstanceByDom(document.getElementById(this.chartId)) - // this.$echarts.registerMap('MAP', json) - // return - // } - // geoJson(areaCode).then(res => { - // this.$store.dispatch('map/setGeo', { - // key: areaCode, - // value: res - // }).then(() => { - // this.myChart.dispose() - // this.myChart = this.$echarts.getInstanceByDom(document.getElementById(this.chartId)) - // this.$echarts.registerMap('MAP', res) - // }) - // }).catch(() => { - // this.downOrUp = true - // }) + // if (this.$store.getters.geoMap[areaCode]) { + // const json = this.$store.getters.geoMap[areaCode] + // this.myChart.dispose() + // this.myChart = this.$echarts.getInstanceByDom(document.getElementById(this.chartId)) + // this.$echarts.registerMap('MAP', json) + // return + // } + // geoJson(areaCode).then(res => { + // this.$store.dispatch('map/setGeo', { + // key: areaCode, + // value: res + // }).then(() => { + // this.myChart.dispose() + // this.myChart = this.$echarts.getInstanceByDom(document.getElementById(this.chartId)) + // this.$echarts.registerMap('MAP', res) + // }) + // }).catch(() => { + // this.downOrUp = true + // }) }, initMapChart(geoJson, chart) { @@ -213,6 +280,16 @@ export default { // 指定图表的配置项和数据 const chart = this.myChart this.setBackGroundBorder() + if ( + option.series && + option.series.length > 0 && + option.series[0].type === 'gauge' + ) { + if (option.series[0].data && option.series[0].data.length > 0) { + option.series[0].max = option.series[0].data[0].value + } + } + console.log('哈哈哈', option) setTimeout(chart.setOption(option, true), 500) window.onresize = function() { chart.resize() @@ -267,6 +344,4 @@ export default { } - + diff --git a/frontend/src/views/chart/components/ChartComponentG2.vue b/frontend/src/views/chart/components/ChartComponentG2.vue index 089b33a..24027f0 100644 --- a/frontend/src/views/chart/components/ChartComponentG2.vue +++ b/frontend/src/views/chart/components/ChartComponentG2.vue @@ -1,7 +1,17 @@ @@ -74,7 +84,9 @@ export default { preDraw() { // 基于准备好的dom,初始化echarts实例 // 渲染echart等待dom加载完毕,渲染之前先尝试销毁具有相同id的echart 放置多次切换仪表板有重复id情况 - new Promise((resolve) => { resolve() }).then(() => { + new Promise((resolve) => { + resolve() + }).then(() => { // 此dom为echarts图标展示dom // this.myChart = this.$echarts.getInstanceByDom(document.getElementById(this.chartId)) // if (!this.myChart) { @@ -157,6 +169,4 @@ export default { } - + diff --git a/frontend/src/views/chart/components/table/TableNormal.vue b/frontend/src/views/chart/components/table/TableNormal.vue index b721640..e7e4463 100644 --- a/frontend/src/views/chart/components/table/TableNormal.vue +++ b/frontend/src/views/chart/components/table/TableNormal.vue @@ -38,11 +38,11 @@ - {{ $t("chart.total") }} + {{ $t('chart.total') }} {{ chart.data && chart.data.tableRow ? chart.data.tableRow.length : 0 }} - {{ $t("chart.items") }} + {{ $t('chart.items') }}