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 1592459766..522a33fc66 100644 --- a/backend/src/main/java/io/dataease/service/chart/ChartViewService.java +++ b/backend/src/main/java/io/dataease/service/chart/ChartViewService.java @@ -572,7 +572,9 @@ public class ChartViewService { List xAxisBase = gson.fromJson(view.getXAxis(), tokenType); List xAxis = gson.fromJson(view.getXAxis(), tokenType); List xAxisExt = gson.fromJson(view.getXAxisExt(), tokenType); - if (StringUtils.equalsIgnoreCase(view.getType(), "table-pivot") || StringUtils.containsIgnoreCase(view.getType(), "group")) { + if (StringUtils.equalsIgnoreCase(view.getType(), "table-pivot") + || StringUtils.containsIgnoreCase(view.getType(), "group") + || ("antv".equalsIgnoreCase(view.getRender()) && "line".equalsIgnoreCase(view.getType()))) { xAxis.addAll(xAxisExt); } List yAxis = gson.fromJson(view.getYAxis(), tokenType); @@ -677,7 +679,13 @@ public class ChartViewService { if (sqlVariables.stream().map(SqlVariableDetails::getVariableName).collect(Collectors.toList()).contains(parameter)) { hasParameters = true; } - if (parameter.contains("|DE|") && table.getId().equals(parameter.split("\\|DE\\|")[0]) && sqlVariables.stream().map(SqlVariableDetails::getVariableName).collect(Collectors.toList()).contains(parameter.split("\\|DE\\|")[1])) { + if (parameter.contains("|DE|") + && table.getId().equals(parameter.split("\\|DE\\|")[0]) + && sqlVariables + .stream() + .map(SqlVariableDetails::getVariableName) + .collect(Collectors.toList()) + .contains(parameter.split("\\|DE\\|")[1])) { hasParameters = true; } } @@ -861,7 +869,7 @@ public class ChartViewService { if (ObjectUtils.isEmpty(ds)) { throw new RuntimeException(Translator.get("i18n_datasource_delete")); } - if (StringUtils.isNotEmpty(ds.getStatus()) && ds.getStatus().equalsIgnoreCase("Error")) { + if (StringUtils.isNotEmpty(ds.getStatus()) && "Error".equalsIgnoreCase(ds.getStatus())) { throw new Exception(Translator.get("i18n_invalid_ds")); } datasourceRequest.setDatasource(ds); @@ -869,7 +877,7 @@ public class ChartViewService { QueryProvider qp = ProviderFactory.getQueryProvider(ds.getType()); if (StringUtils.equalsIgnoreCase(table.getType(), DatasetType.DB.name())) { datasourceRequest.setTable(dataTableInfoDTO.getTable()); - if (StringUtils.equalsIgnoreCase("text", view.getType()) || StringUtils.equalsIgnoreCase("gauge", view.getType()) || StringUtils.equalsIgnoreCase("liquid", view.getType())) { + if (StringUtils.equalsAnyIgnoreCase(view.getType(), "text", "gauge", "liquid")) { datasourceRequest.setQuery(qp.getSQLSummary(dataTableInfoDTO.getTable(), yAxis, fieldCustomFilter, rowPermissionsTree, extFilterList, view, ds)); } else if (StringUtils.containsIgnoreCase(view.getType(), "stack")) { datasourceRequest.setQuery(qp.getSQLStack(dataTableInfoDTO.getTable(), xAxis, yAxis, fieldCustomFilter, rowPermissionsTree, extFilterList, extStack, ds, view)); @@ -883,7 +891,7 @@ public class ChartViewService { } else if (StringUtils.equalsIgnoreCase(table.getType(), DatasetType.SQL.name())) { String sql = dataTableInfoDTO.isBase64Encryption() ? new String(java.util.Base64.getDecoder().decode(dataTableInfoDTO.getSql())) : dataTableInfoDTO.getSql(); sql = handleVariable(sql, requestList, qp, table, ds); - if (StringUtils.equalsIgnoreCase("text", view.getType()) || StringUtils.equalsIgnoreCase("gauge", view.getType()) || StringUtils.equalsIgnoreCase("liquid", view.getType())) { + if (StringUtils.equalsAnyIgnoreCase(view.getType(), "text", "gauge", "liquid")) { datasourceRequest.setQuery(qp.getSQLSummaryAsTmp(sql, yAxis, fieldCustomFilter, rowPermissionsTree, extFilterList, view)); } else if (StringUtils.containsIgnoreCase(view.getType(), "stack")) { datasourceRequest.setQuery(qp.getSQLAsTmpStack(sql, xAxis, yAxis, fieldCustomFilter, rowPermissionsTree, extFilterList, extStack, view)); @@ -898,7 +906,7 @@ public class ChartViewService { DataTableInfoDTO dt = gson.fromJson(table.getInfo(), DataTableInfoDTO.class); List list = dataSetTableUnionService.listByTableId(dt.getList().get(0).getTableId()); String sql = dataSetTableService.getCustomSQLDatasource(dt, list, ds); - if (StringUtils.equalsIgnoreCase("text", view.getType()) || StringUtils.equalsIgnoreCase("gauge", view.getType()) || StringUtils.equalsIgnoreCase("liquid", view.getType())) { + if (StringUtils.equalsAnyIgnoreCase(view.getType(), "text", "gauge", "liquid")) { datasourceRequest.setQuery(qp.getSQLSummaryAsTmp(sql, yAxis, fieldCustomFilter, rowPermissionsTree, extFilterList, view)); } else if (StringUtils.containsIgnoreCase(view.getType(), "stack")) { datasourceRequest.setQuery(qp.getSQLAsTmpStack(sql, xAxis, yAxis, fieldCustomFilter, rowPermissionsTree, extFilterList, extStack, view)); @@ -914,7 +922,7 @@ public class ChartViewService { Map sqlMap = dataSetTableService.getUnionSQLDatasource(dt, ds); String sql = (String) sqlMap.get("sql"); - if (StringUtils.equalsIgnoreCase("text", view.getType()) || StringUtils.equalsIgnoreCase("gauge", view.getType()) || StringUtils.equalsIgnoreCase("liquid", view.getType())) { + if (StringUtils.equalsAnyIgnoreCase(view.getType(), "text", "gauge", "liquid")) { datasourceRequest.setQuery(qp.getSQLSummaryAsTmp(sql, yAxis, fieldCustomFilter, rowPermissionsTree, extFilterList, view)); } else if (StringUtils.containsIgnoreCase(view.getType(), "stack")) { datasourceRequest.setQuery(qp.getSQLAsTmpStack(sql, xAxis, yAxis, fieldCustomFilter, rowPermissionsTree, extFilterList, extStack, view)); @@ -938,7 +946,7 @@ public class ChartViewService { String tableName = "ds_" + table.getId().replaceAll("-", "_"); datasourceRequest.setTable(tableName); QueryProvider qp = ProviderFactory.getQueryProvider(ds.getType()); - if (StringUtils.equalsIgnoreCase("text", view.getType()) || StringUtils.equalsIgnoreCase("gauge", view.getType()) || StringUtils.equalsIgnoreCase("liquid", view.getType())) { + if (StringUtils.equalsAnyIgnoreCase(view.getType(), "text", "gauge", "liquid")) { datasourceRequest.setQuery(qp.getSQLSummary(tableName, yAxis, fieldCustomFilter, rowPermissionsTree, extFilterList, view, ds)); } else if (StringUtils.containsIgnoreCase(view.getType(), "stack")) { datasourceRequest.setQuery(qp.getSQLStack(tableName, xAxis, yAxis, fieldCustomFilter, rowPermissionsTree, extFilterList, extStack, ds, view)); @@ -958,7 +966,9 @@ public class ChartViewService { if (!cache || CollectionUtils.isNotEmpty(requestList.getFilter()) || CollectionUtils.isNotEmpty(requestList.getLinkageFilters()) || CollectionUtils.isNotEmpty(requestList.getOuterParamsFilters()) - || CollectionUtils.isNotEmpty(requestList.getDrill()) || CollectionUtils.isNotEmpty(rowPermissionsTree) || fields.size() != columnPermissionFields.size()) { + || CollectionUtils.isNotEmpty(requestList.getDrill()) + || CollectionUtils.isNotEmpty(rowPermissionsTree) + || fields.size() != columnPermissionFields.size()) { data = datasourceProvider.getData(datasourceRequest); } else { try { @@ -1110,7 +1120,7 @@ public class ChartViewService { mapChart = ChartDataBuild.transChartData(xAxis, yAxis, view, data, isDrill); } } else if (StringUtils.equalsIgnoreCase(view.getRender(), "antv")) { - if (StringUtils.equalsIgnoreCase(view.getType(), "bar-group")) { + if (StringUtils.equalsAnyIgnoreCase(view.getType(), "bar-group","line")) { mapChart = ChartDataBuild.transBaseGroupDataAntV(xAxisBase, xAxis, xAxisExt, yAxis, view, data, isDrill); } else if (StringUtils.equalsIgnoreCase(view.getType(),"bar-group-stack")) { mapChart = ChartDataBuild.transGroupStackDataAntV(xAxisBase, xAxis, xAxisExt, yAxis, extStack, data, view, isDrill); diff --git a/backend/src/main/java/io/dataease/service/chart/util/ChartDataBuild.java b/backend/src/main/java/io/dataease/service/chart/util/ChartDataBuild.java index 7d570a1a8b..d2351a8a3e 100644 --- a/backend/src/main/java/io/dataease/service/chart/util/ChartDataBuild.java +++ b/backend/src/main/java/io/dataease/service/chart/util/ChartDataBuild.java @@ -158,7 +158,11 @@ public class ChartDataBuild { } catch (Exception e) { axisChartDataDTO.setValue(new BigDecimal(0)); } - axisChartDataDTO.setCategory(b.toString()); + if ("line".equals(view.getType()) && CollectionUtils.isEmpty(xAxisExt)) { + axisChartDataDTO.setCategory(yAxis.get(j).getName()); + } else { + axisChartDataDTO.setCategory(b.toString()); + } dataList.add(axisChartDataDTO); } } diff --git a/frontend/src/utils/StringUtils.js b/frontend/src/utils/StringUtils.js index 923daf195a..0707dc2bd4 100644 --- a/frontend/src/utils/StringUtils.js +++ b/frontend/src/utils/StringUtils.js @@ -25,3 +25,15 @@ export function equalsAny(target, ...sources) { } return false } + +export function includesAny(target, ...sources) { + if (!target || !sources) { + return false + } + for (let i = 0; i < sources.length; i++) { + if (target.includes(sources[i])) { + return true + } + } + return false +} diff --git a/frontend/src/views/chart/chart/util.js b/frontend/src/views/chart/chart/util.js index 7550515c99..3c6faa1616 100644 --- a/frontend/src/views/chart/chart/util.js +++ b/frontend/src/views/chart/chart/util.js @@ -1,4 +1,5 @@ import { DEFAULT_TITLE_STYLE } from '@/views/chart/chart/chart' +import { equalsAny, includesAny } from '@/utils/StringUtils' export function hexColorToRGBA(hex, alpha) { const rgb = [] // 定义rgb数组 @@ -3193,7 +3194,7 @@ export function getColors(chart, colors, reset) { }) } } - } else if ((chart.type.includes('bar') || chart.type.includes('line') || chart.type.includes('scatter') || chart.type.includes('radar') || chart.type.includes('area')) && !chart.type.includes('group')) { + } else if (includesAny(chart.type, 'bar', 'scatter', 'radar', 'area') && !chart.type.includes('group')) { if (Object.prototype.toString.call(chart.yaxis) === '[object Array]') { series = JSON.parse(JSON.stringify(chart.yaxis)) } else { @@ -3209,7 +3210,7 @@ export function getColors(chart, colors, reset) { }) } } - } else if (chart.type === 'bar-group') { + } else if (equalsAny(chart.type, 'bar-group', 'line')) { // 拿到data中的category,并去重,然后构建seriesColor const data = chart.data.data const s = [] diff --git a/frontend/src/views/chart/components/ChartComponent.vue b/frontend/src/views/chart/components/ChartComponent.vue index 9e7693e8b1..89862e73df 100644 --- a/frontend/src/views/chart/components/ChartComponent.vue +++ b/frontend/src/views/chart/components/ChartComponent.vue @@ -223,10 +223,6 @@ export default { if (that.linkageActiveParam) { that.reDrawView() } - that.linkageActiveParam = { - seriesIndex: that.pointParam.seriesIndex, - name: that.pointParam.name - } if (that.trackMenu.length < 2) { // 只有一个事件直接调用 that.trackClick(that.trackMenu[0]) } else { // 视图关联多个事件 @@ -436,6 +432,10 @@ export default { this.$emit('onChartClick', this.pointParam) break case 'linkage': + this.linkageActiveParam = { + seriesIndex: param.seriesIndex, + name: param.name + } this.linkageActive() this.$store.commit('addViewTrackFilter', linkageParam) break diff --git a/frontend/src/views/chart/view/ChartEdit.vue b/frontend/src/views/chart/view/ChartEdit.vue index 4bbdea9122..12c77740fc 100644 --- a/frontend/src/views/chart/view/ChartEdit.vue +++ b/frontend/src/views/chart/view/ChartEdit.vue @@ -549,17 +549,23 @@ {{ $t('chart.chart_group') }} - * + * / {{ $t('chart.dimension') }}