Skip to content

Commit

Permalink
fix: 交叉表圈选表头复制内容不正确 (#2254)
Browse files Browse the repository at this point in the history
  • Loading branch information
1wkk committed Jun 25, 2023
1 parent 1479134 commit a4021cb
Showing 1 changed file with 15 additions and 5 deletions.
20 changes: 15 additions & 5 deletions packages/s2-core/src/utils/export/copy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import {
filter,
forEach,
isEmpty,
isEqual,
isNil,
map,
max,
Expand All @@ -12,25 +13,25 @@ import {
repeat,
zip,
} from 'lodash';
import type { ColCell, RowCell } from '../../cell';
import {
type CellMeta,
CellTypes,
CopyType,
EMPTY_PLACEHOLDER,
EXTRA_FIELD,
ID_SEPARATOR,
InteractionStateName,
VALUE_FIELD,
SERIES_NUMBER_FIELD,
VALUE_FIELD,
type CellMeta,
type RowData,
} from '../../common';
import type { DataType } from '../../data-set/interface';
import type { Node } from '../../facet/layout/node';
import type { SpreadSheet } from '../../sheet-type';
import { copyToClipboard } from '../../utils/export';
import type { ColCell, RowCell } from '../../cell';
import { getEmptyPlaceholder } from '../text';
import { flattenDeep } from '../data-set-operate';
import { getEmptyPlaceholder } from '../text';

export function keyEqualTo(key: string, compareKey: string) {
if (!key || !compareKey) {
Expand Down Expand Up @@ -659,11 +660,20 @@ function getCellMatrix(
const meta = cell.getMeta();
const { id, label, isTotals, level } = meta;
let cellId = id;

// 为总计小计补齐高度
if (isTotals && level !== maxLevel) {
cellId = id + ID_SEPARATOR + repeat(label, maxLevel - level);
}
return getHeaderList(cellId, allLevel.size);

// 将指标维度单元格的标签替换为实际文本
const actualText = cell.getActualText();
const headerList = getHeaderList(cellId, allLevel.size);
const formattedHeaderList = map(headerList, (header) =>
isEqual(header, label) ? actualText : header,
);

return formattedHeaderList;
});
}

Expand Down

1 comment on commit a4021cb

@vercel
Copy link

@vercel vercel bot commented on a4021cb Jun 25, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

antvis-s2 – ./

antvis-s2-antv-s2.vercel.app
antvis-s2-git-master-antv-s2.vercel.app
antvis-s2.vercel.app

Please sign in to comment.