@@ -22,6 +22,12 @@ include("utils.jl")
22
22
function apptheme ()
23
23
Theme (
24
24
fontsize= 10 ,
25
+ palette = (;
26
+ linestyle = [:solid , :dot , :dash , :dashdot , :dashdotdot ],
27
+ ),
28
+ Lines = (;
29
+ cycle = Cycle ([:color , :linestyle ], covary= true )
30
+ )
25
31
)
26
32
end
27
33
@@ -60,7 +66,7 @@ function graphplot_card(app; kwargs...)
60
66
end ;
61
67
62
68
edge_state = Observable (Vector {Float32} (undef, NE))
63
- onany (app. sol, app. t, app. graphplot. estate, app. graphplot. nstate_rel ) do _sol, _t, _state, _rel
69
+ onany (app. sol, app. t, app. graphplot. estate, app. graphplot. estate_rel ) do _sol, _t, _state, _rel
64
70
@debug " GP: app.sol, app.t, app.gp.estate, app.gp.estate_rel => edge_state"
65
71
if length (_state) == 0
66
72
fill! (edge_state[], NaN )
@@ -229,10 +235,12 @@ function gpstate_control_card(app, type)
229
235
nothing
230
236
end
231
237
multisel = MultiSelect (options, stateobs; placeholder= " Select state for coloring" , multi= false , T= Symbol)
238
+ reltoggle = ToggleSwitch (value= stateobs_rel, label= " Rel to u0" )
232
239
selector = Grid (
233
240
DOM. span (label),
234
- multisel;
235
- columns = " 70px 1fr" ,
241
+ multisel,
242
+ reltoggle;
243
+ columns = " 70px 1fr auto" ,
236
244
align_items = " center"
237
245
)
238
246
@@ -345,12 +353,17 @@ function timeseries_card(app, session)
345
353
multi= true ,
346
354
option_to_string= _sidx_to_str,
347
355
T= SymbolicIndex)
348
- comp_sel_dom = Grid (DOM. span (" States " ), comp_sel; columns = " 70px 1fr" , align_items = " center" )
356
+ # comp_sel_dom = Grid(DOM.span("Components "), comp_sel; columns = "70px 1fr", align_items = "center")
349
357
state_sel = MultiSelect (state_options, app. tsplot. states;
350
358
placeholder= " Select states" ,
351
359
multi= true ,
352
360
T= Symbol)
353
- state_sel_dom = Grid (DOM. span (" Components" ), state_sel; columns = " 70px 1fr" , align_items = " center" )
361
+
362
+ comp_state_sel_dom = Grid (
363
+ DOM. span (" Components" ), comp_sel,
364
+ DOM. span (" States" ), state_sel;
365
+ columns = " auto 1fr" , align_items = " center"
366
+ )
354
367
355
368
# hl choice of elements in graphplot
356
369
on (app. tsplot. selcomp; update= true ) do _sel
@@ -366,7 +379,7 @@ function timeseries_card(app, session)
366
379
# ###
367
380
color_cache = Dict {Union{EIndex{Int,Nothing},VIndex{Int,Nothing}}, Int} ()
368
381
linestyle_cache = Dict {Symbol,Int} ()
369
- on (app. tsplot. selcomp) do _sel
382
+ on (app. tsplot. selcomp; update = true ) do _sel
370
383
@debug " TS: comp selection => update color_cache"
371
384
for unused in setdiff (keys (color_cache), _sel)
372
385
delete! (color_cache, unused)
@@ -377,7 +390,7 @@ function timeseries_card(app, session)
377
390
end
378
391
nothing
379
392
end
380
- on (app. tsplot. states) do _states
393
+ on (app. tsplot. states; update = true ) do _states
381
394
@debug " TS: state selection => update linestyle_cache"
382
395
for unused in setdiff (keys (linestyle_cache), _states)
383
396
delete! (linestyle_cache, unused)
@@ -388,20 +401,13 @@ function timeseries_card(app, session)
388
401
end
389
402
nothing
390
403
end
391
- getcolor = (s) -> begin
392
- key = s isa VIndex ? VIndex (s. compidx) : EIndex (s. compidx)
393
- Cycled (color_cache[key])
394
- Cycled (ckey)
395
- end
396
- getlinestyle = (s) -> Cycled (linestyle_cache[s. subidx])
397
404
398
405
399
406
fig, ax = with_theme (apptheme ()) do
400
407
fig = Figure ()
401
408
ax = Axis (fig[1 , 1 ])
402
409
fig, ax
403
410
end
404
- Main. axref[] = ax
405
411
406
412
# set axis limits according to time range
407
413
onany (app. tmin, app. tmax, update= true ) do _tmin, _tmax
@@ -462,25 +468,27 @@ function timeseries_card(app, session)
462
468
for i in 1 : length (_valid_idxs)
463
469
data. val[i] = _dat[i,:]
464
470
end
465
- @info " Data updated" data[]
466
471
notify (data)
467
472
end
468
473
469
474
# plot the thing
470
475
on (data; update= true ) do _dat
471
- @debug " TS: Data => Plotting"
472
- println (" befor empty" )
473
- empty! (ax)
474
- println (" after empty" )
475
- # vlines!(ax, app.t; color=:black)
476
- # for (idx, y) in zip(valid_idxs[], data[])
477
- for i in 1 : length (valid_idxs[])
478
- # @info "plot $idx" y
479
- # lines!(ax, ts[], y; label=string(idx), color=getcolor(idx), linestyle=getlinestyle(idx))
480
- # lines!(ax, ts[], y; label=string(idx))
481
- lines! (ax, rand (3 ))
476
+ @async begin
477
+ try
478
+ empty! (ax)
479
+ vlines! (ax, app. t; color= :black )
480
+ for (idx, y) in zip (valid_idxs[], data[])
481
+ color = begin
482
+ key = idx isa VIndex ? VIndex (idx. compidx) : EIndex (idx. compidx)
483
+ Cycled (color_cache[key])
484
+ end
485
+ linestyle = Cycled (linestyle_cache[idx. subidx])
486
+ lines! (ax, ts[], y; label= string (idx), color, linestyle)
487
+ end
488
+ catch e
489
+ @error " Plotting failed" e
490
+ end
482
491
end
483
- @debug " End of plotting"
484
492
nothing
485
493
end
486
494
@@ -500,8 +508,7 @@ function timeseries_card(app, session)
500
508
501
509
Card (
502
510
Grid (
503
- comp_sel_dom,
504
- state_sel_dom,
511
+ comp_state_sel_dom,
505
512
fig
506
513
)
507
514
)
0 commit comments