mirror of
https://github.com/dataease/dataease.git
synced 2026-05-14 21:12:33 +08:00
fix(图表):修复透视表在大屏中行头宽度渲染错误
This commit is contained in:
@@ -389,6 +389,10 @@ declare interface ChartBasicStyle {
|
|||||||
* 透视表行头宽度
|
* 透视表行头宽度
|
||||||
*/
|
*/
|
||||||
tableRowHeaderWidth: number
|
tableRowHeaderWidth: number
|
||||||
|
/**
|
||||||
|
* 透视表行头宽度百分比
|
||||||
|
*/
|
||||||
|
tableRowHeaderWidthPercent: number
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* 表头属性
|
* 表头属性
|
||||||
|
|||||||
@@ -121,7 +121,8 @@ export const customAttrTrans = {
|
|||||||
'lineSymbolSize',
|
'lineSymbolSize',
|
||||||
'leftLineWidth',
|
'leftLineWidth',
|
||||||
'leftLineSymbolSize',
|
'leftLineSymbolSize',
|
||||||
'tableColumnWidth'
|
'tableColumnWidth',
|
||||||
|
'tableRowHeaderWidth'
|
||||||
],
|
],
|
||||||
tableHeader: [
|
tableHeader: [
|
||||||
'tableTitleFontSize',
|
'tableTitleFontSize',
|
||||||
|
|||||||
@@ -65,12 +65,27 @@ const state = reactive({
|
|||||||
fieldId: '',
|
fieldId: '',
|
||||||
width: 0
|
width: 0
|
||||||
},
|
},
|
||||||
fileList: []
|
fileList: [],
|
||||||
|
treeRowWidth: 10
|
||||||
})
|
})
|
||||||
const emit = defineEmits(['onBasicStyleChange', 'onMiscChange'])
|
const emit = defineEmits(['onBasicStyleChange', 'onMiscChange'])
|
||||||
const changeBasicStyle = (prop?: string, requestData = false, render = true) => {
|
const changeBasicStyle = (prop?: string, requestData = false, render = true) => {
|
||||||
emit('onBasicStyleChange', { data: state.basicStyleForm, requestData, render }, prop)
|
emit('onBasicStyleChange', { data: state.basicStyleForm, requestData, render }, prop)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const changeTreeRowWidth = () => {
|
||||||
|
if (state.basicStyleForm.tableRowHeaderMode === 'percent') {
|
||||||
|
state.basicStyleForm.tableRowHeaderWidthPercent = state.treeRowWidth
|
||||||
|
}
|
||||||
|
if (state.basicStyleForm.tableRowHeaderMode === 'fixed') {
|
||||||
|
state.basicStyleForm.tableRowHeaderWidth = state.treeRowWidth
|
||||||
|
}
|
||||||
|
changeBasicStyle(
|
||||||
|
state.basicStyleForm.tableRowHeaderMode === 'percent'
|
||||||
|
? 'tableRowHeaderWidthPercent'
|
||||||
|
: 'tableRowHeaderWidth'
|
||||||
|
)
|
||||||
|
}
|
||||||
const onAlphaChange = v => {
|
const onAlphaChange = v => {
|
||||||
const _v = parseInt(v)
|
const _v = parseInt(v)
|
||||||
if (_v >= 0 && _v <= 100) {
|
if (_v >= 0 && _v <= 100) {
|
||||||
@@ -146,13 +161,15 @@ const init = () => {
|
|||||||
tableExpandLevelOptions.push({ name, value: i })
|
tableExpandLevelOptions.push({ name, value: i })
|
||||||
}
|
}
|
||||||
if (basicStyle.tableRowHeaderMode === 'percent') {
|
if (basicStyle.tableRowHeaderMode === 'percent') {
|
||||||
if (basicStyle.tableRowHeaderWidth > 50) {
|
state.treeRowWidth = basicStyle.tableRowHeaderWidthPercent
|
||||||
state.basicStyleForm.tableRowHeaderWidth = 20
|
if (basicStyle.tableRowHeaderWidthPercent > 80) {
|
||||||
|
state.treeRowWidth = 80
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (basicStyle.tableRowHeaderMode === 'fixed') {
|
if (basicStyle.tableRowHeaderMode === 'fixed') {
|
||||||
|
state.treeRowWidth = basicStyle.tableRowHeaderWidth
|
||||||
if (basicStyle.tableRowHeaderWidth < 10) {
|
if (basicStyle.tableRowHeaderWidth < 10) {
|
||||||
state.basicStyleForm.tableRowHeaderWidth = 120
|
state.treeRowWidth = 120
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1029,11 +1046,11 @@ onMounted(async () => {
|
|||||||
>
|
>
|
||||||
<el-input-number
|
<el-input-number
|
||||||
:effect="themes"
|
:effect="themes"
|
||||||
v-model.number="state.basicStyleForm.tableRowHeaderWidth"
|
v-model.number="state.treeRowWidth"
|
||||||
:min="state.basicStyleForm.tableRowHeaderMode === 'percent' ? 1 : 10"
|
:min="state.basicStyleForm.tableRowHeaderMode === 'percent' ? 1 : 10"
|
||||||
:max="state.basicStyleForm.tableRowHeaderMode === 'percent' ? 50 : 100000"
|
:max="state.basicStyleForm.tableRowHeaderMode === 'percent' ? 80 : 100000"
|
||||||
controls-position="right"
|
controls-position="right"
|
||||||
@change="changeBasicStyle('tableRowHeaderWidth')"
|
@change="changeTreeRowWidth"
|
||||||
/>
|
/>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item v-if="showProperty('autoWrap')" class="form-item" :class="'form-item-' + themes">
|
<el-form-item v-if="showProperty('autoWrap')" class="form-item" :class="'form-item-' + themes">
|
||||||
|
|||||||
@@ -1733,7 +1733,8 @@ export const DEFAULT_BASIC_STYLE: ChartBasicStyle = {
|
|||||||
quotaPosition: 'col',
|
quotaPosition: 'col',
|
||||||
quotaColLabel: t('dataset.value'),
|
quotaColLabel: t('dataset.value'),
|
||||||
tableRowHeaderMode: 'adapt',
|
tableRowHeaderMode: 'adapt',
|
||||||
tableRowHeaderWidth: 10
|
tableRowHeaderWidth: 120,
|
||||||
|
tableRowHeaderWidthPercent: 20
|
||||||
}
|
}
|
||||||
|
|
||||||
export const BASE_VIEW_CONFIG = {
|
export const BASE_VIEW_CONFIG = {
|
||||||
|
|||||||
@@ -267,7 +267,12 @@ export class TablePivot extends S2ChartView<PivotSheet> {
|
|||||||
// options
|
// options
|
||||||
s2Options.style = this.configStyle(chart, s2DataConfig)
|
s2Options.style = this.configStyle(chart, s2DataConfig)
|
||||||
if (basicStyle.tableLayoutMode === 'tree') {
|
if (basicStyle.tableLayoutMode === 'tree') {
|
||||||
const { defaultExpandLevel, tableRowHeaderMode, tableRowHeaderWidth } = basicStyle
|
const {
|
||||||
|
defaultExpandLevel,
|
||||||
|
tableRowHeaderMode,
|
||||||
|
tableRowHeaderWidth,
|
||||||
|
tableRowHeaderWidthPercent
|
||||||
|
} = basicStyle
|
||||||
// 默认展开层级
|
// 默认展开层级
|
||||||
if (isNumeric(defaultExpandLevel)) {
|
if (isNumeric(defaultExpandLevel)) {
|
||||||
if ((defaultExpandLevel as number) >= chart.xAxis.length) {
|
if ((defaultExpandLevel as number) >= chart.xAxis.length) {
|
||||||
@@ -292,11 +297,11 @@ export class TablePivot extends S2ChartView<PivotSheet> {
|
|||||||
s2Options.style.treeRowsWidth = treeRowsWidth
|
s2Options.style.treeRowsWidth = treeRowsWidth
|
||||||
}
|
}
|
||||||
if (tableRowHeaderMode === 'percent') {
|
if (tableRowHeaderMode === 'percent') {
|
||||||
let treeRowsWidth = tableRowHeaderWidth
|
let treeRowsWidthPercent = tableRowHeaderWidthPercent
|
||||||
if (treeRowsWidth > 50) {
|
if (treeRowsWidthPercent > 80) {
|
||||||
treeRowsWidth = 20
|
treeRowsWidthPercent = 20
|
||||||
}
|
}
|
||||||
const width = containerDom.offsetWidth * (treeRowsWidth / 100)
|
const width = containerDom.offsetWidth * (treeRowsWidthPercent / 100)
|
||||||
s2Options.style.treeRowsWidth = width
|
s2Options.style.treeRowsWidth = width
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user