From d0df0c062e40490a7977851b6e5841479b1253e2 Mon Sep 17 00:00:00 2001 From: ulleo Date: Fri, 17 May 2024 17:06:05 +0800 Subject: [PATCH] =?UTF-8?q?fix(=E5=9B=BE=E8=A1=A8):=20=E4=BF=AE=E5=A4=8D?= =?UTF-8?q?=E5=8C=BA=E9=97=B4=E6=9D=A1=E5=BD=A2=E5=9B=BE=E5=80=BC=E8=BD=B4?= =?UTF-8?q?=E9=80=89=E6=8B=A9=E7=BA=AC=E5=BA=A6=E6=97=B6=EF=BC=8C=E5=8B=BE?= =?UTF-8?q?=E9=80=89=E8=81=9A=E5=90=88=E6=97=B6=E9=97=B4=E7=BB=B4=E5=BA=A6?= =?UTF-8?q?=EF=BC=8C=E6=97=A0=E6=B3=95=E8=8E=B7=E5=8F=96=E9=97=B4=E9=9A=94?= =?UTF-8?q?=E5=80=BC=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../dataease/chart/manage/ChartDataManage.java | 18 ++++++++++++++++-- .../dataease/chart/utils/ChartDataBuild.java | 2 +- .../engine/trans/Dimension2SQLObj.java | 2 +- .../io/dataease/engine/trans/Quota2SQLObj.java | 7 ++++++- .../js/panel/charts/bar/range-bar.ts | 1 + .../api/dataset/union/model/SQLMeta.java | 2 ++ 6 files changed, 27 insertions(+), 5 deletions(-) diff --git a/core/core-backend/src/main/java/io/dataease/chart/manage/ChartDataManage.java b/core/core-backend/src/main/java/io/dataease/chart/manage/ChartDataManage.java index 290001372d..debe5f98a0 100644 --- a/core/core-backend/src/main/java/io/dataease/chart/manage/ChartDataManage.java +++ b/core/core-backend/src/main/java/io/dataease/chart/manage/ChartDataManage.java @@ -565,7 +565,21 @@ public class ChartDataManage { String limit = ((pageInfo.getGoPage() != null && pageInfo.getPageSize() != null) ? " LIMIT " + pageInfo.getPageSize() + " OFFSET " + (pageInfo.getGoPage() - 1) * pageInfo.getPageSize() : ""); detailFieldSql = originSql + limit; } - } else { + } else if (StringUtils.equalsIgnoreCase("bar-range", view.getType())) { + sqlMeta.setChartType(view.getType()); + Dimension2SQLObj.dimension2sqlObj(sqlMeta, xAxis, transFields(allFields), crossDs, dsMap); + Quota2SQLObj.quota2sqlObj(sqlMeta, yAxis, transFields(allFields), crossDs, dsMap); + querySql = SQLProvider.createQuerySQL(sqlMeta, true, needOrder, view); + if (containDetailField(view) && ObjectUtils.isNotEmpty(viewFields)) { + detailFieldList.addAll(xAxis); + detailFieldList.addAll(viewFields); + + Dimension2SQLObj.dimension2sqlObj(sqlMeta, detailFieldList, transFields(allFields), crossDs, dsMap); + String originSql = SQLProvider.createQuerySQL(sqlMeta, false, needOrder, view); + String limit = ((pageInfo.getGoPage() != null && pageInfo.getPageSize() != null) ? " LIMIT " + pageInfo.getPageSize() + " OFFSET " + (pageInfo.getGoPage() - 1) * pageInfo.getPageSize() : ""); + detailFieldSql = originSql + limit; + } + }else { Dimension2SQLObj.dimension2sqlObj(sqlMeta, xAxis, transFields(allFields), crossDs, dsMap); Quota2SQLObj.quota2sqlObj(sqlMeta, yAxis, transFields(allFields), crossDs, dsMap); querySql = SQLProvider.createQuerySQL(sqlMeta, true, needOrder, view); @@ -776,7 +790,7 @@ public class ChartDataManage { } else if (StringUtils.containsIgnoreCase(view.getType(), "quadrant")) { mapChart = ChartDataBuild.transQuadrantDataAntV(xAxis, yAxis, view, data, extBubble, isDrill); } else if (StringUtils.equalsIgnoreCase(view.getType(), "bar-range")) { - mapChart = ChartDataBuild.transTimeBarDataAntV(skipBarRange, barRangeDate, xAxisBase, xAxis, yAxis, view, data, isDrill); + mapChart = ChartDataBuild.transBarRangeDataAntV(skipBarRange, barRangeDate, xAxisBase, xAxis, yAxis, view, data, isDrill); } else { mapChart = ChartDataBuild.transChartDataAntV(xAxis, yAxis, view, data, isDrill); } diff --git a/core/core-backend/src/main/java/io/dataease/chart/utils/ChartDataBuild.java b/core/core-backend/src/main/java/io/dataease/chart/utils/ChartDataBuild.java index a6575614de..f73b9b7b4f 100644 --- a/core/core-backend/src/main/java/io/dataease/chart/utils/ChartDataBuild.java +++ b/core/core-backend/src/main/java/io/dataease/chart/utils/ChartDataBuild.java @@ -1327,7 +1327,7 @@ public class ChartDataBuild { return map; } - public static Map transTimeBarDataAntV(boolean skipBarRange, boolean isDate, List xAxisBase, List xAxis, List yAxis, ChartViewDTO view, List data, boolean isDrill) { + public static Map transBarRangeDataAntV(boolean skipBarRange, boolean isDate, List xAxisBase, List xAxis, List yAxis, ChartViewDTO view, List data, boolean isDrill) { Map map = new HashMap<>(); if (skipBarRange) { diff --git a/core/core-backend/src/main/java/io/dataease/engine/trans/Dimension2SQLObj.java b/core/core-backend/src/main/java/io/dataease/engine/trans/Dimension2SQLObj.java index 352c8d7065..458989fb26 100644 --- a/core/core-backend/src/main/java/io/dataease/engine/trans/Dimension2SQLObj.java +++ b/core/core-backend/src/main/java/io/dataease/engine/trans/Dimension2SQLObj.java @@ -66,7 +66,7 @@ public class Dimension2SQLObj { meta.setXFieldsDialect(fieldsDialect); } - private static SQLObj getXFields(ChartViewFieldDTO x, String originField, String fieldAlias) { + public static SQLObj getXFields(ChartViewFieldDTO x, String originField, String fieldAlias) { String fieldName = ""; if (Objects.equals(x.getDeExtractType(), DeTypeConstants.DE_TIME)) { if (Objects.equals(x.getDeType(), DeTypeConstants.DE_INT) || Objects.equals(x.getDeType(), DeTypeConstants.DE_FLOAT)) { diff --git a/core/core-backend/src/main/java/io/dataease/engine/trans/Quota2SQLObj.java b/core/core-backend/src/main/java/io/dataease/engine/trans/Quota2SQLObj.java index 10a4c18516..d99283350e 100644 --- a/core/core-backend/src/main/java/io/dataease/engine/trans/Quota2SQLObj.java +++ b/core/core-backend/src/main/java/io/dataease/engine/trans/Quota2SQLObj.java @@ -50,7 +50,12 @@ public class Quota2SQLObj { } String fieldAlias = String.format(SQLConstants.FIELD_ALIAS_Y_PREFIX, i); // 处理纵轴字段 - yFields.add(getYFields(y, originField, fieldAlias)); + SQLObj ySQLObj = getYFields(y, originField, fieldAlias); + if (StringUtils.equalsIgnoreCase("bar-range", meta.getChartType()) && StringUtils.equalsIgnoreCase(y.getGroupType(), "d") && y.getDeType() == 1) { + yFields.add(Dimension2SQLObj.getXFields(y, ySQLObj.getFieldName(), fieldAlias)); + } else { + yFields.add(ySQLObj); + } // 处理纵轴过滤 String wheres = getYWheres(y, originField, fieldAlias); if (ObjectUtils.isNotEmpty(wheres)) { diff --git a/core/core-frontend/src/views/chart/components/js/panel/charts/bar/range-bar.ts b/core/core-frontend/src/views/chart/components/js/panel/charts/bar/range-bar.ts index 53ce1d20cc..5d4f5ab07a 100644 --- a/core/core-frontend/src/views/chart/components/js/panel/charts/bar/range-bar.ts +++ b/core/core-frontend/src/views/chart/components/js/panel/charts/bar/range-bar.ts @@ -203,6 +203,7 @@ export class RangeBar extends G2PlotChartView { const t = JSON.parse(JSON.stringify(customAttr.tooltip)) if (t.show) { tooltip = { + fields: ['values', 'field', 'gap'], formatter: function (param: Datum) { let res if (isDate) { diff --git a/sdk/api/api-base/src/main/java/io/dataease/api/dataset/union/model/SQLMeta.java b/sdk/api/api-base/src/main/java/io/dataease/api/dataset/union/model/SQLMeta.java index 13118293df..e08bb078c8 100644 --- a/sdk/api/api-base/src/main/java/io/dataease/api/dataset/union/model/SQLMeta.java +++ b/sdk/api/api-base/src/main/java/io/dataease/api/dataset/union/model/SQLMeta.java @@ -11,6 +11,8 @@ import java.util.Map; @Data public class SQLMeta { + private String chartType; + private SQLObj table; /**