Merge pull request #9782 from dataease/pr@dev@feat_table_pivot_scroll

feat(视图): 透视表支持滚动
This commit is contained in:
wisonic-s 2024-05-22 18:42:53 +08:00 committed by GitHub
commit e2fb734ceb
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -540,7 +540,12 @@ export default {
initScroll() {
const customAttr = JSON.parse(this.chart.customAttr)
const senior = JSON.parse(this.chart.senior)
if (senior?.scrollCfg?.open && (this.chart.type === 'table-normal' || (this.chart.type === 'table-info' && !this.showPage))) {
if (senior?.scrollCfg?.open) {
if (this.chart.type !== 'table-normal') {
if (this.chart.type === 'table-info' && !this.showPage) {
return
}
}
//
this.myChart.facet.timer?.stop()
if (this.myChart.store.get('scrollY') !== 0) {
@ -556,15 +561,27 @@ export default {
}
const rowHeight = customAttr.size.tableItemHeight
const headerHeight = customAttr.size.tableTitleHeight
let duration, scrollHeight
if (this.chart.type === 'table-pivot') {
const totalHeight = this.myChart.facet.viewCellHeights.getTotalHeight()
const viewHeight = this.myChart.facet.rowHeader.cfg.viewportHeight
if (totalHeight <= viewHeight) {
return
}
scrollHeight = totalHeight - viewHeight
const scrollViewCount = (totalHeight - viewHeight) / rowHeight
duration = scrollViewCount / senior.scrollCfg.row * senior.scrollCfg.interval
} else {
const scrollBarSize = this.myChart.theme.scrollBar.size
const scrollHeight = rowHeight * this.chart.data.tableRow.length + headerHeight - offsetHeight + scrollBarSize
scrollHeight = rowHeight * this.chart.data.tableRow.length + headerHeight - offsetHeight + scrollBarSize
//
if (scrollHeight < scrollBarSize) {
return
}
const viewHeight = offsetHeight - headerHeight - scrollBarSize
const scrollViewCount = this.chart.data.tableRow.length - viewHeight / rowHeight
const duration = scrollViewCount / senior.scrollCfg.row * senior.scrollCfg.interval
duration = scrollViewCount / senior.scrollCfg.row * senior.scrollCfg.interval
}
this.myChart.facet.scrollWithAnimation({
offsetY: {
value: scrollHeight,