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

分面chart.facet渲染的图,使用changeData(data)无法正常更新 #3331

Closed
1 task
no-simple opened this issue Mar 18, 2021 · 5 comments
Closed
1 task

Comments

@no-simple
Copy link

  • I have searched the issues of this repository and believe that this is not a duplicate.

Reproduction link

https://stackblitz.com/edit/8qba9y--run?file=index.ts

Steps to reproduce

import { Chart } from "@antv/g2";

let data = [
{ type: "自住房", value: 0.21, total: 37 },
{ type: "出租房", value: 0.19, total: 34 },
{ type: "空置房", value: 0.17, total: 31 },
{ type: "未知类型", value: 99.43, total: 17619 }
];

const chart = new Chart({
container: "container",
autoFit: true,
height: 300,
padding: "auto"
});
chart.data(data);
chart.legend(false);
chart.facet("rect", {
fields: ["type"],
padding: window.innerWidth > 1600 ? 25 : 15,
showTitle: false,
eachView(view, facet) {
let data = facet.data;
data.push({
type: "其他",
value: 100 - data[0].value
});
view.data(data);
view.coordinate("theta", {
radius: 1,
innerRadius: 0.8
});
view
.interval()
.adjust("stack")
.position("value")
.color("type")
.tooltip(false)
.animate({
appear: {
animation: "fade-in"
}
});
}
});
chart.render();

let b = [
{ type: "自住房", value: 0, total: 0 },
{ type: "出租房", value: 0, total: 0 },
{ type: "空置房", value: 0, total: 0 },
{ type: "未知类型", value: 0, total: 0 }
];
setTimeout(() => {
chart.changeData(b);
}, 5000);
image

Environment Info
g2 4.1.13
System -
Browser -
@Diazhao
Copy link

Diazhao commented Mar 19, 2021

这里我也发现有同样的问题。你可以在chart.changeData()之后,再执行一次chart.render(). 这样分面就可以正常更新了。
但是。最好不要这样用!看我最新提的一个issue,这种情况下使用会有内存泄漏问题。

@no-simple
Copy link
Author

这里我也发现有同样的问题。你可以在chart.changeData()之后,再执行一次chart.render(). 这样分面就可以正常更新了。
但是。最好不要这样用!看我最新提的一个issue,这种情况下使用会有内存泄漏问题。

嗯,目前可以destroy后重新执行render().

@Diazhao
Copy link

Diazhao commented Mar 19, 2021

这里我也发现有同样的问题。你可以在chart.changeData()之后,再执行一次chart.render(). 这样分面就可以正常更新了。
但是。最好不要这样用!看我最新提的一个issue,这种情况下使用会有内存泄漏问题。

嗯,目前可以destroy后重新执行render().

是的,我目前的解决方案也是这样。图表destroy后,重新render,暂时还没发现内存泄漏

@hustcc
Copy link
Member

hustcc commented Mar 25, 2021

ref:

#3333
#3339

@hustcc hustcc closed this as completed Mar 25, 2021
@mrh-code-star
Copy link

我这里也遇到了差不多的问题,分面+changeData就渲染出错,用data+render就可以实现数据动态的功能,但是会有页面闪动的问题,这个问题(页面闪动)要怎么处理?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants