分面chart.facet渲染的图,使用changeData(data)无法正常更新 #3331
no-simple posted onGitHub
- 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);
Environment | Info |
---|---|
g2 | 4.1.13 |
System | - |
Browser | - |
<!-- generated by antv-issue-helper. DO NOT REMOVE -->