flowsurface_data/chart/ticks.rs
1pub mod x;
2pub mod y;
3
4/// Safety cap on the number of grid lines produced by any strategy.
5pub const MAX_GRID_LINES: usize = 1000;
6
7/// Vertical budget per Y-axis label, as a multiple of the text size.
8pub const Y_LABEL_DENSITY: f32 = 3.0;
9/// Denser budget for the shorter indicator panes (legacy value).
10pub const Y_LABEL_DENSITY_INDICATOR: f32 = 2.5;
11
12/// Number of Y-axis labels that fit in `height` pixels at `text_size` for a
13/// given `density` (one label per `density` text-size units of height).
14pub fn y_labels_that_fit(height: f32, text_size: f32, density: f32) -> usize {
15 (height / (text_size * density)) as usize
16}
17
18/// Horizontal pixel spacing reserved per time label at `text_size`. The
19/// single source for x-axis label density (kline + comparison time axes).
20pub fn x_label_spacing_px(text_size: f32) -> f32 {
21 text_size * 7.2
22}
23
24/// Number of time labels that fit in a `width`-wide axis at `text_size`,
25/// used as the step-selection budget.
26pub fn x_labels_that_fit(width: f32, text_size: f32) -> usize {
27 ((width / x_label_spacing_px(text_size)).floor() as usize).max(2)
28}