Description
If my understanding is correct, we can set the center point of the current view using the center
attribute (https://echarts.apache.org/zh/option.html#series-graph.center).
When we modify the center point, it will only trigger a re-render after an interaction event occurs. For example:
center: [
Math.floor(Math.random() * 10) + 500,
Math.floor(Math.random() * 10) + 400
],
There will be no change without user operation. When the user moves the view, it will only jump in place and cannot be dragged away by the user.
At the same time, when the value of center
does not change, Echarts will not apply this old value. For example:
center: [500, 400],
This will not block mouse movement because it only takes effect during initialization.
The current issue is: I want to provide a button for users to reset the view to the initial position.
I have successfully captured the graphRoam
event (https://echarts.apache.org/zh/api.html#events.graphroam) and found that it provides not only the zoom event mentioned in the documentation but also translation event information.
I have correctly counted all the dx
and dy
values and correctly calculated the actual center coordinates together with width/2
and height/2
.
center: center,
Echarts may have triggered the graphroam
event again during re-rendering, and I have counted approximately 5 times the dx
and dy
values. Event storming is the possibility that comes to my mind, so I believe this might be a bug.
If there are other ways to set the center point coordinates, please let me know, thanks!