diff --git a/frontend/package.json b/frontend/package.json index 3da6eec8cd..5d9f2444c6 100644 --- a/frontend/package.json +++ b/frontend/package.json @@ -14,7 +14,7 @@ }, "dependencies": { "@antv/g2plot": "^2.3.32", - "@antv/s2": "^1.6.0", + "@antv/s2": "^1.7.0", "@riophae/vue-treeselect": "0.4.0", "@tinymce/tinymce-vue": "^3.2.8", "axios": "^0.21.1", diff --git a/frontend/src/components/canvas/custom-component/UserView.vue b/frontend/src/components/canvas/custom-component/UserView.vue index 611338e0e1..d03de10662 100644 --- a/frontend/src/components/canvas/custom-component/UserView.vue +++ b/frontend/src/components/canvas/custom-component/UserView.vue @@ -37,6 +37,16 @@ @onChartClick="chartClick" @onJumpClick="jumpClick" /> + { + columns.push(ele.dataeaseName) + + meta.push({ + field: ele.dataeaseName, + name: ele.name + }) + }) + + // data config + const s2DataConfig = { + fields: { + columns: columns + }, + meta: meta, + data: tableData + } + + // options + const s2Options = { + width: containerDom.offsetWidth, + height: containerDom.offsetHeight, + // showSeriesNumber: true + style: getSize(chart) + } + + // 开始渲染 + if (s2) { + s2.destroy() + } + s2 = new TableSheet(containerDom, s2DataConfig, s2Options) + + // theme + const customTheme = getCustomTheme(chart) + s2.setThemeCfg({ theme: customTheme }) + + return s2 +} + +export function baseTableNormal(s2, container, chart, action, tableData) { + const containerDom = document.getElementById(container) + + // data + const fields = chart.data.fields + if (!fields || fields.length === 0) { + if (s2) { + s2.destroy() + } + return + } + + const columns = [] + const meta = [] + fields.forEach(ele => { + columns.push(ele.dataeaseName) + + meta.push({ + field: ele.dataeaseName, + name: ele.name + }) + }) + + // data config + const s2DataConfig = { + fields: { + columns: columns + }, + meta: meta, + data: tableData + } + + // options + const s2Options = { + width: containerDom.offsetWidth, + height: containerDom.offsetHeight, + // showSeriesNumber: true + style: getSize(chart) + } + + // 开始渲染 + if (s2) { + s2.destroy() + } + s2 = new TableSheet(containerDom, s2DataConfig, s2Options) + + // theme + const customTheme = getCustomTheme(chart) + s2.setThemeCfg({ theme: customTheme }) + + return s2 +} diff --git a/frontend/src/views/chart/components/ChartComponentS2.vue b/frontend/src/views/chart/components/ChartComponentS2.vue new file mode 100644 index 0000000000..25e68cee82 --- /dev/null +++ b/frontend/src/views/chart/components/ChartComponentS2.vue @@ -0,0 +1,368 @@ + + + + + diff --git a/frontend/src/views/chart/components/shape-attr/SizeSelectorAntV.vue b/frontend/src/views/chart/components/shape-attr/SizeSelectorAntV.vue index ad36ad6972..74dfa0bf06 100644 --- a/frontend/src/views/chart/components/shape-attr/SizeSelectorAntV.vue +++ b/frontend/src/views/chart/components/shape-attr/SizeSelectorAntV.vue @@ -81,6 +81,16 @@ + + + + + @@ -92,20 +102,29 @@ - + - + - - - - + + + {{ $t('chart.table_column_adapt') }} + + {{ $t('chart.table_column_custom') }} + + + +
+ 列宽并非任何时候都能生效。 +
+ 容器宽度优先级高于列宽,即(表格容器宽度 / 列数 > 指定列宽),则列宽优先取(容器宽度 / 列数)。 +
+ +
+
+ +
@@ -322,6 +341,9 @@ export default { this.sizeForm.liquidWaveCount = this.sizeForm.liquidWaveCount ? this.sizeForm.liquidWaveCount : DEFAULT_SIZE.liquidWaveCount this.sizeForm.tablePageSize = this.sizeForm.tablePageSize ? this.sizeForm.tablePageSize : DEFAULT_SIZE.tablePageSize + + this.sizeForm.tableColumnMode = this.sizeForm.tableColumnMode ? this.sizeForm.tableColumnMode : DEFAULT_SIZE.tableColumnMode + this.sizeForm.tableColumnWidth = this.sizeForm.tableColumnWidth ? this.sizeForm.tableColumnWidth : DEFAULT_SIZE.tableColumnWidth } } }, @@ -361,7 +383,9 @@ export default { .el-select-dropdown__item{ padding: 0 20px; } - span{font-size: 12px} +span{ + font-size: 12px +} .el-form-item{ margin-bottom: 6px; diff --git a/frontend/src/views/chart/view/ChartEdit.vue b/frontend/src/views/chart/view/ChartEdit.vue index f32461c88f..73c15a2f72 100644 --- a/frontend/src/views/chart/view/ChartEdit.vue +++ b/frontend/src/views/chart/view/ChartEdit.vue @@ -565,7 +565,7 @@ +