antvis / Graphin

A React toolkit for graph visualization based on G6
https://graphin.antv.antgroup.com
MIT License
980 stars 263 forks source link

Minimap is not attached/relative to the graph #470

Open romulorod opened 1 year ago

romulorod commented 1 year ago

Describe the bug

Whenever rendering multiple graphs and using minimaps for each one of them, the minimaps gets "lost", specially if passing options props to it because that would trigger the useEffect inside the component to render which destroys and re-renders the minimap, and what that causes is that both minimaps are rendered together instead of each minimap being "inside" its own graph.

Your Example Website or App

https://codesandbox.io/s/funny-montalcini-v89qno?file=/App.tsx

Steps to Reproduce the Bug or Issue

This is a very small example of what I'm talking about because I couldn't reproduce everything but you can get the sense of it from that code pen.

Expected behavior

Each minimap would be "attached" to its own graph

Screenshots or Videos

Expected Behavior, happens before I update the component props, as including another view. Expected Behavior

Bug after updating props to include another view. Buggy after component update props

Platform

Additional context

It happens after a component update props but since I can render from 1 to 4 charts in the same component, this should happen and the minimap should still recognize its parent graph and stick to it.

I'm not sure yet how to handle / solve this so I'd appreciate any help here, thanks in advance!!

pomelo-nwu commented 11 months ago

@romulorod https://github.com/antvis/Graphin/blob/master/packages/graphin/src/components/MiniMap/index.tsx#LL52C18-L52C30 Seems to be the problem here, we will fix it as soon as possible