antvis/G2



The issue has been closed
[v5] 调用 changeData 后,图例没有同步更新。 #4939
pepper-nice posted onGitHub
代码
const chart = new Chart({ theme: 'classic', container: div, canvas });
chart.data([
{ genre: 'Sports', sold: 275 },
{ genre: 'Strategy', sold: 115 },
{ genre: 'Action', sold: 120 },
{ genre: 'Shooter', sold: 350 },
{ genre: 'Other', sold: 150 },
]);
const interval = chart
.interval()
.encode('x', 'genre')
.encode('y', 'sold')
.encode('color', 'genre');
const finished = chart.render();
button.onclick = () => {
interval.changeData([
{ genre: 'Action', sold: 120 },
{ genre: 'Shooter', sold: 350 },
]);
};