diff --git a/core/core-frontend/src/models/chart/chart-attr.d.ts b/core/core-frontend/src/models/chart/chart-attr.d.ts index bcb7c3aa6f..4a9531bf42 100644 --- a/core/core-frontend/src/models/chart/chart-attr.d.ts +++ b/core/core-frontend/src/models/chart/chart-attr.d.ts @@ -629,11 +629,18 @@ declare interface CalcTotals { */ declare interface CalcTotalCfg extends Axis { dataeaseName: string + /** + * 聚合方式 + */ aggregation: 'MIN' | 'MAX' | 'AVG' | 'SUM' | 'CUSTOM' | '' /** * 自定义汇总表达式 */ originName: string + /** + * 别名 + */ + label: string } /** diff --git a/core/core-frontend/src/views/chart/components/editor/editor-style/components/LegendSelector.vue b/core/core-frontend/src/views/chart/components/editor/editor-style/components/LegendSelector.vue index bcc153968b..297b15dedf 100644 --- a/core/core-frontend/src/views/chart/components/editor/editor-style/components/LegendSelector.vue +++ b/core/core-frontend/src/views/chart/components/editor/editor-style/components/LegendSelector.vue @@ -318,13 +318,16 @@ onMounted(() => { :label="t('chart.show_range_bg')" /> -
+
{ :effect="themes" v-model="state.legendForm.miscForm.bullet.bar.ranges.symbolSize" size="small" - @change="changeMisc()" + @change="changeMisc('bullet.bar.ranges.symbolSize')" > { total.dataeaseName = totalCfg[0].dataeaseName total.aggregation = totalCfg[0].aggregation total.originName = totalCfg[0].originName + total.label = totalCfg[0].label } }) @@ -175,6 +176,7 @@ const changeTotal = (totalItem, totals) => { if (item.dataeaseName === totalItem.dataeaseName) { totalItem.aggregation = item.aggregation totalItem.originName = item.originName + totalItem.label = item.label return } } @@ -184,6 +186,7 @@ const changeTotalAggr = (totalItem, totals, colOrNum) => { const item = totals[i] if (item.dataeaseName === totalItem.dataeaseName) { item.aggregation = totalItem.aggregation + item.label = totalItem.label break } } @@ -197,7 +200,8 @@ const setupTotalCfg = (totalCfg, axis) => { axis.forEach(i => { totalCfg.push({ dataeaseName: i.dataeaseName, - aggregation: 'SUM' + aggregation: 'SUM', + label: i.chartShowName ?? i.name }) }) return @@ -215,7 +219,8 @@ const setupTotalCfg = (totalCfg, axis) => { totalCfg.push({ dataeaseName: i.dataeaseName, aggregation: cfgMap[i.dataeaseName] ? cfgMap[i.dataeaseName].aggregation : 'SUM', - originName: cfgMap[i.dataeaseName] ? cfgMap[i.dataeaseName].originName : '' + originName: cfgMap[i.dataeaseName] ? cfgMap[i.dataeaseName].originName : '', + label: cfgMap[i.dataeaseName] ? cfgMap[i.dataeaseName].label : i.chartShowName ?? i.name }) }) } @@ -657,6 +662,27 @@ onMounted(() => { + + + { s2Options.style.hierarchyCollapse = true } } + // 列汇总别名 + if ( + chart.xAxisExt?.length && + chart.yAxis?.length > 1 && + tableTotal.col.showGrandTotals && + tableTotal.col.calcTotals?.cfg?.length + ) { + const colTotalCfgMap = tableTotal.col.calcTotals.cfg.reduce((p, n) => { + p[n.dataeaseName] = n + return p + }, {}) + s2Options.layoutCoordinate = (_, __, col) => { + if (col?.isGrandTotals) { + if (colTotalCfgMap[col.value]) { + col.label = colTotalCfgMap[col.value].label + // col.value = colTotalCfgMap[col.value].label + } + } + } + } // tooltip this.configTooltip(chart, s2Options) // 开始渲染