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

View File

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

View File

@ -3363,6 +3363,10 @@ export default {
this.view.senior.functionCfg.emptyDataStrategy = 'ignoreData' this.view.senior.functionCfg.emptyDataStrategy = 'ignoreData'
} else if (type.includes('line')) { } else if (type.includes('line')) {
this.view.customAttr.label.position = 'top' 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 // reset custom colors
this.view.customAttr.color.seriesColors = [] this.view.customAttr.color.seriesColors = []