euv-ui 0.51.0

Cross-platform UI component library and 17-scheme design system for the euv framework with pixel-consistent rendering across Web, Android, iOS, iPadOS, macOS, Windows, and Linux.
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
use super::*;

/// Computes a clean 1-2-5 nice step interval for axis tick generation.
///
/// # Arguments
///
/// - `f32` - Raw positive numeric span.
/// - `usize` - Target number of split intervals.
///
/// # Returns
///
/// - `f32` - Nice human-readable step magnitude.
#[must_use]
pub fn compute_nice_step(span: f32, split_number: usize) -> f32 {
    let safe_span: f32 = if span.is_finite() && span > 1e-6 {
        span
    } else {
        1.0
    };
    let splits: f32 = (split_number.max(1)) as f32;
    let rough: f32 = safe_span / splits;
    let exponent: f32 = rough.log10().floor();
    let mag: f32 = 10.0_f32.powf(exponent);
    let residual: f32 = rough / mag;
    let nice_mult: f32 = if residual <= 1.0 {
        1.0
    } else if residual <= 2.0 {
        2.0
    } else if residual <= 2.5 {
        2.5
    } else if residual <= 5.0 {
        5.0
    } else {
        10.0
    };
    nice_mult * mag
}

/// Formats a numeric scalar cleanly with compact `k`/`M`/`B` suffixes and optional unit suffix.
///
/// # Arguments
///
/// - `f32` - Numeric value to format.
/// - `&str` - Optional unit suffix (e.g. `"%"`, `"ms"`).
///
/// # Returns
///
/// - `String` - Formatted human-readable number string.
#[must_use]
pub fn format_chart_number(value: f32, unit_suffix: &str) -> String {
    if !value.is_finite() {
        return String::new();
    }
    let abs_v: f32 = value.abs();
    let base: String = if abs_v >= 1_000_000_000.0 {
        format!("{:.1}{}", value / 1_000_000_000.0, SCALE_SUFFIX_B)
    } else if abs_v >= 1_000_000.0 {
        format!("{:.1}{}", value / 1_000_000.0, SCALE_SUFFIX_M)
    } else if abs_v >= 10_000.0 {
        format!("{:.1}{}", value / 1_000.0, SCALE_SUFFIX_K)
    } else if (value - value.round()).abs() < 1e-3 {
        format!("{:.0}", value.round())
    } else if abs_v >= 100.0 {
        format!("{:.1}", value)
    } else {
        format!("{:.2}", value)
            .trim_end_matches('0')
            .trim_end_matches('.')
            .to_string()
    };
    if unit_suffix.is_empty() {
        base
    } else {
        format!("{}{}", base, unit_suffix)
    }
}

/// Formats a numeric timestamp on a `Time` axis into a concise `MM/DD` or `HH:MM` label.
///
/// # Arguments
///
/// - `f32` - Timestamp value (Unix seconds, day index, or hour index).
/// - `f32` - Full visible time span on the axis.
///
/// # Returns
///
/// - `String` - Formatted time tick label.
#[must_use]
pub fn format_chart_time(value: f32, span: f32) -> String {
    if !value.is_finite() {
        return String::new();
    }
    if value.abs() >= SCALE_UNIX_SECONDS_MIN {
        let total_days: i64 = (value as i64).div_euclid(86_400);
        let month_idx: usize = (total_days.div_euclid(30).rem_euclid(12)) as usize;
        let day_num: i64 = total_days.rem_euclid(30) + 1;
        if span <= 86_400.0 * 2.0 {
            let secs_in_day: i64 = (value as i64).rem_euclid(86_400);
            let hh: i64 = secs_in_day / 3600;
            let mm: i64 = (secs_in_day % 3600) / 60;
            return format!("{:02}:{:02}", hh, mm);
        }
        return format!("{} {:02}", SCALE_MONTH_NAMES[month_idx], day_num);
    }
    if span <= 48.0 {
        let total_mins: i64 = (value * 60.0).round() as i64;
        let hh: i64 = total_mins.div_euclid(60).rem_euclid(24);
        let mm: i64 = total_mins.rem_euclid(60);
        format!("{:02}:{:02}", hh, mm)
    } else {
        let day_idx: i64 = value.round() as i64;
        let month_idx: usize = (day_idx.div_euclid(30).rem_euclid(12)) as usize;
        let day_num: i64 = day_idx.rem_euclid(30) + 1;
        format!("{} {:02}", SCALE_MONTH_NAMES[month_idx], day_num)
    }
}

/// Computes an `EuvChartAxisScale` supporting `Category`, `Value`, `Time`, and `Log` domains with nice 1-2-5 ticks.
///
/// # Arguments
///
/// - `&EuvChartAxis` - Declarative axis configuration.
/// - `f32` - Observed data minimum across bound visible series.
/// - `f32` - Observed data maximum across bound visible series.
/// - `bool` - When `true`, anchors zero inside numeric bar/area ranges unless overridden.
/// - `Option<EuvChartZoomSlice>` - Optional active `DataZoom` window applied to category or domain bounds.
///
/// # Returns
///
/// - `EuvChartAxisScale` - Fully resolved axis scale with formatted tick labels.
#[must_use]
pub fn build_axis_scale(
    axis: &EuvChartAxis,
    data_min: f32,
    data_max: f32,
    anchor_zero: bool,
    zoom: Option<EuvChartZoomSlice>,
) -> EuvChartAxisScale {
    let split_count: usize = axis.get_split_number().clamp(2, 12);
    match axis.get_axis_type() {
        EuvChartAxisType::Category => {
            let all_cats: &[String] = axis.get_categories().as_slice();
            let len: usize = all_cats.len();
            let (start_i, end_i, win_start, win_span): (usize, usize, f32, f32) = if let Some(pos_z) =
                zoom
                && len > 0
            {
                let len_f: f32 = len as f32;
                let sf: f32 = pos_z.get_start_f().clamp(0.0, (len_f - 1.0).max(0.0));
                let ef: f32 = pos_z.get_end_f().clamp((sf + 1.0).min(len_f), len_f);
                let source_val: usize = pos_z.get_start_index().min(len);
                let event_ref: usize = pos_z.get_end_index().clamp(source_val, len);
                if source_val < event_ref {
                    (source_val, event_ref, sf, (ef - sf).max(1.0))
                } else {
                    (0, len, 0.0, len_f)
                }
            } else {
                (0, len, 0.0, len as f32)
            };
            let visible_cats: Vec<String> = all_cats[start_i..end_i].to_vec();
            let count: usize = visible_cats.len();
            let mut ticks: Vec<f32> = Vec::with_capacity(count);
            for item_index in start_i..end_i {
                ticks.push(item_index as f32);
            }
            let max_idx: f32 = if end_i > 0 { (end_i - 1) as f32 } else { 1.0 };
            EuvChartAxisScale {
                axis_type: EuvChartAxisType::Category,
                min: start_i as f32,
                max: max_idx,
                inverse: axis.get_inverse(),
                ticks,
                labels: visible_cats.clone(),
                categories: visible_cats,
                window_start: win_start,
                window_span: win_span,
                category_base_index: start_i,
            }
        }
        EuvChartAxisType::Log => {
            let safe_lo: f32 = axis
                .min_opt()
                .unwrap_or(data_min)
                .max(SCALE_LOG_MIN_POSITIVE);
            let safe_hi: f32 = axis.max_opt().unwrap_or(data_max).max(safe_lo * 10.0);
            let min_exp: i32 = safe_lo.log10().floor() as i32;
            let max_exp: i32 = (safe_hi.log10().ceil() as i32).max(min_exp + 1);
            let mut ticks: Vec<f32> = Vec::new();
            let mut labels: Vec<String> = Vec::new();
            let mut exp: i32 = min_exp;
            while exp <= max_exp && ticks.len() < 16 {
                let item_val: f32 = 10.0_f32.powi(exp);
                ticks.push(item_val);
                labels.push(format_chart_number(
                    item_val,
                    axis.get_unit_suffix().as_str(),
                ));
                exp += 1;
            }
            EuvChartAxisScale {
                axis_type: EuvChartAxisType::Log,
                min: 10.0_f32.powi(min_exp),
                max: 10.0_f32.powi(max_exp),
                inverse: axis.get_inverse(),
                ticks,
                labels,
                categories: Vec::new(),
                window_start: 0.0,
                window_span: 0.0,
                category_base_index: 0,
            }
        }
        EuvChartAxisType::Value | EuvChartAxisType::Time => {
            let mut lo: f32 = if data_min.is_finite() { data_min } else { 0.0 };
            let mut hi: f32 = if data_max.is_finite() {
                data_max
            } else {
                100.0
            };
            if anchor_zero && axis.min_opt().is_none() && lo > 0.0 {
                lo = 0.0;
            }
            if anchor_zero && axis.max_opt().is_none() && hi < 0.0 {
                hi = 0.0;
            }
            if let Some(exp_min) = axis.min_opt() {
                lo = exp_min;
            }
            if let Some(exp_max) = axis.max_opt() {
                hi = exp_max;
            }
            if (hi - lo).abs() < 1e-5 {
                let pad: f32 = if hi.abs() > 1.0 { hi.abs() * 0.2 } else { 1.0 };
                lo -= pad;
                hi += pad;
            }
            if let Some(coord_z) = zoom {
                let span_full: f32 = hi - lo;
                let z_lo: f32 = lo + span_full * (coord_z.get_start_pct() * 0.01);
                let z_hi: f32 = lo + span_full * (coord_z.get_end_pct() * 0.01);
                if z_hi - z_lo > 1e-5 {
                    lo = z_lo;
                    hi = z_hi;
                }
            }
            let step: f32 = compute_nice_step(hi - lo, split_count);
            let nice_min: f32 = if axis.min_opt().is_some() {
                lo
            } else {
                (lo / step).floor() * step
            };
            let nice_max: f32 = if axis.max_opt().is_some() {
                hi
            } else {
                (hi / step).ceil() * step
            };
            let span: f32 = (nice_max - nice_min).max(step);
            let mut ticks: Vec<f32> = Vec::new();
            let mut labels: Vec<String> = Vec::new();
            let is_time: bool = axis.get_axis_type() == EuvChartAxisType::Time;
            let count_steps: usize = ((span / step).round() as usize).clamp(1, 14);
            for outer_index in 0..=count_steps {
                let tv: f32 = nice_min + (outer_index as f32) * (span / (count_steps as f32));
                ticks.push(tv);
                let text_value: String = if is_time {
                    format_chart_time(tv, span)
                } else {
                    format_chart_number(tv, axis.get_unit_suffix().as_str())
                };
                labels.push(text_value);
            }
            EuvChartAxisScale {
                axis_type: axis.get_axis_type(),
                min: nice_min,
                max: nice_max,
                inverse: axis.get_inverse(),
                ticks,
                labels,
                categories: Vec::new(),
                window_start: 0.0,
                window_span: 0.0,
                category_base_index: 0,
            }
        }
    }
}

/// Computes a continuously-padded numeric `Value` Y-axis scale with nice interior 1-2-5 ticks so panning zoomed charts never snaps vertically.
///
/// # Arguments
///
/// - `&EuvChartAxis` - Declarative numeric axis configuration.
/// - `f32` - Smoothly interpolated visible data minimum.
/// - `f32` - Smoothly interpolated visible data maximum.
/// - `bool` - When `true`, anchors zero inside numeric bar/area ranges unless overridden.
///
/// # Returns
///
/// - `EuvChartAxisScale` - Smoothly bounded numeric axis scale with clean interior ticks.
#[must_use]
pub(crate) fn build_smooth_value_axis_scale(
    axis: &EuvChartAxis,
    data_min: f32,
    data_max: f32,
    anchor_zero: bool,
) -> EuvChartAxisScale {
    if axis.get_axis_type() != EuvChartAxisType::Value {
        return build_axis_scale(axis, data_min, data_max, anchor_zero, None);
    }
    let split_count: usize = axis.get_split_number().clamp(2, 12);
    let mut lo: f32 = if data_min.is_finite() { data_min } else { 0.0 };
    let mut hi: f32 = if data_max.is_finite() {
        data_max
    } else {
        100.0
    };
    if anchor_zero && axis.min_opt().is_none() && lo > 0.0 {
        lo = 0.0;
    }
    if anchor_zero && axis.max_opt().is_none() && hi < 0.0 {
        hi = 0.0;
    }
    if let Some(exp_min) = axis.min_opt() {
        lo = exp_min;
    }
    if let Some(exp_max) = axis.max_opt() {
        hi = exp_max;
    }
    if (hi - lo).abs() < 1e-5 {
        let pad: f32 = if hi.abs() > 1.0 { hi.abs() * 0.2 } else { 1.0 };
        lo -= pad;
        hi += pad;
    }
    let raw_span: f32 = (hi - lo).max(1e-5);
    let pad: f32 = raw_span * 0.06;
    let smooth_min: f32 = if axis.min_opt().is_some() || (anchor_zero && lo == 0.0) {
        lo
    } else {
        lo - pad
    };
    let smooth_max: f32 = if axis.max_opt().is_some() || (anchor_zero && hi == 0.0) {
        hi
    } else {
        hi + pad
    };
    let span: f32 = (smooth_max - smooth_min).max(1e-5);
    let step: f32 = compute_nice_step(span, split_count);
    let first_k: i64 = (smooth_min / step).ceil() as i64;
    let last_k: i64 = (smooth_max / step).floor() as i64;
    let mut ticks: Vec<f32> = Vec::new();
    let mut labels: Vec<String> = Vec::new();
    let mut entry_index: i64 = first_k;
    while entry_index <= last_k && ticks.len() < 16 {
        let tv: f32 = (entry_index as f32) * step;
        if tv >= smooth_min - step * 1e-4 && tv <= smooth_max + step * 1e-4 {
            ticks.push(tv);
            labels.push(format_chart_number(tv, axis.get_unit_suffix().as_str()));
        }
        entry_index += 1;
    }
    if ticks.len() < 2 {
        ticks.clear();
        labels.clear();
        let fallback_steps: usize = split_count.clamp(2, 6);
        for item_index in 0..=fallback_steps {
            let tv: f32 = smooth_min + (item_index as f32) * (span / (fallback_steps as f32));
            ticks.push(tv);
            labels.push(format_chart_number(tv, axis.get_unit_suffix().as_str()));
        }
    }
    EuvChartAxisScale {
        axis_type: EuvChartAxisType::Value,
        min: smooth_min,
        max: smooth_max,
        inverse: axis.get_inverse(),
        ticks,
        labels,
        categories: Vec::new(),
        window_start: 0.0,
        window_span: 0.0,
        category_base_index: 0,
    }
}

/// Computes an index slice window for `total_len` category items from percentage bounds `[start_pct, end_pct]`.
///
/// # Arguments
///
/// - `usize` - Total item count before zooming.
/// - `f32` - Start percentage in `[0.0, 100.0]`.
/// - `f32` - End percentage in `[0.0, 100.0]`.
///
/// # Returns
///
/// - `EuvChartZoomSlice` - Clamped continuous and discrete slice window.
#[must_use]
pub fn compute_zoom_slice(total_len: usize, start_pct: f32, end_pct: f32) -> EuvChartZoomSlice {
    let lo_pct: f32 = start_pct.clamp(0.0, 99.0);
    let hi_pct: f32 = end_pct.clamp(lo_pct + 1.0, 100.0);
    if total_len == 0 {
        return EuvChartZoomSlice {
            start_pct: lo_pct,
            end_pct: hi_pct,
            start_index: 0,
            end_index: 0,
            start_f: 0.0,
            end_f: 0.0,
        };
    }
    let total_f: f32 = total_len as f32;
    let raw_start_f: f32 = (total_f * lo_pct * 0.01).clamp(0.0, (total_f - 1.0).max(0.0));
    let raw_end_f: f32 =
        (total_f * hi_pct * 0.01).clamp(raw_start_f + 1.0_f32.min(total_f), total_f);
    let start_idx: usize = (raw_start_f.floor() as usize).min(total_len.saturating_sub(1));
    let raw_end: usize = (raw_end_f.ceil() as usize).min(total_len);
    let end_idx: usize = raw_end.max((start_idx + 1).min(total_len));
    EuvChartZoomSlice {
        start_pct: lo_pct,
        end_pct: hi_pct,
        start_index: start_idx,
        end_index: end_idx,
        start_f: raw_start_f,
        end_f: raw_end_f,
    }
}

/// Builds a ready-to-evaluate `EuvChartVisualEvaluator` from `visual_map` and active `tokens`.
///
/// # Arguments
///
/// - `Option<&EuvChartVisualMap>` - Optional declarative visual-map configuration.
/// - `f32` - Observed data minimum fallback when visual-map bounds collapse.
/// - `f32` - Observed data maximum fallback when visual-map bounds collapse.
/// - `ThemeTokens` - Active UI theme tokens supplying Light/Dark default ramps.
///
/// # Returns
///
/// - `EuvChartVisualEvaluator` - Ready color evaluator.
#[must_use]
pub fn build_visual_evaluator(
    visual_map: Option<&EuvChartVisualMap>,
    data_min: f32,
    data_max: f32,
    tokens: ThemeTokens,
) -> EuvChartVisualEvaluator {
    let default_ramp: &[u32; 4] = match tokens.get_mode() {
        ThemeMode::Light => &ECHART_VISUAL_RAMP_LIGHT,
        ThemeMode::Dark => &ECHART_VISUAL_RAMP_DARK,
    };
    let default_stops: Vec<Color> = default_ramp
        .iter()
        .map(|&height_val: &u32| Color::hex(height_val))
        .collect();
    if let Some(vm) = visual_map {
        let stops: Vec<Color> = if vm.get_in_range_colors().is_empty() {
            default_stops
        } else {
            vm.get_in_range_colors().clone()
        };
        let lo: f32 = vm.get_min();
        let hi: f32 = if (vm.get_max() - lo).abs() > 1e-6 {
            vm.get_max()
        } else {
            data_max.max(lo + 1.0)
        };
        EuvChartVisualEvaluator {
            kind: vm.get_kind(),
            min: lo,
            max: hi,
            stops,
            pieces: vm.get_pieces().clone(),
        }
    } else {
        let lo: f32 = if data_min.is_finite() { data_min } else { 0.0 };
        let hi: f32 = if data_max.is_finite() && data_max > lo {
            data_max
        } else {
            lo + 100.0
        };
        EuvChartVisualEvaluator {
            kind: EuvChartVisualMapKind::Continuous,
            min: lo,
            max: hi,
            stops: default_stops,
            pieces: Vec::new(),
        }
    }
}

/// Extracts category labels from an `EuvChartDataset` column matching `dim`.
///
/// # Arguments
///
/// - `&EuvChartDataset` - Shared tabular dataset.
/// - `&str` - Dimension name or column index string.
///
/// # Returns
///
/// - `Vec<String>` - Extracted category strings per row.
#[must_use]
pub fn dataset_extract_labels(dataset: &EuvChartDataset, dim: &str) -> Vec<String> {
    let Some(col) = dataset.column_index(dim) else {
        return Vec::new();
    };
    let mut out: Vec<String> = Vec::with_capacity(dataset.get_rows().len());
    for row in dataset.get_rows().iter() {
        let cell_str: String = match row.get(col) {
            Some(EuvChartCell::Text(source_val)) => source_val.clone(),
            Some(EuvChartCell::Number(item_val)) => format_chart_number(*item_val, ""),
            Some(EuvChartCell::Null) | None => String::new(),
        };
        out.push(cell_str);
    }
    out
}

/// Extracts nullable numeric values from an `EuvChartDataset` column matching `dim`.
///
/// # Arguments
///
/// - `&EuvChartDataset` - Shared tabular dataset.
/// - `&str` - Dimension name or column index string.
///
/// # Returns
///
/// - `Vec<Option<f32>>` - Extracted scalar values per row.
#[must_use]
pub fn dataset_extract_numbers(dataset: &EuvChartDataset, dim: &str) -> Vec<Option<f32>> {
    let Some(col) = dataset.column_index(dim) else {
        return Vec::new();
    };
    let mut out: Vec<Option<f32>> = Vec::with_capacity(dataset.get_rows().len());
    for row in dataset.get_rows().iter() {
        let val: Option<f32> = match row.get(col) {
            Some(EuvChartCell::Number(item_val)) if item_val.is_finite() => Some(*item_val),
            _ => None,
        };
        out.push(val);
    }
    out
}

/// Extracts scatter `(x, y, size, value, label)` points from an `EuvChartDataset` using `encode`.
///
/// # Arguments
///
/// - `&EuvChartDataset` - Shared tabular dataset.
/// - `&EuvChartEncode` - Column encoding mapping.
/// - `f32` - Fallback default symbol radius.
///
/// # Returns
///
/// - `Vec<EuvChartScatterPoint>` - Extracted scatter points.
#[must_use]
pub fn dataset_extract_scatter(
    dataset: &EuvChartDataset,
    encode: &EuvChartEncode,
    default_size: f32,
) -> Vec<EuvChartScatterPoint> {
    let x_vals: Vec<Option<f32>> = encode
        .x_dimension_opt()
        .map(|text_value: &str| dataset_extract_numbers(dataset, text_value))
        .unwrap_or_default();
    let y_vals: Vec<Option<f32>> = encode
        .y_dimension_opt()
        .or_else(|| encode.value_opt())
        .map(|label_str: &str| dataset_extract_numbers(dataset, label_str))
        .unwrap_or_default();
    let sz_vals: Vec<Option<f32>> = encode
        .size_opt()
        .map(|content_text: &str| dataset_extract_numbers(dataset, content_text))
        .unwrap_or_default();
    let val_vals: Vec<Option<f32>> = encode
        .value_opt()
        .map(|delta_val: &str| dataset_extract_numbers(dataset, delta_val))
        .unwrap_or_default();
    let lbls: Vec<String> = encode
        .item_name_opt()
        .map(|distance_val: &str| dataset_extract_labels(dataset, distance_val))
        .unwrap_or_default();
    let row_count: usize = dataset.get_rows().len();
    let mut out: Vec<EuvChartScatterPoint> = Vec::with_capacity(row_count);
    for item_index in 0..row_count {
        let xv: f32 = x_vals
            .get(item_index)
            .and_then(|item_val: &Option<f32>| *item_val)
            .unwrap_or(item_index as f32);
        let Some(yv) = y_vals
            .get(item_index)
            .and_then(|tex_v: &Option<f32>| *tex_v)
        else {
            continue;
        };
        let sz: f32 = sz_vals
            .get(item_index)
            .and_then(|bary_v: &Option<f32>| *bary_v)
            .unwrap_or(default_size);
        let mut point_coords: EuvChartScatterPoint = EuvChartScatterPoint::new(xv, yv).size(sz);
        if let Some(mv) = val_vals
            .get(item_index)
            .and_then(|sample_val: &Option<f32>| *sample_val)
        {
            point_coords = point_coords.value(mv);
        }
        if let Some(label_text) = lbls.get(item_index) {
            point_coords = point_coords.label(label_text.clone());
        }
        out.push(point_coords);
    }
    out
}