How to update and plot data without creating circular references?

I have a project where I want to 1) generate some random data, 2 a) scatter plot them and 2 b) show them in a table and then 3) allow the user to change the data by clicking on the plot, dragging, removing data points and so on. The plot as well as the table should change if the user makes changes. In addition, 4) I want to have a reset button which resets the data to the initial random data set.

I spent some time working on that but run into problems all the time with either circular dependencies, problems of not being able to change constants or weird behaviour when trying to use mutables.

What would be the right way to set this up? Is this possible to build without mutables, which I apparently don’t really understand yet?

Here is an example notebook which I created for testing this: How to interact with data without creating circular dependencies? / Frederik Holtel | Observable

Yes it’s a tricky problem. I tried something a bit similar (though less advanced) in Edit data with Plot / Fil | Observable ; hope this helps!

1 Like

Cool, that’s close to what I want to do as well.

In dotEditor(), what does data = => ({...d})); do? Isn’t it possible to leave this out?

this is making a copy of the data so we don’t edit the original contents.