MCPcopy Create free account
hub / github.com/alceal/plotlars / render_numeric

Function render_numeric

crates/plotlars-plotters/src/render/numeric.rs:106–1074  ·  view source on GitHub ↗
(
    root: &DrawingArea<DB, plotters::coord::Shift>,
    layout: &LayoutIR,
    traces: &[TraceIR],
    unsupported: &mut Vec<String>,
    dash_entries: &mut Vec<DashEntry>,
)

Source from the content-addressed store, hash-verified

104}
105
106pub(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()

Callers 1

render_to_backendFunction · 0.85

Calls 15

extract_layout_configFunction · 0.85
compute_numeric_rangesFunction · 0.85
histogram_max_countFunction · 0.85
is_log_axisFunction · 0.85
log_rangeFunction · 0.85
is_category_axisFunction · 0.85
collect_string_x_labelsFunction · 0.85
is_date_axisFunction · 0.85
extract_f64Function · 0.85

Tested by

no test coverage detected