antvis/G2

分面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.

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 -

<!-- generated by antv-issue-helper. DO NOT REMOVE -->


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

posted by mrh-code-star almost 3 years ago

Fund this Issue

$0.00
Funded

Pull requests