@@ -44,6 +44,38 @@ function widget(range::AbstractRange{<:Number})
4444 return range_slider
4545end
4646
47+ widget_value (w:: Vector{<:String} ; resolution = 1 ) = w
48+ widget_value (x:: Vector ; resolution = 1 ) =
49+ x[1 ] ≈ x[end ] ? Float64[] : range (Float64 (x[1 ]), Float64 (x[end ]), length = 5 )
50+
51+
4752function formular_text (content; class = " " )
4853 return DOM. div (content; class = " px-1 text-lg m-1 font-semibold $(class) " )
4954end
55+
56+ function variable_legend (name, values:: AbstractRange{<:Number} , palette:: Dict )
57+ range, cmap = palette[:colormap ]
58+ return S. Colorbar (limits = range, colormap = cmap, label = string (name))
59+ end
60+
61+ function variable_legend (name, values:: Set , palette:: Dict )
62+ marker_color_lookup = (x) -> begin
63+ if haskey (palette, :color )
64+ return get (palette[:color ], x, :black )
65+ else
66+ return :black
67+ end
68+ end
69+ marker_lookup = (x) -> begin
70+ if haskey (palette, :marker )
71+ return palette[:marker ][x]
72+ else
73+ return :rect
74+ end
75+ end
76+ conditions = collect (values)
77+ elements = map (conditions) do c
78+ return MarkerElement (marker = marker_lookup (c), color = marker_color_lookup (c))
79+ end
80+ return S. Legend (elements, conditions)
81+ end
0 commit comments