feat(视图-表格): AntV明细表,透视表支持空值策略

https://www.tapd.cn/55578866/prong/stories/view/1155578866001011957
This commit is contained in:
wisonic-s 2023-05-26 12:07:10 +08:00
parent 06fef344ac
commit d71f031f29
3 changed files with 32 additions and 19 deletions

View File

@ -127,14 +127,15 @@ export function baseTableInfo(s2, container, chart, action, tableData, pageInfo)
})
})
}
// 空值处理
const newData = handleTableEmptyStrategy(tableData, chart)
// data config
const s2DataConfig = {
fields: {
columns: columns
},
meta: meta,
data: tableData
data: newData
}
const customAttr = JSON.parse(chart.customAttr)
@ -494,7 +495,8 @@ export function baseTablePivot(s2, container, chart, action, headerAction, table
}
sortParams.push(sort)
}
// 空值处理
const newData = handleTableEmptyStrategy(tableData, chart)
// data config
const s2DataConfig = {
fields: {
@ -503,7 +505,7 @@ export function baseTablePivot(s2, container, chart, action, headerAction, table
values: v
},
meta: meta,
data: tableData,
data: newData,
sortParams: sortParams
}

View File

@ -132,21 +132,21 @@ export default {
},
computed: {
showSlider() {
return this.chart.type !== 'bidirectional-bar' && !equalsAny(this.chart.type, 'map')
return this.chart.type !== 'bidirectional-bar' &&
!equalsAny(this.chart.type, 'map') &&
!includesAny(this.chart.type, 'table')
},
showEmptyStrategy() {
return (this.chart.render === 'antv' &&
(includesAny(this.chart.type, 'line', 'bar', 'area') ||
equalsAny(this.chart.type, 'table-normal'))) ||
includesAny(this.chart.type, 'line', 'bar', 'area', 'table')) ||
(this.chart.render === 'echarts' && equalsAny(this.chart.type, 'map'))
},
showIgnoreOption() {
return !equalsAny(this.chart.type, 'map')
return !equalsAny(this.chart.type, 'map', 'table-pivot', 'table-info')
},
showEmptyDataFieldCtrl() {
return this.showEmptyStrategy &&
this.functionForm.emptyDataStrategy !== 'breakLine' &&
equalsAny(this.chart.type, 'table-normal')
this.functionForm.emptyDataStrategy !== 'breakLine'
}
},
watch: {
@ -180,20 +180,27 @@ export default {
initFieldCtrl() {
if (this.showEmptyDataFieldCtrl) {
this.fieldOptions = []
let yAxis = []
if (Object.prototype.toString.call(this.chart.xaxis) === '[object Array]') {
yAxis = this.chart.yaxis
} else {
yAxis = JSON.parse(this.chart.yaxis)
let axis
if (equalsAny(this.chart.type, 'table-normal', 'table-pivot')) {
axis = this.chart.yaxis
}
if (this.chart.type === 'table-normal') {
yAxis.forEach(item => {
if (this.chart.type === 'table-info') {
axis = this.chart.xaxis
}
let axisArr = []
if (Object.prototype.toString.call(axis) === '[object Array]') {
axisArr = axisArr.concat(axis)
} else {
axisArr = axisArr.concat(JSON.parse(axis))
}
axisArr.forEach(item => {
if (item.groupType === 'q') {
this.fieldOptions.push({
label: item.name,
value: item.dataeaseName
})
})
}
}
})
}
},
changeFunctionCfg() {

View File

@ -3363,6 +3363,10 @@ export default {
this.view.senior.functionCfg.emptyDataStrategy = 'ignoreData'
} else if (type.includes('line')) {
this.view.customAttr.label.position = 'top'
} else if (equalsAny(type, 'table-info', 'table-pivot')) {
if (this.view?.senior?.functionCfg?.emptyDataStrategy === 'ignoreData') {
this.view.senior.functionCfg.emptyDataStrategy = 'breakLine'
}
}
// reset custom colors
this.view.customAttr.color.seriesColors = []