apache / echarts

Apache ECharts is a powerful, interactive charting and data visualization library for browser
https://echarts.apache.org
Apache License 2.0
60.69k stars 19.62k forks source link

[Bug] Selected state not correctly redrawn when updating map data with `setOption` #20502

Open henrik-wolf opened 1 week ago

henrik-wolf commented 1 week ago

Version

5.5.1

Link to Minimal Reproduction

https://codepen.io/SupergGrobi/pen/YzmdOKW

Steps to Reproduce

  1. Select an area by clicking on it.
  2. click the "new data" button
  3. hover above one of the two areas

Current Behavior

when clicking the "new data" button (which updates the data.value field of every entry in the map series) while an area is selected, the new data is accurately updated for all areas, however, the state of the current selection is no longer shown, but re-appears when hovering over the dataseries.

Expected Behavior

the unselected areas are redrawn with the new colors and the selected area is drawn considering the styling for highlighted/selected datapoints. No hovering should be required to get to this state.

Environment

- OS:macOS Sonoma
- Browser: Chrome
- Framework: plain javascript as well as Vue@3

Any additional comments?

This behaviour seems to be connected to having the geo component explicitly present in the options. In my usecase, I need it explicitly, as I want to scatter some points into the same map later on (see the mwe). (although the behaviour in that case is not super smooth either)

Somehow, this seems to work with an svg map, as in this example: modified french beef map (which updates the data a second after each selection)

helgasoft commented 1 week ago

not-a-bug, scatter update on map works fine - Demo Please close issue if problem solved. Debug and "how to" questions are better posted on stackoverflow, where there are more volunteers to help. 🚩 Please follow Official posting guidelines (below).


The issue list is reserved exclusively for bug reports and feature requests. For usage questions, please use the following resources:

henrik-wolf commented 1 week ago

Scatter works fine. It is the update of the map series (id 0) which causes the problems. I remove the scatter from the mwe, to highlight the issue. (I had it in there to show that my use case can not be reformulated in terms of only a series, without the geo component)

helgasoft commented 1 week ago

If you update the map geometry, then you'll have to register it again with echarts.registerMap. Should work...

henrik-wolf commented 1 week ago

I do not update the map geometry. I update the data from which the colors of each area are calculated. My whole problem is, that when I do this, the selected state of an area is not correctly redrawn.

image

henrik-wolf commented 1 week ago

After some more experimentation, there seems to be an inconsistency in the way svg map are handled compared to geojson maps. In this pen I set up two identical plots, the left one using the svg representation of some test data and the right one using the geojson representation.

When clicking an area in the left plot, the selection-highlighting is preserved when changing the data, while in the right plot, it isn't.