Skip to content

Commit 847197b

Browse files
committed
hash input for data gen to limit recalc
1 parent 094ff2d commit 847197b

File tree

1 file changed

+8
-11
lines changed

1 file changed

+8
-11
lines changed

NetworkDynamicsInspector/src/timeseries.jl

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -321,7 +321,13 @@ function timeseries_card(app, key, session)
321321

322322
# extract the data
323323
data = Observable{Vector{Vector{Float32}}}(Vector{Float32}[])
324+
datahash = Ref{UInt64}()
324325
onany(ts, valid_idxs, tsplot.rel, app.sol; update=true) do _ts, _valid_idxs, _rel, _sol
326+
# only replot if the data has actually changed
327+
newhash = hash((_ts, _valid_idxs, _rel, _sol))
328+
newhash == datahash[] && return
329+
datahash[] = newhash
330+
325331
@debug "TS: t, valid_idx, rel, sol => update data"
326332
_dat = _sol(_ts, idxs=_valid_idxs)
327333
if _rel
@@ -342,7 +348,7 @@ function timeseries_card(app, key, session)
342348
# store the idxs for which the autolmits where last set
343349
last_autolimits = Ref((eltype(valid_idxs)(), tsplot.rel[]))
344350
# plot the thing
345-
onany(data, replot) do _dat, _
351+
onany(data, replot; update=true) do _dat, _
346352
@async begin
347353
try
348354
empty!(ax)
@@ -404,16 +410,7 @@ function timeseries_card(app, key, session)
404410
id=key
405411
)
406412

407-
# trigger plot on document ready
408-
trigger_plot = js"""
409-
window.addEventListener('load', function() {
410-
console.log("Document ready, trigger plot");
411-
$(replot).notify();
412-
});
413-
"""
414-
Bonito.evaljs(session, trigger_plot)
415-
416-
return card
413+
return card, obsf
417414
end
418415
function closebutton(app, key)
419416
button = Bonito.Button("×", class="close-button")

0 commit comments

Comments
 (0)