refactor(图表): 明细表合并单元格条件样式

This commit is contained in:
wisonic 2024-11-01 12:12:48 +08:00
parent abaac31b6c
commit 286844e1d1

View File

@ -29,7 +29,10 @@ import {
InteractionStateName, InteractionStateName,
InteractionName, InteractionName,
DataCellBrushSelection, DataCellBrushSelection,
TableDataCell TableDataCell,
MergedCell,
getPolygonPoints,
renderPolygon
} from '@antv/s2' } from '@antv/s2'
import { keys, intersection, filter, cloneDeep, merge, find, repeat } from 'lodash-es' import { keys, intersection, filter, cloneDeep, merge, find, repeat } from 'lodash-es'
import { createVNode, render } from 'vue' import { createVNode, render } from 'vue'
@ -1462,5 +1465,25 @@ export function configMergeCells(chart: Chart, options: S2Options) {
}) })
}) })
options.mergedCellsInfo = mergedCellsInfo options.mergedCellsInfo = mergedCellsInfo
options.mergedCell = (sheet, cells, meta) => {
return new CustomMergedCell(sheet, cells, meta)
}
} }
} }
class CustomMergedCell extends MergedCell {
protected drawBackgroundShape() {
const allPoints = getPolygonPoints(this.cells)
// 处理条件样式这里没有用透明度
// 因为合并的单元格是单独的图层透明度降低的话会显示底下未合并的单元格需要单独处理被覆盖的单元格
const { backgroundColor: fill, backgroundColorOpacity: fillOpacity } =
this.getBackgroundColor();
const cellTheme = this.theme.dataCell.cell
this.backgroundShape = renderPolygon(this, {
points: allPoints,
stroke: cellTheme.horizontalBorderColor,
fill,
lineHeight: cellTheme.horizontalBorderWidth,
})
}
}