When you pass a new state to the chart, ReGraph will calculate any differences between the new and existing states and animate the changes. The result is new nodes moving smoothly in and out of the chart from sensible origins, and layouts and property changes animating to let the end user follow the changes on-screen.
On any given update, ReGraph decides what animations are required and builds a queue of changes. It will then animate those changes in series until the Chart is in the right place. If state changes occur during animation, ReGraph will simply add more changes to the animation queue.
Animation should be switched off during drag events to ensure the drag is able to complete before any associated animations are run; see the Combos Drag and Drop example.
Update Order
State changes are often complex and so to effectively manage them ReGraph animates in a particular order:
- Set component options
- Hide maps
- Uncombine combos
- Remove, add and update nodes
- Arrange combos
- Run layout
- Display a map (Leaflet Integration)
- Update selection
To control the order of animations, it may be necessary to queue multiple state changes.
Duration
You can control the speed of animation via the animation prop. Passing a time value tells ReGraph how long it should take to animate each state update (in milliseconds). This time will be shared by whatever animations are required. So if ReGraph has 1000ms to animate new items being loaded into the chart, a layout which repositions nodes, and a change to node size, then each animation will run in about a third of a second.
The example below uses setInterval to add a new item to the chart every two seconds, triggering an animated layout.
ReGraph Example
