[Bug] Legend click not responding when setOption is called at high frequency (≥30fps)

オープン
#21,566 コメント 2 件 リアクション 0 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

評価

難易度
4/5
見積もり時間
3〜5日
初心者へのやさしさ
48/100
issue の種類
バグ
明瞭さ
おおむね明確
活発さ
静か
技術スタック
typescript

調査の方向性

更新間隔を1000/60に変更した後、dynamic-data2の例で失敗を再現します。まず、_downEl周辺におけるzrenderのmousedownおよびmouseupのクリック検出を追跡し、動作しているmousemoveの挙動と比較します。setOptionが高頻度で実行され続ける間、凡例のクリックが一貫してトリガーされれば完了です。

索引モデルが issue の本文から書いたものです。

説明

bug en pending
Version

6.0.0

Link to Minimal Reproduction

https://echarts.apache.org/examples/zh/editor.html?c=dynamic-data2

Steps to Reproduce

Using the official https://echarts.apache.org/examples/zh/editor.html?c=dynamic-data2 example, change the update interval to 60fps:

setInterval(function () {
  for (var i = 0; i < 5; i++) {
    data.shift();
    data.push(randomData());
  }
  myChart.setOption({
    series: [{ data: data }]
  });
}, 1000 / 60);  // <-- changed from 1000 to 1000/60

// Add a legend:
option = {
  legend: { data: ['Fake Data'] },
  // ... rest unchanged
};

Steps to reproduce:

  1. Open the above config in ECharts playground
  2. Try clicking the legend item "Fake Data"
  3. Click multiple times — the legend rarely or never responds
Current Behavior

When setOption is called at high frequency (≥30fps, e.g. real-time WebSocket data),
clicking legend items becomes unreliable or completely unresponsive.

Expected Behavior

Legend items should be clickable regardless of how frequently setOption is called.

Environment
- OS: macOS 26.3.1、Windows 10
- Browser: Chrome Version 146.0.7680.165 (Official Build) (arm64)
- Framework: Vue3、Chrome officel example
Any additional comments?
Root Cause (suspected)

zrender's click detection saves _downEl on mousedown and compares it to the
element found at mouseup. When setOption triggers a scene graph update between
mousedown and mouseup, the legend elements may be recreated or marked dirty,
causing the reference comparison to fail and the click event to never fire.

This does not happen with mousemove (cursor change works correctly), only with
the mousedown → mouseup sequence.

Temporary solution

Replace ECharts' built-in legend with HTML elements positioned over the canvas,
and use dispatchAction({ type: 'legendToggleSelect', name }) to control
series visibility programmatically.

主要言語
TypeScript
スター
67.7k
フォーク
19.9k
PR マージ指標
30日以内にマージされた PR はありません

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

apache/echarts のほかの issue

apache/echarts の issue をすべて見る

似ている issue

TypeScript の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。