(
root: &DrawingArea<DB, plotters::coord::Shift>,
layout: &LayoutIR,
traces: &[TraceIR],
unsupported: &mut Vec<String>,
dash_entries: &mut Vec<DashEntry>,
)
| 104 | } |
| 105 | |
| 106 | pub(super) fn render_numeric<DB: DrawingBackend>( |
| 107 | root: &DrawingArea<DB, plotters::coord::Shift>, |
| 108 | layout: &LayoutIR, |
| 109 | traces: &[TraceIR], |
| 110 | unsupported: &mut Vec<String>, |
| 111 | dash_entries: &mut Vec<DashEntry>, |
| 112 | ) { |
| 113 | let config = extract_layout_config(layout, unsupported); |
| 114 | |
| 115 | let (mut x_min, mut x_max, mut y_min, mut y_max) = compute_numeric_ranges(traces); |
| 116 | |
| 117 | // For histograms, y axis is bin counts |
| 118 | let hist_max = histogram_max_count(traces); |
| 119 | if hist_max > 0.0 { |
| 120 | y_min = 0.0; |
| 121 | y_max = y_max.max(hist_max * 1.1); |
| 122 | } |
| 123 | // Ensure valid ranges |
| 124 | if !x_min.is_finite() || !x_max.is_finite() { |
| 125 | x_min = 0.0; |
| 126 | x_max = 1.0; |
| 127 | } |
| 128 | if !y_min.is_finite() || !y_max.is_finite() { |
| 129 | y_min = 0.0; |
| 130 | y_max = 1.0; |
| 131 | } |
| 132 | |
| 133 | // Apply user-specified axis ranges |
| 134 | if let Some((lo, hi)) = config.x_range { |
| 135 | x_min = lo; |
| 136 | x_max = hi; |
| 137 | } |
| 138 | if let Some((lo, hi)) = config.y_range { |
| 139 | y_min = lo; |
| 140 | y_max = hi; |
| 141 | } |
| 142 | |
| 143 | // Detect logarithmic axes and transform ranges to log10 space |
| 144 | let x_log = is_log_axis(&config.x_axis); |
| 145 | let y_log = is_log_axis(&config.y_axis); |
| 146 | |
| 147 | if x_log { |
| 148 | let (lo, hi) = log_range(x_min, x_max); |
| 149 | x_min = lo; |
| 150 | x_max = hi; |
| 151 | } |
| 152 | if y_log { |
| 153 | let (lo, hi) = log_range(y_min, y_max); |
| 154 | y_min = lo; |
| 155 | y_max = hi; |
| 156 | } |
| 157 | |
| 158 | // Detect category/date x-axis and collect string labels |
| 159 | let x_cat = is_category_axis(&config.x_axis); |
| 160 | let mut cat_labels = if x_cat { |
| 161 | collect_string_x_labels(traces) |
| 162 | } else { |
| 163 | Vec::new() |
no test coverage detected