[Feature] Improve Tooltip Synchronization with sampling: 'lttb' for Connected Charts
- Dominant language
- TypeScript
- Stars
- 67.3k
- Forks
- 19.8k
- Avg merge
- 15h 17m
- Merged PRs (30d)
- 5
Description
### What problem does this feature solve?
Currently, when two charts are connected using `echarts.connect()` and both use `sampling: 'lttb'`, the tooltip linking does not work reliably. In some cases, hovering over a point in one chart does not trigger the corresponding tooltip in the connected chart. This appears to be caused by the fact that the exact matching data point has been dropped during the LTTB resampling process. If the user zooms in far enough to reduce or eliminate sampling, the tooltip syncing starts to work correctly again.
### Minimal reproduction to demonstrate the issue: https://jsfiddle.net/4un0sk3f/20/
Tooltip synchronization between connected charts should work consistently, even when `sampling: 'lttb'` is applied. Hovering over one chart should always trigger the corresponding tooltip in the other.
### What does the proposed API look like?
To address this, a matching mechanism could be introduced that selects the nearest visible data point in the resampled dataset of the connected chart.
This matching could be based on the original x-axis value, finding the closest index after sampling. It could be implemented as an internal behavior or optionally exposed through a new configuration parameter, for example:
```
echarts.connect(charts, {
syncStrategy: 'closestSampledPoint'
});
```
This would allow tooltips to remain properly synchronized, even when aggressive sampling is applied to large datasets.
Contributor guide
Research direction
Start with the minimal reproduction at https://jsfiddle.net/4un0sk3f/20/ and inspect the tooltip linking behavior through echarts.connect() when both charts use sampling: 'lttb'. Trace how the original x-axis value maps to the resampled dataset; done means hovering one chart consistently triggers the corresponding tooltip in the other, including while sampling remains active.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- data-visualization
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100