From bcabbf905df685ed9201e244a4cc6d019cecdf91 Mon Sep 17 00:00:00 2001 From: junjie Date: Thu, 9 Dec 2021 18:32:30 +0800 Subject: [PATCH 1/8] =?UTF-8?q?feat(=E8=A7=86=E5=9B=BE):=20=E5=90=8C?= =?UTF-8?q?=E6=AF=94=E7=8E=AF=E6=AF=94?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../dto/chart/ChartFieldCompareCustomDTO.java | 21 +++ .../dto/chart/ChartFieldCompareDTO.java | 15 ++ .../dataease/dto/chart/ChartViewFieldDTO.java | 2 + .../service/chart/ChartConstants.java | 13 ++ .../service/chart/ChartViewService.java | 144 ++++++++++++++++++ .../components/drag-item/ChartDragItem.vue | 10 +- .../components/drag-item/DimensionItem.vue | 23 ++- .../chart/components/drag-item/QuotaItem.vue | 2 +- 8 files changed, 222 insertions(+), 8 deletions(-) create mode 100644 backend/src/main/java/io/dataease/dto/chart/ChartFieldCompareCustomDTO.java create mode 100644 backend/src/main/java/io/dataease/dto/chart/ChartFieldCompareDTO.java create mode 100644 backend/src/main/java/io/dataease/service/chart/ChartConstants.java diff --git a/backend/src/main/java/io/dataease/dto/chart/ChartFieldCompareCustomDTO.java b/backend/src/main/java/io/dataease/dto/chart/ChartFieldCompareCustomDTO.java new file mode 100644 index 0000000000..8ae4a5be60 --- /dev/null +++ b/backend/src/main/java/io/dataease/dto/chart/ChartFieldCompareCustomDTO.java @@ -0,0 +1,21 @@ +package io.dataease.dto.chart; + +import lombok.Data; + +import java.util.List; + +/** + * @Author gin + * @Date 2021/12/9 2:48 下午 + */ +@Data +public class ChartFieldCompareCustomDTO { + private String field; + private String calcType; + private String timeType; + private String currentTime; + private String compareTime; + private List currentTimeRange; + private List compareTimeRange; + +} diff --git a/backend/src/main/java/io/dataease/dto/chart/ChartFieldCompareDTO.java b/backend/src/main/java/io/dataease/dto/chart/ChartFieldCompareDTO.java new file mode 100644 index 0000000000..800a37f0cb --- /dev/null +++ b/backend/src/main/java/io/dataease/dto/chart/ChartFieldCompareDTO.java @@ -0,0 +1,15 @@ +package io.dataease.dto.chart; + +import lombok.Data; + +/** + * @Author gin + * @Date 2021/12/9 2:48 下午 + */ +@Data +public class ChartFieldCompareDTO { + private String type; + private String resultData; + private String field; + private ChartFieldCompareCustomDTO custom; +} diff --git a/backend/src/main/java/io/dataease/dto/chart/ChartViewFieldDTO.java b/backend/src/main/java/io/dataease/dto/chart/ChartViewFieldDTO.java index 221ff0d218..3d5b13665d 100644 --- a/backend/src/main/java/io/dataease/dto/chart/ChartViewFieldDTO.java +++ b/backend/src/main/java/io/dataease/dto/chart/ChartViewFieldDTO.java @@ -46,4 +46,6 @@ public class ChartViewFieldDTO implements Serializable { private Integer extField; private String chartType; + + private ChartFieldCompareDTO compareCalc; } diff --git a/backend/src/main/java/io/dataease/service/chart/ChartConstants.java b/backend/src/main/java/io/dataease/service/chart/ChartConstants.java new file mode 100644 index 0000000000..9b1736018c --- /dev/null +++ b/backend/src/main/java/io/dataease/service/chart/ChartConstants.java @@ -0,0 +1,13 @@ +package io.dataease.service.chart; + +/** + * @Author gin + * @Date 2021/12/9 3:58 下午 + */ +public class ChartConstants { + public static final String YEAR_MOM = "year_mom"; + public static final String MONTH_MOM = "month_mom"; + public static final String YEAR_YOY = "year_yoy"; + public static final String DAY_MOM = "day_mom"; + public static final String MONTH_YOY = "month_yoy"; +} diff --git a/backend/src/main/java/io/dataease/service/chart/ChartViewService.java b/backend/src/main/java/io/dataease/service/chart/ChartViewService.java index d90a240ebb..b9a8d478c6 100644 --- a/backend/src/main/java/io/dataease/service/chart/ChartViewService.java +++ b/backend/src/main/java/io/dataease/service/chart/ChartViewService.java @@ -36,6 +36,7 @@ import org.springframework.stereotype.Service; import javax.annotation.Resource; import java.math.BigDecimal; import java.math.RoundingMode; +import java.text.SimpleDateFormat; import java.util.*; import java.util.concurrent.locks.ReentrantLock; import java.util.stream.Collectors; @@ -433,6 +434,87 @@ public class ChartViewService { } } + // 同比/环比计算,通过对比类型和数据设置,计算出对应指标的结果,然后替换结果data数组中的对应元素 + // 如果因维度变化(如时间字段缺失,时间字段的展示格式变化)导致无法计算结果的,则结果data数组中的对应元素全置为null + // 根据不同图表类型,获得需要替换的指标index array + for (int i = 0; i < yAxis.size(); i++) { + ChartViewFieldDTO chartViewFieldDTO = yAxis.get(i); + ChartFieldCompareDTO compareCalc = chartViewFieldDTO.getCompareCalc(); + if (ObjectUtils.isEmpty(compareCalc)) { + continue; + } + if (StringUtils.isNotEmpty(compareCalc.getType()) + && !StringUtils.equalsIgnoreCase(compareCalc.getType(), "none")) { + String compareFieldId = compareCalc.getField();// 选中字段 + String resultData = compareCalc.getResultData();// 数据设置 + // 获取选中字段以及下标 + List checkedField = new ArrayList<>(xAxis); + if (StringUtils.containsIgnoreCase(view.getType(), "stack")) { + checkedField.addAll(extStack); + } + int timeIndex = 0;// 时间字段下标 + ChartViewFieldDTO timeField = null; + for (int j = 0; j < checkedField.size(); j++) { + if (StringUtils.equalsIgnoreCase(checkedField.get(j).getId(), compareFieldId)) { + timeIndex = j; + timeField = checkedField.get(j); + } + } + // 计算指标对应的下标 + int dataIndex = 0;// 数据字段下标 + if (StringUtils.containsIgnoreCase(view.getType(), "stack")) { + dataIndex = xAxis.size() + extStack.size() + i; + } else { + dataIndex = xAxis.size() + i; + } + // 无选中字段,或者选中字段已经不在维度list中,或者选中字段日期格式不符合对比类型的,直接将对应数据置为null + if (ObjectUtils.isEmpty(timeField) || !checkCalcType(timeField.getDateStyle(), compareCalc.getType())) { + // set null + for (String[] item : data) { + item[dataIndex] = null; + } + } else { + // 计算 同比/环比 + // 1,处理当期数据;2,根据type计算上一期数据;3,根据resultData计算结果 + Map currentMap = new LinkedHashMap<>(); + for (String[] item : data) { + currentMap.put(item[timeIndex], item[dataIndex]); + } + + Iterator> iterator = currentMap.entrySet().iterator(); + int index = 0; + while (iterator.hasNext()) { + Map.Entry next = iterator.next(); + String cTime = next.getKey(); + String cValue = next.getValue(); + + String lastTime = calcLastTime(cTime, compareCalc.getType(), timeField.getDateStyle()); + String lastValue = currentMap.get(lastTime); + if (StringUtils.isEmpty(cValue) || StringUtils.isEmpty(lastValue)) { + data.get(index)[dataIndex] = null; + } else { + if (StringUtils.equalsIgnoreCase(resultData, "sub")) { + data.get(index)[dataIndex] = new BigDecimal(cValue).subtract(new BigDecimal(lastValue)).toString(); + } else if (StringUtils.equalsIgnoreCase(resultData, "percent")) { + if (StringUtils.isEmpty(lastValue)) { + data.get(index)[dataIndex] = null; + } else { + data.get(index)[dataIndex] = new BigDecimal(cValue) + .divide(new BigDecimal(lastValue), 2, RoundingMode.HALF_UP) + .subtract(new BigDecimal(1)) + .setScale(2, RoundingMode.HALF_UP) + .toString(); + } + } + } + index++; + } + + } + } + } + + // 构建结果 Map map = new TreeMap<>(); // 图表组件可再扩展 Map mapChart = new HashMap<>(); @@ -491,6 +573,68 @@ public class ChartViewService { return dto; } + private boolean checkCalcType(String dateStyle, String calcType) { + switch (dateStyle) { + case "y": + return StringUtils.equalsIgnoreCase(calcType, "year_mom"); + case "y_M": + return StringUtils.equalsIgnoreCase(calcType, "month_mom") + || StringUtils.equalsIgnoreCase(calcType, "year_yoy"); + case "y_M_d": + return StringUtils.equalsIgnoreCase(calcType, "day_mom") + || StringUtils.equalsIgnoreCase(calcType, "month_yoy") + || StringUtils.equalsIgnoreCase(calcType, "year_yoy"); + } + return false; + } + + private String calcLastTime(String cTime, String type, String dateStyle) throws Exception { + String lastTime = null; + Calendar calendar = Calendar.getInstance(); + if (StringUtils.equalsIgnoreCase(type, ChartConstants.YEAR_MOM)) { + SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy"); + Date date = simpleDateFormat.parse(cTime); + calendar.setTime(date); + calendar.add(Calendar.YEAR, -1); + lastTime = simpleDateFormat.format(calendar.getTime()); + } else if (StringUtils.equalsIgnoreCase(type, ChartConstants.MONTH_MOM)) { + SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM"); + Date date = simpleDateFormat.parse(cTime); + calendar.setTime(date); + calendar.add(Calendar.MONTH, -1); + lastTime = simpleDateFormat.format(calendar.getTime()); + } else if (StringUtils.equalsIgnoreCase(type, ChartConstants.YEAR_YOY)) { + SimpleDateFormat simpleDateFormat = null; + if (StringUtils.equalsIgnoreCase(dateStyle, "y_M")) { + simpleDateFormat = new SimpleDateFormat("yyyy-MM"); + } else if (StringUtils.equalsIgnoreCase(dateStyle, "y_M_d")) { + simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd"); + } + Date date = simpleDateFormat.parse(cTime); + calendar.setTime(date); + calendar.add(Calendar.YEAR, -1); + lastTime = simpleDateFormat.format(calendar.getTime()); + } else if (StringUtils.equalsIgnoreCase(type, ChartConstants.DAY_MOM)) { + SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd"); + Date date = simpleDateFormat.parse(cTime); + calendar.setTime(date); + calendar.add(Calendar.DAY_OF_MONTH, -1); + lastTime = simpleDateFormat.format(calendar.getTime()); + } else if (StringUtils.equalsIgnoreCase(type, ChartConstants.MONTH_YOY)) { + SimpleDateFormat simpleDateFormat = null; + if (StringUtils.equalsIgnoreCase(dateStyle, "y_M")) { + simpleDateFormat = new SimpleDateFormat("yyyy-MM"); + } else if (StringUtils.equalsIgnoreCase(dateStyle, "y_M_d")) { + simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd"); + } + Date date = simpleDateFormat.parse(cTime); + calendar.setTime(date); + calendar.add(Calendar.MONTH, -1); + lastTime = simpleDateFormat.format(calendar.getTime()); + } + return lastTime; + } + private boolean checkDrillExist(List xAxis, List extStack, ChartViewFieldDTO dto, ChartViewWithBLOBs view) { if (CollectionUtils.isNotEmpty(xAxis)) { for (ChartViewFieldDTO x : xAxis) { diff --git a/frontend/src/views/chart/components/drag-item/ChartDragItem.vue b/frontend/src/views/chart/components/drag-item/ChartDragItem.vue index 400fadab32..8fded96dda 100644 --- a/frontend/src/views/chart/components/drag-item/ChartDragItem.vue +++ b/frontend/src/views/chart/components/drag-item/ChartDragItem.vue @@ -11,6 +11,9 @@ {{ item.name }} {{ $t('chart.'+item.summary) }} + + {{ $t('chart.' + item.dateStyle) }} + @@ -25,6 +28,9 @@ {{ item.name }} {{ $t('chart.'+item.summary) }} + + {{ $t('chart.' + item.dateStyle) }} + @@ -239,7 +245,7 @@ export default { .item-span-style{ display: inline-block; - width: 80px; + width: 70px; white-space: nowrap; text-overflow: ellipsis; overflow: hidden; @@ -254,6 +260,6 @@ export default { margin-left: 4px; color: #878d9f; position: absolute; - right: 30px; + right: 25px; } diff --git a/frontend/src/views/chart/components/drag-item/DimensionItem.vue b/frontend/src/views/chart/components/drag-item/DimensionItem.vue index 073edc2b01..5b71a0f813 100644 --- a/frontend/src/views/chart/components/drag-item/DimensionItem.vue +++ b/frontend/src/views/chart/components/drag-item/DimensionItem.vue @@ -10,6 +10,9 @@ {{ item.name }} + + {{ $t('chart.' + item.dateStyle) }} + @@ -23,6 +26,9 @@ {{ item.name }} + + {{ $t('chart.' + item.dateStyle) }} + @@ -32,7 +38,7 @@ {{ $t('chart.sort') }} - ({{ $t('chart.'+item.sort) }}) + ({{ $t('chart.'+item.sort) }}) @@ -53,7 +59,7 @@ {{ $t('chart.dateStyle') }} - ({{ $t('chart.'+item.dateStyle) }}) + ({{ $t('chart.'+item.dateStyle) }}) @@ -73,7 +79,7 @@ {{ $t('chart.datePattern') }} - ({{ $t('chart.'+item.datePattern) }}) + ({{ $t('chart.'+item.datePattern) }}) @@ -215,7 +221,9 @@ export default { .summary-span{ margin-left: 4px; - color: #878d9f;; + color: #878d9f; + position: absolute; + right: 25px; } .inner-dropdown-menu{ @@ -227,9 +235,14 @@ export default { .item-span-style{ display: inline-block; - width: 80px; + width: 70px; white-space: nowrap; text-overflow: ellipsis; overflow: hidden; } + + .summary-span-item{ + margin-left: 4px; + color: #878d9f; + } diff --git a/frontend/src/views/chart/components/drag-item/QuotaItem.vue b/frontend/src/views/chart/components/drag-item/QuotaItem.vue index 565412392a..38855fcece 100644 --- a/frontend/src/views/chart/components/drag-item/QuotaItem.vue +++ b/frontend/src/views/chart/components/drag-item/QuotaItem.vue @@ -195,7 +195,7 @@ export default { const t2 = extStack.filter(ele => { return ele.deType === 1 }) - if ((t1.length > 0 || t2.length > 0) && this.chart.type !== 'text' && this.chart.type !== 'gauge' && this.chart.type !== 'liquid') { + if ((t1.length + t2.length === 1) && this.chart.type !== 'text' && this.chart.type !== 'gauge' && this.chart.type !== 'liquid') { this.disableEditCompare = false } else { this.disableEditCompare = true From 82a71052eb3580b0151ae6c0ac66f13a9a48488b Mon Sep 17 00:00:00 2001 From: fit2cloud-chenyw Date: Thu, 9 Dec 2021 18:59:01 +0800 Subject: [PATCH 2/8] =?UTF-8?q?feat:=20=E4=BF=AE=E6=94=B9=E9=95=9C?= =?UTF-8?q?=E5=83=8F=E8=BF=90=E8=A1=8C=E8=84=9A=E6=9C=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Dockerfile | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index b9b4cd5366..4d7ae78f4a 100644 --- a/Dockerfile +++ b/Dockerfile @@ -28,4 +28,7 @@ ENV JAVA_OPTIONS=-Dfile.encoding=utf-8 HEALTHCHECK --interval=15s --timeout=5s --retries=20 --start-period=30s CMD curl -f 127.0.0.1:8081 -CMD ["/deployments/run-java.sh"] +EXPOSE 8081 + +ENTRYPOINT java -jar /opt/apps/backend-$IMAGE_TAG.jar +#CMD ["/deployments/run-java.sh"] From 44f721d3ae83749d427dbd137fd473b9cbbb890b Mon Sep 17 00:00:00 2001 From: fit2cloud-chenyw Date: Thu, 9 Dec 2021 21:25:13 +0800 Subject: [PATCH 3/8] =?UTF-8?q?revert:=20=E9=95=9C=E5=83=8F=E5=9B=9E?= =?UTF-8?q?=E9=80=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Dockerfile | 19 ++----------------- 1 file changed, 2 insertions(+), 17 deletions(-) diff --git a/Dockerfile b/Dockerfile index 84fef98363..70dec5f209 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,16 +1,4 @@ -#FROM registry.cn-qingdao.aliyuncs.com/dataease/fabric8-java-alpine-openjdk8-jre -FROM alpine - -RUN echo -e 'http://mirrors.aliyun.com/alpine/v3.15/main/\nhttp://mirrors.aliyun.com/alpine/v3.15/community/' > /etc/apk/repositories - -RUN apk add openjdk8 chromium chromium-chromedriver fontconfig --no-cache --allow-untrusted - -ADD simsun.ttc /usr/share/fonts/ - -RUN cd /usr/share/fonts/ \ - && mkfontscale \ - && mkfontdir \ - && fc-cache -fv +FROM registry.cn-qingdao.aliyuncs.com/dataease/fabric8-java-alpine-openjdk8-jre ARG IMAGE_TAG @@ -34,7 +22,4 @@ ENV JAVA_OPTIONS=-Dfile.encoding=utf-8 HEALTHCHECK --interval=15s --timeout=5s --retries=20 --start-period=30s CMD curl -f 127.0.0.1:8081 -EXPOSE 8081 - -ENTRYPOINT java -jar /opt/apps/backend-$IMAGE_TAG.jar -#CMD ["/deployments/run-java.sh"] +CMD ["/deployments/run-java.sh"] From bfa247cbc35b38a3b266ef297f0acd58fcb8e48d Mon Sep 17 00:00:00 2001 From: junjie Date: Fri, 10 Dec 2021 10:43:34 +0800 Subject: [PATCH 4/8] =?UTF-8?q?feat(=E8=A7=86=E5=9B=BE):=20=E5=90=8C?= =?UTF-8?q?=E6=AF=94=E7=8E=AF=E6=AF=94?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/chart/ChartViewService.java | 31 ++++++++++--------- .../chart/components/compare/CompareEdit.vue | 4 +-- .../components/drag-item/QuotaExtItem.vue | 12 +++---- .../chart/components/drag-item/QuotaItem.vue | 12 +++---- 4 files changed, 25 insertions(+), 34 deletions(-) diff --git a/backend/src/main/java/io/dataease/service/chart/ChartViewService.java b/backend/src/main/java/io/dataease/service/chart/ChartViewService.java index b9a8d478c6..3eb3b5af78 100644 --- a/backend/src/main/java/io/dataease/service/chart/ChartViewService.java +++ b/backend/src/main/java/io/dataease/service/chart/ChartViewService.java @@ -478,28 +478,31 @@ public class ChartViewService { // 1,处理当期数据;2,根据type计算上一期数据;3,根据resultData计算结果 Map currentMap = new LinkedHashMap<>(); for (String[] item : data) { - currentMap.put(item[timeIndex], item[dataIndex]); + String[] dimension = Arrays.copyOfRange(item, 0, checkedField.size()); + currentMap.put(StringUtils.join(dimension, "-"), item[dataIndex]); } - Iterator> iterator = currentMap.entrySet().iterator(); - int index = 0; - while (iterator.hasNext()) { - Map.Entry next = iterator.next(); - String cTime = next.getKey(); - String cValue = next.getValue(); + for (int index = 0; index < data.size(); index++) { + String[] item = data.get(index); + String cTime = item[timeIndex]; + String cValue = item[dataIndex]; + // 获取计算后的时间,并且与所有维度拼接 String lastTime = calcLastTime(cTime, compareCalc.getType(), timeField.getDateStyle()); - String lastValue = currentMap.get(lastTime); + String[] dimension = Arrays.copyOfRange(item, 0, checkedField.size()); + dimension[timeIndex] = lastTime; + + String lastValue = currentMap.get(StringUtils.join(dimension, "-")); if (StringUtils.isEmpty(cValue) || StringUtils.isEmpty(lastValue)) { - data.get(index)[dataIndex] = null; + item[dataIndex] = null; } else { if (StringUtils.equalsIgnoreCase(resultData, "sub")) { - data.get(index)[dataIndex] = new BigDecimal(cValue).subtract(new BigDecimal(lastValue)).toString(); + item[dataIndex] = new BigDecimal(cValue).subtract(new BigDecimal(lastValue)).toString(); } else if (StringUtils.equalsIgnoreCase(resultData, "percent")) { - if (StringUtils.isEmpty(lastValue)) { - data.get(index)[dataIndex] = null; + if (Integer.parseInt(lastValue) == 0) { + item[dataIndex] = null; } else { - data.get(index)[dataIndex] = new BigDecimal(cValue) + item[dataIndex] = new BigDecimal(cValue) .divide(new BigDecimal(lastValue), 2, RoundingMode.HALF_UP) .subtract(new BigDecimal(1)) .setScale(2, RoundingMode.HALF_UP) @@ -507,9 +510,7 @@ public class ChartViewService { } } } - index++; } - } } } diff --git a/frontend/src/views/chart/components/compare/CompareEdit.vue b/frontend/src/views/chart/components/compare/CompareEdit.vue index 988b372323..aa9916a684 100644 --- a/frontend/src/views/chart/components/compare/CompareEdit.vue +++ b/frontend/src/views/chart/components/compare/CompareEdit.vue @@ -63,10 +63,8 @@ export default { // 过滤xaxis,extStack所有日期字段 initFieldList() { const xAxis = JSON.parse(this.chart.xaxis) - const extStack = JSON.parse(this.chart.extStack) const t1 = xAxis.filter(ele => { return ele.deType === 1 }) - const t2 = extStack.filter(ele => { return ele.deType === 1 }) - this.fieldList = t1.concat(t2) + this.fieldList = t1 // 如果没有选中字段,则默认选中第一个 if ((!this.compareItem.compareCalc.field || this.compareItem.compareCalc.field === '') && this.fieldList.length > 0) { this.compareItem.compareCalc.field = this.fieldList[0].id diff --git a/frontend/src/views/chart/components/drag-item/QuotaExtItem.vue b/frontend/src/views/chart/components/drag-item/QuotaExtItem.vue index 7684e24757..294a72aa45 100644 --- a/frontend/src/views/chart/components/drag-item/QuotaExtItem.vue +++ b/frontend/src/views/chart/components/drag-item/QuotaExtItem.vue @@ -97,15 +97,15 @@ - - {{ $t('chart.yoy_label') }} + + {{ $t('chart.quick_calc') }} ({{ !item.compareCalc ? $t('chart.none') : $t('chart.' + item.compareCalc.type) }}) {{ $t('chart.none') }} - {{ $t('commons.setting') }}... + {{ $t('chart.yoy_label') }}... @@ -191,14 +191,10 @@ export default { }, isEnableCompare() { const xAxis = JSON.parse(this.chart.xaxis) - const extStack = JSON.parse(this.chart.extStack) const t1 = xAxis.filter(ele => { return ele.deType === 1 }) - const t2 = extStack.filter(ele => { - return ele.deType === 1 - }) - if (t1.length > 0 || t2.length > 0) { + if (t1.length > 0 && this.chart.type !== 'text' && this.chart.type !== 'gauge' && this.chart.type !== 'liquid') { this.disableEditCompare = false } else { this.disableEditCompare = true diff --git a/frontend/src/views/chart/components/drag-item/QuotaItem.vue b/frontend/src/views/chart/components/drag-item/QuotaItem.vue index 38855fcece..8c8d53e8b9 100644 --- a/frontend/src/views/chart/components/drag-item/QuotaItem.vue +++ b/frontend/src/views/chart/components/drag-item/QuotaItem.vue @@ -97,15 +97,15 @@ - - {{ $t('chart.yoy_label') }} + + {{ $t('chart.quick_calc') }} ({{ !item.compareCalc ? $t('chart.none') : $t('chart.' + item.compareCalc.type) }}) {{ $t('chart.none') }} - {{ $t('commons.setting') }}... + {{ $t('chart.yoy_label') }}... @@ -188,14 +188,10 @@ export default { }, isEnableCompare() { const xAxis = JSON.parse(this.chart.xaxis) - const extStack = JSON.parse(this.chart.extStack) const t1 = xAxis.filter(ele => { return ele.deType === 1 }) - const t2 = extStack.filter(ele => { - return ele.deType === 1 - }) - if ((t1.length + t2.length === 1) && this.chart.type !== 'text' && this.chart.type !== 'gauge' && this.chart.type !== 'liquid') { + if (t1.length > 0 && this.chart.type !== 'text' && this.chart.type !== 'gauge' && this.chart.type !== 'liquid') { this.disableEditCompare = false } else { this.disableEditCompare = true From deb5456d91a146fc7c95e0cba63d4430e8c5e5be Mon Sep 17 00:00:00 2001 From: junjie Date: Fri, 10 Dec 2021 11:01:26 +0800 Subject: [PATCH 5/8] =?UTF-8?q?refactor(=E8=A7=86=E5=9B=BE):=20=E6=8C=87?= =?UTF-8?q?=E6=A0=87=E7=BB=93=E6=9E=9C=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/chart/ChartViewService.java | 36 ++++++++++--------- 1 file changed, 20 insertions(+), 16 deletions(-) diff --git a/backend/src/main/java/io/dataease/service/chart/ChartViewService.java b/backend/src/main/java/io/dataease/service/chart/ChartViewService.java index 3eb3b5af78..b93d710aaf 100644 --- a/backend/src/main/java/io/dataease/service/chart/ChartViewService.java +++ b/backend/src/main/java/io/dataease/service/chart/ChartViewService.java @@ -733,7 +733,7 @@ public class ChartViewService { quotaList.add(chartQuotaDTO); axisChartDataDTO.setQuotaList(quotaList); try { - axisChartDataDTO.setValue(new BigDecimal(StringUtils.isEmpty(row[i]) ? "0" : row[i])); + axisChartDataDTO.setValue(StringUtils.isEmpty(row[i]) ? null : new BigDecimal(row[i])); } catch (Exception e) { axisChartDataDTO.setValue(new BigDecimal(0)); } @@ -789,7 +789,7 @@ public class ChartViewService { quotaList.add(chartQuotaDTO); axisChartDataDTO.setQuotaList(quotaList); try { - axisChartDataDTO.setValue(new BigDecimal(StringUtils.isEmpty(row[valueIndex]) ? "0" : row[valueIndex])); + axisChartDataDTO.setValue(StringUtils.isEmpty(row[valueIndex]) ? null : new BigDecimal(row[valueIndex])); } catch (Exception e) { axisChartDataDTO.setValue(new BigDecimal(0)); } @@ -837,7 +837,7 @@ public class ChartViewService { quotaList.add(chartQuotaDTO); axisChartDataDTO.setQuotaList(quotaList); try { - axisChartDataDTO.setValue(new BigDecimal(StringUtils.isEmpty(row[i]) ? "0" : row[i])); + axisChartDataDTO.setValue(StringUtils.isEmpty(row[i]) ? null : new BigDecimal(row[i])); } catch (Exception e) { axisChartDataDTO.setValue(new BigDecimal(0)); } @@ -892,14 +892,18 @@ public class ChartViewService { quotaList.add(chartQuotaDTO); axisChartDataDTO.setQuotaList(quotaList); try { - axisChartDataDTO.setValue(new BigDecimal(StringUtils.isEmpty(row[i]) ? "0" : row[i])); + axisChartDataDTO.setValue(StringUtils.isEmpty(row[i]) ? null : new BigDecimal(row[i])); } catch (Exception e) { axisChartDataDTO.setValue(new BigDecimal(0)); } axisChartDataDTO.setCategory(yAxis.get(j).getName()); // pop if (CollectionUtils.isNotEmpty(extBubble)) { - axisChartDataDTO.setPopSize(new BigDecimal(StringUtils.isEmpty(row[xAxis.size() + yAxis.size()]) ? "0" : row[xAxis.size() + yAxis.size()])); + try { + axisChartDataDTO.setPopSize(StringUtils.isEmpty(row[xAxis.size() + yAxis.size()]) ? null : new BigDecimal(row[xAxis.size() + yAxis.size()])); + } catch (Exception e) { + axisChartDataDTO.setPopSize(new BigDecimal(0)); + } } datas.add(axisChartDataDTO); } @@ -951,7 +955,7 @@ public class ChartViewService { quotaList.add(chartQuotaDTO); axisChartDataDTO.setQuotaList(quotaList); try { - axisChartDataDTO.setValue(new BigDecimal(StringUtils.isEmpty(row[i]) ? "0" : row[i])); + axisChartDataDTO.setValue(StringUtils.isEmpty(row[i]) ? null : new BigDecimal(row[i])); } catch (Exception e) { axisChartDataDTO.setValue(new BigDecimal(0)); } @@ -1013,7 +1017,7 @@ public class ChartViewService { quotaList.add(chartQuotaDTO); axisChartDataDTO.setQuotaList(quotaList); try { - axisChartDataDTO.setValue(new BigDecimal(StringUtils.isEmpty(d[i]) ? "0" : d[i])); + axisChartDataDTO.setValue(StringUtils.isEmpty(d[i]) ? null : new BigDecimal(d[i])); } catch (Exception e) { axisChartDataDTO.setValue(new BigDecimal(0)); } @@ -1061,7 +1065,7 @@ public class ChartViewService { quotaList.add(chartQuotaDTO); axisChartDataDTO.setQuotaList(quotaList); try { - axisChartDataDTO.setValue(new BigDecimal(StringUtils.isEmpty(d[i]) ? "0" : d[i])); + axisChartDataDTO.setValue(StringUtils.isEmpty(d[i]) ? null : new BigDecimal(d[i])); } catch (Exception e) { axisChartDataDTO.setValue(new BigDecimal(0)); } @@ -1122,7 +1126,7 @@ public class ChartViewService { quotaList.add(chartQuotaDTO); axisChartDataDTO.setQuotaList(quotaList); try { - axisChartDataDTO.setValue(new BigDecimal(StringUtils.isEmpty(d[i]) ? "0" : d[i])); + axisChartDataDTO.setValue(StringUtils.isEmpty(d[i]) ? null : new BigDecimal(d[i])); } catch (Exception e) { axisChartDataDTO.setValue(new BigDecimal(0)); } @@ -1177,7 +1181,7 @@ public class ChartViewService { for (int i = xAxis.size(); i < xAxis.size() + yAxis.size(); i++) { int j = i - xAxis.size(); try { - series.get(j).getData().add(new BigDecimal(StringUtils.isEmpty(d[i]) ? "0" : d[i])); + series.get(j).getData().add(StringUtils.isEmpty(d[i]) ? null : new BigDecimal(d[i])); } catch (Exception e) { series.get(j).getData().add(new BigDecimal(0)); } @@ -1219,7 +1223,7 @@ public class ChartViewService { for (int i = xAxis.size(); i < xAxis.size() + yAxis.size(); i++) { int j = i - xAxis.size(); try { - series.get(j).getData().add(new BigDecimal(StringUtils.isEmpty(d[i]) ? "0" : d[i])); + series.get(j).getData().add(StringUtils.isEmpty(d[i]) ? null : new BigDecimal(d[i])); } catch (Exception e) { series.get(j).getData().add(new BigDecimal(0)); } @@ -1359,7 +1363,7 @@ public class ChartViewService { quotaList.add(chartQuotaDTO); axisChartDataDTO.setQuotaList(quotaList); try { - axisChartDataDTO.setValue(new BigDecimal(StringUtils.isEmpty(d[i]) ? "0" : d[i])); + axisChartDataDTO.setValue(StringUtils.isEmpty(d[i]) ? null : new BigDecimal(d[i])); } catch (Exception e) { axisChartDataDTO.setValue(new BigDecimal(0)); } @@ -1437,8 +1441,8 @@ public class ChartViewService { try { scatterChartDataDTO.setValue(new Object[]{ a.toString(), - new BigDecimal(StringUtils.isEmpty(d[i]) ? "0" : d[i]), - new BigDecimal(StringUtils.isEmpty(d[xAxis.size() + yAxis.size()]) ? "0" : d[xAxis.size() + yAxis.size()]) + StringUtils.isEmpty(d[i]) ? null : new BigDecimal(d[i]), + StringUtils.isEmpty(d[xAxis.size() + yAxis.size()]) ? null : new BigDecimal(d[xAxis.size() + yAxis.size()]) }); } catch (Exception e) { scatterChartDataDTO.setValue(new Object[]{a.toString(), new BigDecimal(0), new BigDecimal(0)}); @@ -1447,7 +1451,7 @@ public class ChartViewService { try { scatterChartDataDTO.setValue(new Object[]{ a.toString(), - new BigDecimal(StringUtils.isEmpty(d[i]) ? "0" : d[i]) + StringUtils.isEmpty(d[i]) ? null : new BigDecimal(d[i]) }); } catch (Exception e) { scatterChartDataDTO.setValue(new Object[]{a.toString(), new BigDecimal(0)}); @@ -1483,7 +1487,7 @@ public class ChartViewService { if (chartViewFieldDTO.getDeType() == 0 || chartViewFieldDTO.getDeType() == 1) { d.put(fields.get(i).getDataeaseName(), StringUtils.isEmpty(ele[i]) ? "" : ele[i]); } else if (chartViewFieldDTO.getDeType() == 2 || chartViewFieldDTO.getDeType() == 3) { - d.put(fields.get(i).getDataeaseName(), new BigDecimal(StringUtils.isEmpty(ele[i]) ? "0" : ele[i]).setScale(2, RoundingMode.HALF_UP)); + d.put(fields.get(i).getDataeaseName(), StringUtils.isEmpty(ele[i]) ? null : new BigDecimal(ele[i]).setScale(2, RoundingMode.HALF_UP)); } } tableRow.add(d); From 96fa9cc53e35230bebf040a32efa44be5ec31ff9 Mon Sep 17 00:00:00 2001 From: junjie Date: Fri, 10 Dec 2021 11:23:07 +0800 Subject: [PATCH 6/8] =?UTF-8?q?feat(=E6=95=B0=E6=8D=AE=E9=9B=86):=20?= =?UTF-8?q?=E5=85=B3=E8=81=94=E6=95=B0=E6=8D=AE=E9=9B=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- frontend/src/views/dataset/add/AddUnion.vue | 8 ++++++-- frontend/src/views/dataset/add/union/NodeItem.vue | 4 ++-- .../src/views/dataset/common/DatasetGroupSelectorTree.vue | 2 +- 3 files changed, 9 insertions(+), 5 deletions(-) diff --git a/frontend/src/views/dataset/add/AddUnion.vue b/frontend/src/views/dataset/add/AddUnion.vue index 875c597130..6caa95bcad 100644 --- a/frontend/src/views/dataset/add/AddUnion.vue +++ b/frontend/src/views/dataset/add/AddUnion.vue @@ -16,7 +16,7 @@
- + @@ -59,7 +59,7 @@
- + - +