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

Function collect_string_x_labels

crates/plotlars-plotters/src/render/axis.rs:201–216  ·  view source on GitHub ↗

Collect unique x-string labels from scatter/line traces for category/date axes.

(traces: &[TraceIR])

Source from the content-addressed store, hash-verified

199
200/// Collect unique x-string labels from scatter/line traces for category/date axes.
201pub(super) fn collect_string_x_labels(traces: &[TraceIR]) -> Vec<String> {
202 let mut labels = Vec::new();
203 for trace in traces {
204 let col = match trace {
205 TraceIR::ScatterPlot(ir) => Some(&ir.x),
206 TraceIR::LinePlot(ir) => Some(&ir.x),
207 _ => None,
208 };
209 if let Some(col) = col {
210 labels.extend(extract_strings(col));
211 }
212 }
213 let mut seen = std::collections::HashSet::new();
214 labels.retain(|s| seen.insert(s.clone()));
215 labels
216}
217
218/// Convert string x-values + f64 y-values into (index, y) pairs using a category map.
219pub(super) fn category_xy_pairs(

Callers 1

render_numericFunction · 0.85

Calls 1

extract_stringsFunction · 0.50

Tested by

no test coverage detected