# d3.forceSimulation - continue from current node positions when data changes

**URL:** https://talk.observablehq.com/t/d3-forcesimulation-continue-from-current-node-positions-when-data-changes/7556
**Category:** Help
**Created:** [January 24, 2023, 8:07pm UTC](https://talk.observablehq.com/t/d3-forcesimulation-continue-from-current-node-positions-when-data-changes/7556 "2023-01-24T20:07:43Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![ChrisWoodsSays](https://yyz2.discourse-cdn.com/flex030/user_avatar/talk.observablehq.com/chriswoodssays/32/3754_2.png) [@ChrisWoodsSays](https://talk.observablehq.com/u/ChrisWoodsSays)
#### Post date: [January 24, 2023, 8:07pm UTC](https://talk.observablehq.com/t/d3-forcesimulation-continue-from-current-node-positions-when-data-changes/7556/1 "2023-01-24T20:07:43Z")

</div>

I have a force directed chart with nodes grouped and then clustered by one of two selected fields in the data.

It works, with the simulation restarting from scratch each time the selected field is changed.

However, I’d like the nodes to continue moving from their current position rather than completely new coordinates generated for each cluster, so that the switch looks smooth and natural.

I’ve tried setting the x and y values to fixed values, just to see if it had any impact (and if did, then then look at how use the previous values instead), but it didn’t. So I’m not sure where to go next.

> **[Clustered Bubbles from CSV of grouped data items](https://observablehq.com/d/8e639032f957d6d6)**
>
> Based on Clustered Bubbles, rather than using random hierarchical data, this pulls in data from a CSV grouped by a "destination" field. This is converted to an array where 'group' is set to the destination value 'size' is set to the distance value a...

---

<div class="post-metadata">

### Author: ![Fil](https://yyz2.discourse-cdn.com/flex030/user_avatar/talk.observablehq.com/fil/32/207_2.png) [@Fil](https://talk.observablehq.com/u/Fil)
#### Post date: [January 24, 2023, 8:51pm UTC](https://talk.observablehq.com/t/d3-forcesimulation-continue-from-current-node-positions-when-data-changes/7556/2 "2023-01-24T20:51:13Z")

</div>

I think it works if you take nodes = pack().leaves() out of the chart cell, so that the x and y values of the nodes are not reset to the default [phyllotaxis arrangement](https://observablehq.com/@d3/force-layout-phyllotaxis).

---

<div class="post-metadata">

### Author: ![ChrisWoodsSays](https://yyz2.discourse-cdn.com/flex030/user_avatar/talk.observablehq.com/chriswoodssays/32/3754_2.png) [@ChrisWoodsSays](https://talk.observablehq.com/u/ChrisWoodsSays)
#### Post date: [January 24, 2023, 10:18pm UTC](https://talk.observablehq.com/t/d3-forcesimulation-continue-from-current-node-positions-when-data-changes/7556/3 "2023-01-24T22:18:27Z")

</div>

Thanks @Fil . I’ve tried moving it out but its still the performs in the same way.

---

<div class="post-metadata">

### Author: ![Fil](https://yyz2.discourse-cdn.com/flex030/user_avatar/talk.observablehq.com/fil/32/207_2.png) [@Fil](https://talk.observablehq.com/u/Fil)
#### Post date: [January 25, 2023, 6:48am UTC](https://talk.observablehq.com/t/d3-forcesimulation-continue-from-current-node-positions-when-data-changes/7556/4 "2023-01-25T06:48:02Z")

</div>

It seemed to work for me, but the sudden change of radius and color makes it a bit difficult to follow.
