@@ -70,18 +70,29 @@ The result is a `Plot` containing all layers from both operands. -/
70
70
instance (priority := 2000 ) [ToPlot α] [ToPlot β] : HAdd α β Plot where
71
71
hAdd a b := Plot.overlay (toPlot a) (toPlot b)
72
72
73
+ /-- Generic `*` overlay via `[ToPlot]`. -/
74
+ instance (priority := 2000 ) [ToPlot α] [ToPlot β] : HMul α β Plot where
75
+ hMul a b := Plot.overlay (toPlot a) (toPlot b)
76
+
77
+ /-- Generic `/` overlay via `[ToPlot]`. Provided for API symmetry. -/
78
+ instance (priority := 2000 ) [ToPlot α] [ToPlot β] : HDiv α β Plot where
79
+ hDiv a b := Plot.overlay (toPlot a) (toPlot b)
80
+
73
81
/-! ### Render instance ---------------------------------------------------- -/
74
82
75
83
instance : Render Layer where
76
84
render := Layer.html
77
85
78
- /-- Render a plot by vertically stacking each layer inside a `<div>` container.
86
+ /-- Render a plot by overlaying all layers in a single relative container.
79
87
For line/scatter overlays we ideally want a *single* combined Recharts chart;
80
- that is a future optimisation. The vertical stack is "correct" though perhaps
81
- not visually perfect. -/
88
+ that is a future optimisation. -/
82
89
instance : Render Plot where
83
90
render p :=
84
- -- simple flex column
85
- <div style={Json.mkObj [("display" , "flex" ), ("flex-direction" , "column" )]}>
86
- {... p.layers.map (fun l => l.html)}
87
- </div>
91
+ let rows := (List.range p.layers.size).toArray.map (fun idx =>
92
+ let l := p.layers[idx]!
93
+ Html.element "div"
94
+ #[("key" , Json.str (toString idx))]
95
+ #[l.html])
96
+ Html.element "div"
97
+ #[("style" , Json.str "display:flex; flex-direction:column;" )]
98
+ rows
0 commit comments