antvis/G2

【v5】chart.clear 之后调用 chart.render 报错 #5296

Deathsteps posted onGitHub

问题描述

chart.clear 之后调用 chart.render ,无法重新渲染,控制台报 theme 错误。(在 chart.render 前调用 chart.interval 等重新设置也一样)

<img width="1078" alt="image" src="https://github.com/antvis/G2/assets/1549118/04da13fc-8089-4434-b636-c42fe5f3c1f3">

期望结果

可以正常 clear 重绘

如何重现

官方代码修改

/**
 * A recreation of this demo: https://observablehq.com/@d3/bar-chart
 */
import { Chart } from '@antv/g2';

const chart = new Chart({
  container: 'container',
  theme: 'classic',
  autoFit: true,
});

chart
  .interval()
  .data({
    type: 'fetch',
    value:
      'https://gw.alipayobjects.com/os/bmw-prod/fb9db6b7-23a5-4c23-bbef-c54a55fee580.csv',
  })
  .encode('x', 'letter')
  .encode('y', 'frequency')
  .axis('y', { labelFormatter: '.0%' });

chart.render();

setTimeout(() => {
  chart.clear();
  console.log(123);
  chart.render();
}, 2000);

额外信息

  • G2 5.0.15 版本

Fund this Issue

$0.00
Funded

Pull requests