-
Notifications
You must be signed in to change notification settings - Fork 1.6k
This issue was moved to a discussion.
You can continue the conversation there. Go to discussion →
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
chart.changeSize 调用时出现巨大BUG,造成浏览器卡死 #4889
Comments
@hexu6788 10ms 调用的报错内容可以看一下吗? |
已改4.7版本,报错信息没有了。复现BUG,使用定时器每间隔一段时间调用changeSize方法就可以复现BUG |
性能这个问题,这个 PR 已经解决部分:#4899 |
当前这个 pr 的问题解决了吗? |
没有,正在解决 |
@hexu6788 这里例子看上去没有问题呢? import { Chart } from '@antv/g2';
const step = 10;
let width = 600;
let height = 400;
const chart = new Chart({
container: 'container',
theme: 'classic',
width,
height,
});
chart.data([
{ genre: 'Sports', sold: 275 },
{ genre: 'Strategy', sold: 115 },
{ genre: 'Action', sold: 120 },
{ genre: 'Shooter', sold: 350 },
{ genre: 'Other', sold: 150 },
]);
chart
.interval()
.encode('x', 'genre')
.encode('y', 'sold')
.encode('color', 'genre')
.animate(false);
chart.render();
let count = -1;
setInterval(() => {
if (count > 20) return;
count++;
chart.changeSize((width += step), (height += step));
}, 10); |
@hexu6788 这个代码中,最好能加一个 debounce 或者 throttle,另外很卡的问题,可以看看是否是因为 watch 带来的死循环,加个打印语句。 watch([() => props..width, () => props..height], () => {
console.log('111', props.width, props.height); // 👈🏻 这里
chart.changeSize(props..width, props..height)
}) |
This issue was moved to a discussion.
You can continue the conversation there. Go to discussion →
版本为 @antv/g2 5.0.3
场景:将 高宽为200px的 Chart,改为 高宽为 500px。 200px到500px的过程要渐变完成。因为循环会调用 chart.changeSize 。
每次调用高宽各增加 10px。直至高款为500px。
watch([() => props..width, () => props..height], () => {
chart.changeSize(props..width, props..height)
})
The text was updated successfully, but these errors were encountered: