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

fix(data): render empty data #5098

Merged
merged 1 commit into from
May 26, 2023
Merged

fix(data): render empty data #5098

merged 1 commit into from
May 26, 2023

Conversation

pearmini
Copy link
Member

空数据

当 changeData 数据为空的时候,会有 undefined 绘制。

存在问题

  • line 和 area 空数据的 index 获得错误。
  • 空数据时候,连续比例尺的 domain 计算错误:因为 domainMin 和 domainMax 的关系得到 [undefined, undefined] 的情况。

案例

clear-empty-data

export function chartChangeDataEmpty(context) {
  const { container, canvas } = context;

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

  chart.options({
    theme: 'classic',
    type: 'line',
    clip: true,
    data: {
      type: 'fetch',
      value: 'data/aapl.csv',
    },
    encode: {
      x: 'date',
      y: 'close',
    },
  });

  const finished = chart.render().then((chart) => chart.changeData([]));

  return { chart, finished };
}

@pearmini pearmini requested a review from hustcc May 26, 2023 03:39
@hustcc hustcc merged commit 6de9e33 into v5 May 26, 2023
@hustcc hustcc deleted the fix/change-empty-data branch May 26, 2023 04:37
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

Successfully merging this pull request may close these issues.

2 participants