apache / apache/echarts

[Feature] accessing legend unselected series in tooltip formatter function

Open
#20,731 4 comments 0 reactions 0 assignees View on GitHub
en new-feature topic: legend
Dominant language
TypeScript
Stars
67.3k
Forks
19.8k
Avg merge
11d 14h
Merged PRs (30d)
8

Description

### What problem does this feature solve?

https://echarts.apache.org/examples/en/editor.html?c=line-simple&code=PYBwLglsB2AEC8sDeAoWsAeBBDEDOAXMmurGAJ4gCmRA5AMYCGYVA5sAE7m0A0J6AE2aMiAbVoBZGL1i0AKgFcqM2gHUqAlXIAWClQDEOEFQGVmphdFoBdEgF8-6cjnxFUpMpRqyAbowA2SrT2jrD-bFTQAgTupABGwGBgwAC2BABEAEwApOmh6HhU4fQs0cQe6OkAjOlEAGYBhfywdiEkycD-kCAxzWBGrKxUHBmMuHh5zXWcKcwsIwAUjBwcAJTwAHyxHgJUcQqDw83o9DB4nVQAdP7ArEsrq82t6A4khUZUhLCizdukQmARN8qgBWAAMPFgmQAzBCoZkACyQzJVAAckKq0JBGIRAHZkQA2MHWfKkCjUOj-CDQZSQ6CMFLearpJ6kv6CYRiGFwzKI5FojFYnH4qFEknHTwU2RUmkyemMohZFkeZ6wWx2ADcQA

Image

---
in the tooltip formatter callback, `arr` contains only legend selected series, making it almost impossible to access unselected ones. I wanna achieve something like this, notice the series unselected by legend are still shown in the tooltip

Image

accessing the unselected data through `getOption` is not viable here, as one can unselect all series, making it impossible to get data index through `arr[0].dataIndex`. and different series may have different data layout, we can't simply reuse dataIndex

---
I did a lot of code reading but can't find where the `dataByCoordSys` is actually populated(checked `filterSeries` and related code but no luck
* can you point me the code path?

Image

---

### What does the proposed API look like?

modify the `formatter` callback signature like this, it should be mostly backward compatible
if concerned, we could add `toString` and `toJSON` to the new object, or just append a new parameter instead

Image

or we we could do the following, it works according to ECMA standards although it may look unconventional

Image

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.