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
10/// Number of Y-axis labels that fit in `height` pixels at `text_size` for a
11/// given `density` (one label per `density` text-size units of height).
12pub fn y_labels_that_fit(height: f32, text_size: f32, density: f32) -> usize {
13 (height / (text_size * density)) as usize
14}
15
16/// Horizontal pixel spacing reserved per time label at `text_size`. The
17/// single source for x-axis label density (kline + comparison time axes).
18pub fn x_label_spacing_px(text_size: f32) -> f32 {
19 text_size * 7.2
20}
21
22/// Number of time labels that fit in a `width`-wide axis at `text_size`,
23/// used as the step-selection budget.
24pub fn x_labels_that_fit(width: f32, text_size: f32) -> usize {
25 ((width / x_label_spacing_px(text_size)).floor() as usize).max(2)
26}