Merge pull request #6117 from dataease/pr@dev@fix_pivot_col_tooltip_ellipsis

fix: 修复透视表表头悬停未显示单元格全部内容
This commit is contained in:
wisonic-s 2023-09-12 18:06:18 +08:00 committed by GitHub
commit 93151cd8ed
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -334,6 +334,10 @@ export function baseTablePivot(s2, container, chart, action, headerAction, table
const columns = [] const columns = []
const meta = [] const meta = []
const fieldMap = fields.reduce((pre, next) => {
pre[next['dataeaseName']] = next['name']
return pre
}, {})
// add drill list // add drill list
if (chart.drill) { if (chart.drill) {
@ -486,10 +490,10 @@ export function baseTablePivot(s2, container, chart, action, headerAction, table
// hover // hover
const size = customAttr?.size const size = customAttr?.size
if (size?.tableRowTooltip?.show) { if (size?.tableRowTooltip?.show) {
s2.on(S2Event.ROW_CELL_HOVER, event => showTooltip(s2, event)) s2.on(S2Event.ROW_CELL_HOVER, event => showTooltip(s2, event, fieldMap))
} }
if (size?.tableColTooltip?.show) { if (size?.tableColTooltip?.show) {
s2.on(S2Event.COL_CELL_HOVER, event => showTooltip(s2, event)) s2.on(S2Event.COL_CELL_HOVER, event => showTooltip(s2, event, fieldMap))
} }
// theme // theme
const customTheme = getCustomTheme(chart) const customTheme = getCustomTheme(chart)
@ -703,10 +707,13 @@ function mappingColor(value, defaultColor, field, type) {
return color return color
} }
function showTooltip(s2Instance, event) { function showTooltip(s2Instance, event, fieldMap) {
const cell = s2Instance.getCell(event.target) const cell = s2Instance.getCell(event.target)
const content = cell.actualText const meta = cell.getMeta()
let content = meta.value
if (fieldMap?.[content]) {
content = fieldMap?.[content]
}
s2Instance.showTooltip({ s2Instance.showTooltip({
position: { position: {
x: event.clientX, x: event.clientX,