Snippet Slows Down in subsequent runs - very weird


I think I may know what’s going on. The chart, I think, is attempting to rerender after each adopted row.


Yup. Confirmed. Adding/removing rows in chart snippet is problematic.

Hi Pat,

If I understand what you’re saying is the cause, it sounds like the chart is re-rendering every time its model’s contents change. Since you’re making many sequential updates, this is causing many re-renders of the chart. Is there any way you could modify your snippet to consolidate all the row updates into an array, and bundle them into one updateRows()? In Skuid’s API documentation for updateRow() there’s a note that explains “If updating several rows within a loop, it is much more efficient to use the updateRows( ) function.”

Making all my changes in one model and adopting into the final chart model when done.

My sense is that the changes to the model are causing a refresh to happen, and that’s triggering your before-render snippet. Is there a way to separate the update actions so that the before-render snippet doesn’t update models that are relevant to the chart? I am not sure there is a way to prevent the chart from trying to re-render itself if its models are updated, since that’s built-in / intended functionality. 

Running into a similar issue. Adopting rows is a neat idea, but I think for my case it’s trickier. I have a single filter set I want to apply to three different models on 3 charts in a chart set, but if you apply the condition updates all at once, all 3 charts’ before render snippets run at the same time (well, in sequence from chart 1 first to chart 3 last). So, I want to wait to requery the other charts’ models until I’m actually looking at that chart. But you can’t put a model.updateData in a before render snippet because it loops!

One solution I have - if you add a UI field called “ActiveChart”, then your before render snippet can call model.UpdateData only if ActiveChart != currentChart, and in the updateData callback you can change ActiveChart === currentChart. It will still run the beforeRender snippet twice, but it should stop the loop there. 

Now, if only I could figure out how to make queue page include loads stop re-rendering every chart that’s ever been loaded