[OCaml] High Intensity Training Online
feat make the progress chart a golden rectangle
Set the viewBox to 640x396 (~1.618:1) and widen the top padding so the axis titles clear the edge. A taller plot also keeps sparse two-point series from reading as empty.
lib/presenter/svg_chart.ml
@@ -17,14 +17,15 @@
17
17
let fattr = float_attr
18
18
19
19
(* Fixed drawing surface. The viewBox scales to the container width via CSS. A
20
Removed:
wider-than-tall aspect keeps sparse two-point series from looking empty. The
21
Removed:
side gutters are fixed, so every chart's plot area starts at the same x and
22
Removed:
the stacked charts share one clean left edge. *)
20
Added:
golden rectangle: the 640×396 surface is a 1.618:1 width:height ratio, which
21
Added:
also keeps sparse two-point series from looking empty. The side gutters are
22
Added:
fixed, so every chart's plot area starts at the same x and the stacked charts
23
Added:
share one clean left edge. *)
23
24
let width = 640.
24
Removed:
let height = 260.
25
Added:
let height = 396.
25
26
let pad_left = 52.
26
27
let pad_right = 52.
27
Removed:
let pad_top = 22.
28
Added:
let pad_top = 30.
28
29
let pad_bottom = 34.
29
30
let plot_w = width -. pad_left -. pad_right
30
31
let plot_h = height -. pad_top -. pad_bottom
@@ -154,10 +155,10 @@
154
155
~y2:(pad_top +. plot_h);
155
156
axis_line ~x1:pad_left ~y1:(pad_top +. plot_h) ~x2:(pad_left +. plot_w)
156
157
~y2:(pad_top +. plot_h);
157
Removed:
(* Axis titles, anchored just above their axis. *)
158
Removed:
axis_label ~x:pad_left ~y:(pad_top -. 8.) ~anchor:"middle"
158
Added:
(* Axis titles, anchored just above their axis, clear of the top edge. *)
159
Added:
axis_label ~x:pad_left ~y:(pad_top -. 10.) ~anchor:"middle"
159
160
~css_class:"chart-axis-title weight" "kg";
160
Removed:
axis_label ~x:(pad_left +. plot_w) ~y:(pad_top -. 8.) ~anchor:"middle"
161
Added:
axis_label ~x:(pad_left +. plot_w) ~y:(pad_top -. 10.) ~anchor:"middle"
161
162
~css_class:"chart-axis-title reps" "reps";
162
163
(* Left axis bounds (weight, kg). *)
163
164
axis_label ~x:(pad_left -. 6.) ~y:(pad_top +. 4.) ~anchor:"end"