diff --git a/core/backend/src/main/java/io/dataease/service/chart/ChartViewService.java b/core/backend/src/main/java/io/dataease/service/chart/ChartViewService.java index 43445687b4..3d80fdab40 100644 --- a/core/backend/src/main/java/io/dataease/service/chart/ChartViewService.java +++ b/core/backend/src/main/java/io/dataease/service/chart/ChartViewService.java @@ -57,6 +57,7 @@ import io.dataease.service.datasource.DatasourceService; import io.dataease.service.engine.EngineService; import io.dataease.service.panel.PanelGroupExtendDataService; import org.apache.commons.collections4.CollectionUtils; +import org.apache.commons.collections4.ListUtils; import org.apache.commons.lang3.ObjectUtils; import org.apache.commons.lang3.StringUtils; import org.pentaho.di.core.util.UUIDUtil; @@ -344,7 +345,9 @@ public class ChartViewService { } List xAxis = gson.fromJson(view.getXAxis(), new TypeToken>() { }.getType()); - if (StringUtils.equalsIgnoreCase(view.getType(), "table-pivot") || StringUtils.equalsIgnoreCase(view.getType(), "bar-time-range")) { + if (StringUtils.equalsAnyIgnoreCase(view.getType(), "table-pivot", "bar-time-range") + || StringUtils.containsIgnoreCase(view.getType(), "group") + || ("antv".equalsIgnoreCase(view.getRender()) && "line".equalsIgnoreCase(view.getType()))) { List xAxisExt = gson.fromJson(view.getXAxisExt(), new TypeToken>() { }.getType()); xAxis.addAll(xAxisExt); @@ -402,7 +405,7 @@ public class ChartViewService { switch (view.getType()) { case "label": - xAxis = xAxis.stream().filter(item -> !desensitizationList.keySet().contains(item.getDataeaseName()) && dataeaseNames.contains(item.getDataeaseName())).collect(Collectors.toList()); + xAxis = xAxis.stream().filter(item -> !desensitizationList.containsKey(item.getDataeaseName()) && dataeaseNames.contains(item.getDataeaseName())).collect(Collectors.toList()); yAxis = new ArrayList<>(); if (CollectionUtils.isEmpty(xAxis)) { return new ArrayList(); @@ -412,7 +415,7 @@ public class ChartViewService { case "gauge": case "liquid": xAxis = new ArrayList<>(); - yAxis = yAxis.stream().filter(item -> !desensitizationList.keySet().contains(item.getDataeaseName()) && dataeaseNames.contains(item.getDataeaseName())).collect(Collectors.toList()); + yAxis = yAxis.stream().filter(item -> !desensitizationList.containsKey(item.getDataeaseName()) && dataeaseNames.contains(item.getDataeaseName())).collect(Collectors.toList()); if (CollectionUtils.isEmpty(yAxis)) { return new ArrayList(); } @@ -429,8 +432,8 @@ public class ChartViewService { yAxis = yAxis.stream().filter(item -> dataeaseNames.contains(item.getDataeaseName())).collect(Collectors.toList()); break; default: - xAxis = xAxis.stream().filter(item -> !desensitizationList.keySet().contains(item.getDataeaseName()) && dataeaseNames.contains(item.getDataeaseName())).collect(Collectors.toList()); - yAxis = yAxis.stream().filter(item -> !desensitizationList.keySet().contains(item.getDataeaseName()) && dataeaseNames.contains(item.getDataeaseName())).collect(Collectors.toList()); + xAxis = xAxis.stream().filter(item -> !desensitizationList.containsKey(item.getDataeaseName()) && dataeaseNames.contains(item.getDataeaseName())).collect(Collectors.toList()); + yAxis = yAxis.stream().filter(item -> !desensitizationList.containsKey(item.getDataeaseName()) && dataeaseNames.contains(item.getDataeaseName())).collect(Collectors.toList()); } List extFilterList = new ArrayList<>(); @@ -1913,17 +1916,29 @@ public class ChartViewService { ChartViewDTO view = getOne(id, requestList.getQueryFrom()); List sqlData = sqlData(view, requestList, cache, fieldId); List fieldList = new ArrayList<>(); - if (StringUtils.equalsIgnoreCase(fieldType, "xAxis")) { - fieldList = gson.fromJson(view.getXAxis(), new TypeToken>() { - }.getType()); - } else if (StringUtils.equalsIgnoreCase(fieldType, "extStack")) { - fieldList = gson.fromJson(view.getExtStack(), new TypeToken>() { - }.getType()); + switch (fieldType) { + case "xaxis": { + fieldList = gson.fromJson(view.getXAxis(), new TypeToken>() { + }.getType()); + break; + } + case "extStack": { + fieldList = gson.fromJson(view.getExtStack(), new TypeToken>() { + }.getType()); + break; + } + case "xaxisExt": { + fieldList = gson.fromJson(view.getXAxisExt(), new TypeToken>() { + }.getType()); + break; + } + default: + return Collections.emptyList(); } DatasetTableField field = dataSetTableFieldsService.get(fieldId); List res = new ArrayList<>(); - if (ObjectUtils.isNotEmpty(field) && fieldList.size() > 0) { + if (ObjectUtils.isNotEmpty(field) && !fieldList.isEmpty()) { // 找到对应维度 ChartViewFieldDTO chartViewFieldDTO = null; int index = 0; @@ -1947,10 +1962,22 @@ public class ChartViewService { } } if (StringUtils.equalsIgnoreCase(fieldType, "extStack") && !skipAddIndex) { - List stack = gson.fromJson(view.getXAxis(), new TypeToken>() { + List xaxis = gson.fromJson(view.getXAxis(), new TypeToken>() { }.getType()); - index += stack.size(); - getIndex += stack.size(); + index += xaxis.size(); + getIndex += xaxis.size(); + if (StringUtils.containsIgnoreCase(view.getType(), "group")) { + List ext = gson.fromJson(view.getXAxisExt(), new TypeToken>() { + }.getType()); + index += ext.size(); + getIndex += ext.size(); + } + } + if (StringUtils.equalsIgnoreCase(fieldType, "xaxisExt") && !skipAddIndex) { + List xaxis = gson.fromJson(view.getXAxis(), new TypeToken>() { + }.getType()); + index += xaxis.size(); + getIndex += xaxis.size(); } List sortResult = resultCustomSort(fieldList, sqlData); if (ObjectUtils.isNotEmpty(chartViewFieldDTO) && (getIndex >= index)) { diff --git a/core/frontend/src/views/chart/chart/common/common_antv.js b/core/frontend/src/views/chart/chart/common/common_antv.js index 44bf308322..b112f96a25 100644 --- a/core/frontend/src/views/chart/chart/common/common_antv.js +++ b/core/frontend/src/views/chart/chart/common/common_antv.js @@ -344,6 +344,9 @@ export function getTooltip(chart) { // tooltip value formatter if (chart.type && chart.type !== 'waterfall') { + if (chart.type === 'bar-group-stack') { + tooltip.fields = [] + } tooltip.formatter = function(param) { let res = param.value @@ -455,7 +458,7 @@ export function getTooltip(chart) { } else { let name = '' if (param.group) { - name = param.name + '-' + name = param.group + '-' } if (param.category) { name += param.category diff --git a/core/frontend/src/views/chart/chart/table/table-info.js b/core/frontend/src/views/chart/chart/table/table-info.js index 6eb79e7502..61013bfbbd 100644 --- a/core/frontend/src/views/chart/chart/table/table-info.js +++ b/core/frontend/src/views/chart/chart/table/table-info.js @@ -98,10 +98,9 @@ export function baseTableInfo(s2, container, chart, action, tableData, pageInfo) if (s2Options.showSeriesNumber) { s2Options.colCell = (node) => { if (node.colIndex === 0) { - if (!customAttr.size.indexLabel) { + node.label = customAttr.size.indexLabel + if (!customAttr.size.indexLabel || customAttr.size.showTableHeader === false) { node.label = ' ' - } else { - node.label = customAttr.size.indexLabel } } } @@ -120,6 +119,11 @@ export function baseTableInfo(s2, container, chart, action, tableData, pageInfo) colCellVertical: false } } + s2Options.colCell = (node) => { + if (node.colIndex === 0) { + node.label = ' ' + } + } } // 开始渲染 diff --git a/core/frontend/src/views/chart/components/dragItem/ChartDragItem.vue b/core/frontend/src/views/chart/components/dragItem/ChartDragItem.vue index 24a877469b..ca207cd62a 100644 --- a/core/frontend/src/views/chart/components/dragItem/ChartDragItem.vue +++ b/core/frontend/src/views/chart/components/dragItem/ChartDragItem.vue @@ -195,7 +195,7 @@ {{ $t('chart.asc') }} {{ $t('chart.desc') }} {{ $t('chart.custom_sort') }}... @@ -228,6 +228,7 @@ import { getItemType, getOriginFieldName } from '@/views/chart/components/dragItem/utils' import FieldErrorTips from '@/views/chart/components/dragItem/components/FieldErrorTips' import bus from '@/utils/bus' +import { equalsAny } from '@/utils/StringUtils' export default { name: 'ChartDragItem', @@ -273,6 +274,10 @@ export default { this.chart.datasourceType === 'ds_doris' || this.chart.datasourceType === 'StarRocks' || this.chart.datasetMode === 1 + }, + showCustomSort() { + return !equalsAny(this.chart.type, 'scatter') && + !this.item.chartId } }, watch: { diff --git a/core/frontend/src/views/chart/components/dragItem/DimensionExtItem.vue b/core/frontend/src/views/chart/components/dragItem/DimensionExtItem.vue index 5cd9903258..2f79ebbd9b 100644 --- a/core/frontend/src/views/chart/components/dragItem/DimensionExtItem.vue +++ b/core/frontend/src/views/chart/components/dragItem/DimensionExtItem.vue @@ -84,6 +84,12 @@ {{ $t('chart.none') }} {{ $t('chart.asc') }} {{ $t('chart.desc') }} + + {{ $t('chart.custom_sort') }}... + @@ -181,6 +187,7 @@ import { getItemType, getOriginFieldName } from '@/views/chart/components/dragItem/utils' import FieldErrorTips from '@/views/chart/components/dragItem/components/FieldErrorTips' import bus from '@/utils/bus' +import { equalsAny } from '@/utils/StringUtils' export default { name: 'DimensionExtItem', @@ -220,6 +227,10 @@ export default { computed: { hideSpecial() { return this.chart.type === 'bar-time-range' + }, + showCustomSort() { + return !equalsAny(this.chart.type, 'bar-time-range', 'scatter') && + !this.item.chartId } }, watch: { @@ -265,8 +276,18 @@ export default { } }, sort(param) { - this.item.sort = param.type - this.$emit('onDimensionItemChange', this.item) + if (param.type === 'custom_sort') { + const item = { + index: this.index, + sort: param.type + } + this.$emit('onItemCustomSort', item) + } else { + this.item.index = this.index + this.item.sort = param.type + this.item.customSort = [] + this.$emit('onDimensionItemChange', this.item) + } }, beforeSort(type) { return { diff --git a/core/frontend/src/views/chart/components/dragItem/DimensionItem.vue b/core/frontend/src/views/chart/components/dragItem/DimensionItem.vue index b0fbd2aebd..85219b95fe 100644 --- a/core/frontend/src/views/chart/components/dragItem/DimensionItem.vue +++ b/core/frontend/src/views/chart/components/dragItem/DimensionItem.vue @@ -90,9 +90,11 @@ {{ $t('chart.asc') }} {{ $t('chart.desc') }} {{ $t('chart.custom_sort') }}... + > + {{ $t('chart.custom_sort') }}... + @@ -191,6 +193,7 @@ import { getItemType, getOriginFieldName } from '@/views/chart/components/dragIt import FieldErrorTips from '@/views/chart/components/dragItem/components/FieldErrorTips' import bus from '@/utils/bus' import { formatterItem } from '@/views/chart/chart/formatter' +import { equalsAny } from '@/utils/StringUtils' export default { name: 'DimensionItem', @@ -228,6 +231,13 @@ export default { showDateExt: false } }, + computed: { + showCustomSort() { + return !equalsAny(this.chart.type, 'scatter') && + !this.item.chartId && + (this.item.deType === 0 || this.item.deType === 5) + } + }, watch: { dimensionData: function() { this.getItemTagType() diff --git a/core/frontend/src/views/chart/view/ChartEdit.vue b/core/frontend/src/views/chart/view/ChartEdit.vue index 12155b7dbe..d5cd03f1d1 100644 --- a/core/frontend/src/views/chart/view/ChartEdit.vue +++ b/core/frontend/src/views/chart/view/ChartEdit.vue @@ -568,6 +568,7 @@ :chart="chart" @onDimensionItemChange="dimensionItemChange" @onDimensionItemRemove="dimensionItemRemove" + @onItemCustomSort="item => onCustomSort(item, 'xaxisExt')" @editItemFilter="showDimensionEditFilter" @onNameEdit="showRename" /> @@ -670,7 +671,7 @@ @editItemFilter="showDimensionEditFilter" @onNameEdit="showRename" @valueFormatter="valueFormatter" - @onCustomSort="onCustomSort" + @onCustomSort="item => onCustomSort(item, 'xaxis')" /> @@ -748,6 +749,7 @@ :chart="chart" @onDimensionItemChange="dimensionExtItemChange" @onDimensionItemRemove="dimensionItemRemove" + @onItemCustomSort="item => onCustomSort(item, 'xaxisExt')" @editItemFilter="showDimensionEditFilter" @onNameEdit="showRename" /> @@ -947,7 +949,7 @@ :quota-data="quota" @onItemChange="stackItemChange" @onItemRemove="stackItemRemove" - @onItemCustomSort="stackItemCustomSort" + @onItemCustomSort="item => onCustomSort(item, 'extStack')" @onNameEdit="showRename" /> @@ -1748,7 +1750,7 @@ > @@ -1770,40 +1772,6 @@ - - - - - - { + this.view[this.customSortFieldType].forEach(ele => { if (ele.id === this.customSortField.id) { ele.sort = 'custom_sort' ele.customSort = this.customSortList @@ -3650,24 +3612,6 @@ export default { this.closeCustomSort() this.calcData(true) }, - - stackCustomSort() { - this.showStackCustomSort = true - }, - closeStackCustomSort() { - this.showStackCustomSort = false - }, - saveStackCustomSort() { - this.view.extStack.forEach(ele => { - if (ele.id === this.customSortField.id) { - ele.sort = 'custom_sort' - ele.customSort = this.customSortList - } - }) - this.closeStackCustomSort() - this.calcData(true) - }, - fieldEdit(param) { switch (param.type) { case 'ds':