@@ -52,38 +52,42 @@ function timeseries_cards(app, session)
52
52
known_tsplots = collect (keys (cache))
53
53
current_tsplots = collect (values (_tsplots))
54
54
55
- # do nothing if the TSPlots objects themselve did not change
56
- Set (known_tsplots) == Set (current_tsplots) && return
57
-
58
- # del_tsplots = setdiff(known_tsplots, current_tsplots)
59
- # new_tsplots = setdiff(current_tsplots, known_tsplots)
60
- # FIXME : it is not possible to redisplay the same tsplot, recreate all
61
- del_tsplots = known_tsplots
62
- new_tsplots = current_tsplots
63
-
64
- for del in del_tsplots
65
- (; card, observerfunctions, plotqueue) = cache[del]
66
- close (plotqueue) # close plotqueue
67
- Observables. off .(observerfunctions) # disable all observer functions
68
- delete! (cache, del) # delete from cache
69
- end
70
- for new in new_tsplots
71
- key = only ([key for (key, value) in _tsplots if value == new])
72
- ntup = timeseries_card (app, key, session)
73
- cache[new] = ntup
74
- end
55
+ # do nothing if the TSPlots objects themselve did not change unless on update!
56
+ if ! isdefined (container, 0 ) || Set (known_tsplots) != Set (current_tsplots)
57
+ # del_tsplots = setdiff(known_tsplots, current_tsplots)
58
+ # new_tsplots = setdiff(current_tsplots, known_tsplots)
59
+ # FIXME : it is not possible to redisplay the same tsplot, recreate all
60
+ del_tsplots = known_tsplots
61
+ new_tsplots = current_tsplots
62
+
63
+ for del in del_tsplots
64
+ (; card, observerfunctions, plotqueue) = cache[del]
65
+ close (plotqueue) # close plotqueue
66
+ Observables. off .(observerfunctions) # disable all observer functions
67
+ delete! (cache, del) # delete from cache
68
+ end
69
+ for new in new_tsplots
70
+ key = only ([key for (key, value) in _tsplots if value == new])
71
+ ntup = timeseries_card (app, key, session)
72
+ cache[new] = ntup
73
+ end
75
74
76
- cards = [cache[ts]. card for ts in values (_tsplots)]
77
- # update the display by notifying the content
78
- container[] = DOM. div (cards; class= " timeseries-stack" )
75
+ cards = [cache[ts]. card for ts in values (_tsplots)]
76
+ # update the display by notifying the content
77
+ container[] = DOM. div (cards; class= " timeseries-stack" )
78
+ end
79
79
80
80
nothing
81
81
end
82
82
83
83
# update the selected components in the graphplot when the active tsplot changes
84
84
on (app. active_tsplot; update= true ) do active
85
- activesel = app. tsplots[][active]. selcomp[]
86
- app. graphplot. _selcomp[] = activesel
85
+ if haskey (app. tsplots[], active)
86
+ activesel = app. tsplots[][active]. selcomp[]
87
+ app. graphplot. _selcomp[] = activesel
88
+ else
89
+ app. active_tsplot[] = first (keys (app. tsplots[]))
90
+ end
87
91
end
88
92
89
93
return container
0 commit comments