Replies: 1 comment
-
|
@LutherLcp 您好!以下是关于您问题的自动回复: 感谢您开启这个讨论! 我们的团队会尽快查看您的问题。谢谢您的理解与支持! 此回复由 AI 助手自动生成。如有任何问题,我们的团队会尽快跟进。 |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
移动源滚动会出现错位的问题 且 getScrollOffset拿不到滚动的xy,{scrollX: 0, scrollY: NaN, rowHeaderScrollX: 0}
<img width="484" height="550" alt="image" src="https://github.com/user-attachments/assets/00d4106d-e62e-4a37-9c51-cacbcd8209bd"
`import React, { useCallback, useEffect, useMemo, useState, useRef } from 'react';
import { SheetComponent, SheetComponentOptions } from '@antv/s2-react';
import {
LayoutWidthType,
CalcTotals,
VALUE_FIELD,
EXTRA_FIELD,
type SortMethod,
TooltipOptions,
TooltipOperatorMenuItem,
S2Theme,
S2Event,
} from '@antv/s2';
import '@antv/s2-react/dist/s2-react.min.css';
const SortMethodType = {
asc: 'asc',
desc: 'desc',
none: 'none',
};
const S2Table = (props: any) => {
const { source, config = {}, id, height, configChangeCallback, relation_setting } = props;
const { getFieldMeta, aggregateS2TableData, getAllMetaData } = useSetFn(
config,
ChartTypeEnum.table,
);
.....
useEffect(() => {
if (relationSetting?.filterInfo) {
const { filterInfo } = relationSetting;
const filterKey = relationSetting?.targetIndicator?.value;
const value = filterInfo?.value;
const filterItem = {
defaultValue: value,
field: filterKey,
op: ['date'].includes(config?.col_types?.[filterKey]) ? 'custom' : 'eq',
type: config?.col_types?.[filterKey] ?? 'string',
};
}, [relationSetting]);
// 移动端滚动时防止图表消失:优化渲染逻辑,避免性能问题
useEffect(() => {
if (!isMobile) return;
}, [isMobile, showChart]);
return (
<>
{showChart ? (
<div className={
h-[parent] flex flex-col ${styles.s2_table_box} mt-[8px]}><SheetComponent
ref={s2Ref}
sheetType="pivot"
adaptive={!isMobile}
onMounted={spreadsheet => {
// 组件挂载后,移动端确保正确渲染
if (isMobile && spreadsheet) {
// 保存 spreadsheet 实例到 ref
s2Ref.current = spreadsheet;
// 延迟渲染,确保布局计算完成
setTimeout(() => {
try {
// 强制重新计算布局
if (spreadsheet?.facet?.updatePanelScrollGroup) {
spreadsheet.facet.updatePanelScrollGroup();
}
);
};
export default S2Table;
`
版本:2.x
Beta Was this translation helpful? Give feedback.
All reactions