Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug] 缩放父元素会导致图表执行了多次 #3832

Open
yibird opened this issue Mar 21, 2025 · 4 comments
Open

[Bug] 缩放父元素会导致图表执行了多次 #3832

yibird opened this issue Mar 21, 2025 · 4 comments
Assignees
Labels
bug Something isn't working

Comments

@yibird
Copy link

yibird commented Mar 21, 2025

Version

1.13.7

Link to Minimal Reproduction

缩放父元素并不会导致RecentlyVisited组件重新渲染,但是图表却执行了多次

Steps to Reproduce

import { useEffect, useRef } from "react";
import { Card } from "antd";
import { AreaChart, type VChartCore, type ISpec } from "@visactor/react-vchart";

import type { RecentlyVisiteData } from "./types";

const data: RecentlyVisiteData[] = [
{ date: "2024-10-01", value: 3 },
{ date: "2024-10-02", value: 4 },
{ date: "2024-10-03", value: 100 },
{ date: "2024-10-04", value: 5 },
{ date: "2024-10-05", value: 60 },
{ date: "2024-10-06", value: 6 },
{ date: "2024-10-07", value: 7 },
{ date: "2024-10-08", value: 2 },
{ date: "2024-10-09", value: 113 },
];

const spec = {
type: "area",
data: {
id: "recentlyVisite",
values: [],
},
xField: "date",
yField: "value",
line: {
style: {
curveType: "monotone",
},
},
} as ISpec;

// 最近访问
export default function RecentlyVisited() {
const chartRef = useRef(null);
useEffect(() => {
const timer = setTimeout(() => {
chartRef.current?.updateData("recentlyVisite", data, undefined, { reAnimate: true });
}, 500);
const chartInstance = chartRef.current;
return () => {
chartInstance?.release();
clearTimeout(timer);
};
}, []);

return (



);
}
缩放父元素并不会导致RecentlyVisited组件重新渲染,但是图表却执行了多次

Image

Current Behavior

缩放父元素并不会导致RecentlyVisited组件重新渲染,但是图表却执行了多次

Expected Behavior

缩放父元素并不会导致RecentlyVisited组件重新渲染,但是图表却执行了多次

Environment

- OS:
- Browser:
- Framework:

Any additional comments?

缩放父元素并不会导致RecentlyVisited组件重新渲染,但是图表却执行了多次

@yibird yibird added the bug Something isn't working label Mar 21, 2025
@xile611
Copy link
Contributor

xile611 commented Mar 21, 2025

@yibird 父容器应该做了动画吧
图表内部默认做了resize 的监听,父容器的动画,应该会导致触发多次resize, 所以看起来会有多次更新

@yibird
Copy link
Author

yibird commented Mar 24, 2025

@xile611 请问有解决方案吗?

@xile611
Copy link
Contributor

xile611 commented Mar 24, 2025

@xiaoluoHe resize 触发的动画可以关掉吗?同步一下配置吧

@xiaoluoHe
Copy link
Contributor

@xiaoluoHe resize 触发的动画可以关掉吗?同步一下配置吧

gif 看上去重复执行的是 appear 动画。
目测是代码里 updateSpec 第四个参数{ reAnimate: true }设置问题,可以去掉试一下

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants