diff --git a/frontend/src/lang/en.js b/frontend/src/lang/en.js
index 70576e101f..72e253be4a 100644
--- a/frontend/src/lang/en.js
+++ b/frontend/src/lang/en.js
@@ -1441,7 +1441,12 @@ export default {
proportion: 'Proportion',
label_content: 'Label Content',
percent: 'Percent',
- table_index_desc: 'Index Header Name'
+ table_index_desc: 'Index Header Name',
+ total_sort: 'Total Sort',
+ total_sort_none: 'None',
+ total_sort_asc: 'ASC',
+ total_sort_desc: 'DESC',
+ total_sort_field: 'Sort Field'
},
dataset: {
spend_time: 'Spend',
diff --git a/frontend/src/lang/tw.js b/frontend/src/lang/tw.js
index 2d7a6ca4f8..ee8d9b1d31 100644
--- a/frontend/src/lang/tw.js
+++ b/frontend/src/lang/tw.js
@@ -1441,7 +1441,12 @@ export default {
proportion: '佔比',
label_content: '標籤展示',
percent: '占比',
- table_index_desc: '表頭名稱'
+ table_index_desc: '表頭名稱',
+ total_sort: '總計排序',
+ total_sort_none: '無',
+ total_sort_asc: '升序',
+ total_sort_desc: '降序',
+ total_sort_field: '排序字段'
},
dataset: {
spend_time: '耗時',
diff --git a/frontend/src/lang/zh.js b/frontend/src/lang/zh.js
index e99ddb82f4..ba5fe35c28 100644
--- a/frontend/src/lang/zh.js
+++ b/frontend/src/lang/zh.js
@@ -1440,7 +1440,12 @@ export default {
proportion: '占比',
label_content: '标签展示',
percent: '占比',
- table_index_desc: '表头名称'
+ table_index_desc: '表头名称',
+ total_sort: '总计排序',
+ total_sort_none: '无',
+ total_sort_asc: '升序',
+ total_sort_desc: '降序',
+ total_sort_field: '排序字段'
},
dataset: {
spend_time: '耗时',
diff --git a/frontend/src/views/chart/chart/chart.js b/frontend/src/views/chart/chart/chart.js
index c2c3bf250a..a1083cc57a 100644
--- a/frontend/src/views/chart/chart/chart.js
+++ b/frontend/src/views/chart/chart/chart.js
@@ -172,7 +172,9 @@ export const DEFAULT_TOTAL = {
},
calcSubTotals: {
aggregation: 'SUM'
- }
+ },
+ totalSort: 'none', // asc,desc
+ totalSortField: ''
},
col: {
showGrandTotals: true,
@@ -187,7 +189,9 @@ export const DEFAULT_TOTAL = {
},
calcSubTotals: {
aggregation: 'SUM'
- }
+ },
+ totalSort: 'none', // asc,desc
+ totalSortField: ''
}
}
export const DEFAULT_TITLE_STYLE = {
diff --git a/frontend/src/views/chart/chart/table/table-info.js b/frontend/src/views/chart/chart/table/table-info.js
index 6b37d6fe84..976215d370 100644
--- a/frontend/src/views/chart/chart/table/table-info.js
+++ b/frontend/src/views/chart/chart/table/table-info.js
@@ -1,4 +1,4 @@
-import { TableSheet, S2Event, PivotSheet, DataCell } from '@antv/s2'
+import { TableSheet, S2Event, PivotSheet, DataCell, EXTRA_FIELD, TOTAL_VALUE } from '@antv/s2'
import { getCustomTheme, getSize } from '@/views/chart/chart/common/common_table'
import { DEFAULT_COLOR_CASE, DEFAULT_TOTAL } from '@/views/chart/chart/chart'
import { formatterItem, valueFormatter } from '@/views/chart/chart/formatter'
@@ -403,17 +403,6 @@ export function baseTablePivot(s2, container, chart, action, tableData) {
})
}
- // data config
- const s2DataConfig = {
- fields: {
- rows: r,
- columns: c,
- values: v
- },
- meta: meta,
- data: tableData
- }
-
// total config
let totalCfg = {}
const chartObj = JSON.parse(JSON.stringify(chart))
@@ -433,6 +422,43 @@ export function baseTablePivot(s2, container, chart, action, tableData) {
totalCfg.row.subTotalsDimensions = r
totalCfg.col.subTotalsDimensions = c
+ // 解析合计、小计排序
+ const sortParams = []
+ if (totalCfg.row.totalSort && totalCfg.row.totalSort !== 'none' && c.length > 0) {
+ const sort = {
+ sortFieldId: c[0],
+ sortMethod: totalCfg.row.totalSort.toUpperCase(),
+ sortByMeasure: TOTAL_VALUE,
+ query: {
+ [EXTRA_FIELD]: totalCfg.row.totalSortField
+ }
+ }
+ sortParams.push(sort)
+ }
+ if (totalCfg.col.totalSort && totalCfg.col.totalSort !== 'none' && r.length > 0) {
+ const sort = {
+ sortFieldId: r[0],
+ sortMethod: totalCfg.col.totalSort.toUpperCase(),
+ sortByMeasure: TOTAL_VALUE,
+ query: {
+ [EXTRA_FIELD]: totalCfg.col.totalSortField
+ }
+ }
+ sortParams.push(sort)
+ }
+
+ // data config
+ const s2DataConfig = {
+ fields: {
+ rows: r,
+ columns: c,
+ values: v
+ },
+ meta: meta,
+ data: tableData,
+ sortParams: sortParams
+ }
+
// options
const s2Options = {
width: containerDom.offsetWidth,
diff --git a/frontend/src/views/chart/components/shapeAttr/TotalCfg.vue b/frontend/src/views/chart/components/shapeAttr/TotalCfg.vue
index 146af8ba11..bac489ec89 100644
--- a/frontend/src/views/chart/components/shapeAttr/TotalCfg.vue
+++ b/frontend/src/views/chart/components/shapeAttr/TotalCfg.vue
@@ -67,6 +67,40 @@
/>
+
+
+ {{ $t('chart.total_sort_none') }}
+ {{ $t('chart.total_sort_asc') }}
+ {{ $t('chart.total_sort_desc') }}
+
+
+
+
+
+
+
+
+
+ {{ $t('chart.total_sort_none') }}
+ {{ $t('chart.total_sort_asc') }}
+ {{ $t('chart.total_sort_desc') }}
+
+
+
+
+
+
+
0) {
+ if (this.totalForm.row.totalSortField === '') {
+ this.totalForm.row.totalSortField = this.totalSortFields[0].dataeaseName
+ }
+ if (this.totalForm.col.totalSortField === '') {
+ this.totalForm.col.totalSortField = this.totalSortFields[0].dataeaseName
+ }
+ }
}
},
changeTotalCfg(modifyName) {