cell error when loading page

Hello

I worked on my project, and everything appears to work correctly. When I reload the page, it seems that one or more cells do not run, so I see an error. And by running that cell again, I can see the correct output. Do you have any ideas how I can fix it? I was thinking of a while loop as an example.

1 Like

This can sometimes occur if you’re relying on cross-cell mutation (side effects). I wrote a little about that here:

If you’d like to share your notebook, we might be able to provide more specific guidance.

1 Like

Thank you so much for your response. here is my code HW2 / Fatemeh Nazari | Observable

most of the time i have problem with the radar chart.

1 Like

As Mike indicated, you’ve got a side effect that needs to finish before your visualizations can run. In particular, the cell that looks like so

{
   // in this cell we want to add calculated similarity column, for each car, with the BMW 2002
  data.forEach((element) => { 
    ... 
  }
}

processes and modifies the data to make some changes that are necessary for the visualizations. To fix this, you can name that cell and then refer to that value in the cells that require it. Perhaps something like:

process = {
   // in this cell we want to add calculated similarity column, for each car, with the BMW 2002
  data.forEach((element) => { 
    ... 
  }
}

Then,

Radar_Chart = {
  process;
  var margin = { top: 100, right: 100, bottom: 100, left: 100 },
    ...
}
1 Like

great! that worked perfectly. I would appreciate it if you could tell me how to do that for my scatter plot because sometimes I have the same problem there too.

I think I could fix that one too. Thank you and Mike for the tips.

1 Like