Skip to main content

euv_ui/component/chart/model/
impl.rs

1use super::*;
2
3/// Default legend configuration positioned at the top edge.
4impl Default for EuvChartLegend {
5    /// Creates a visible top-docked legend.
6    ///
7    /// # Returns
8    ///
9    /// - `Self` - Default legend configuration.
10    fn default() -> Self {
11        Self {
12            show: true,
13            position: EuvChartPosition::Top,
14            items: Vec::new(),
15        }
16    }
17}
18
19/// Default Cartesian grid margins and label containment.
20impl Default for EuvChartGrid {
21    /// Creates a standard padded Cartesian grid.
22    ///
23    /// # Returns
24    ///
25    /// - `Self` - Default grid margins.
26    fn default() -> Self {
27        Self {
28            left: ECHART_GRID_DEFAULT_LEFT,
29            right: ECHART_GRID_DEFAULT_RIGHT,
30            top: ECHART_GRID_DEFAULT_TOP,
31            bottom: ECHART_GRID_DEFAULT_BOTTOM,
32            contain_label: true,
33            show_border: false,
34        }
35    }
36}
37
38/// Default continuous numeric value axis configuration.
39impl Default for EuvChartAxis {
40    /// Creates a default `Value` axis with ticks, labels, and subtle grid split lines.
41    ///
42    /// # Returns
43    ///
44    /// - `Self` - Default axis configuration.
45    fn default() -> Self {
46        Self {
47            axis_type: EuvChartAxisType::Value,
48            name: String::new(),
49            unit_suffix: String::new(),
50            categories: Vec::new(),
51            grid_index: 0,
52            min: None,
53            max: None,
54            inverse: false,
55            split_number: ECHART_DEFAULT_SPLIT_NUMBER,
56            show_axis_line: true,
57            show_axis_tick: true,
58            show_axis_label: true,
59            show_split_line: true,
60            show_split_area: false,
61            position: None,
62        }
63    }
64}
65
66/// Default polar coordinate system.
67impl Default for EuvChartPolar {
68    /// Creates a centered polar coordinate system with category angle axis and value radius axis.
69    ///
70    /// # Returns
71    ///
72    /// - `Self` - Default polar configuration.
73    fn default() -> Self {
74        Self {
75            angle_axis: EuvChartAxis::category(Vec::new()),
76            radius_axis: EuvChartAxis::value(),
77            radius_ratio: 0.72,
78            center_x_ratio: 0.5,
79            center_y_ratio: 0.5,
80        }
81    }
82}
83
84/// Default radar coordinate system.
85impl Default for EuvChartRadar {
86    /// Creates a polygon radar web with four concentric rings.
87    ///
88    /// # Returns
89    ///
90    /// - `Self` - Default radar configuration.
91    fn default() -> Self {
92        Self {
93            indicators: Vec::new(),
94            shape: EuvChartRadarShape::Polygon,
95            split_number: 4,
96            radius_ratio: 0.72,
97        }
98    }
99}
100
101/// Default single-axis coordinate system.
102impl Default for EuvChartSingleAxis {
103    /// Creates a centered horizontal single-axis track.
104    ///
105    /// # Returns
106    ///
107    /// - `Self` - Default single-axis configuration.
108    fn default() -> Self {
109        Self {
110            axis: EuvChartAxis::category(Vec::new()),
111            center_y_ratio: 0.54,
112        }
113    }
114}
115
116/// Default calendar coordinate system.
117impl Default for EuvChartCalendar {
118    /// Creates a horizontal 26-week calendar matrix.
119    ///
120    /// # Returns
121    ///
122    /// - `Self` - Default calendar configuration.
123    fn default() -> Self {
124        Self {
125            year: 2026,
126            weeks: ECHART_CALENDAR_DEFAULT_WEEKS,
127            month_labels: Vec::new(),
128            cell_gap: 3.0,
129            orient: EuvChartOrient::Horizontal,
130        }
131    }
132}
133
134/// Default geographic coordinate system.
135impl Default for EuvChartGeo {
136    /// Creates a built-in stylized world map coordinate system.
137    ///
138    /// # Returns
139    ///
140    /// - `Self` - Default geo configuration.
141    fn default() -> Self {
142        Self {
143            preset: EuvChartGeoMapPreset::World,
144            regions: Vec::new(),
145            show_labels: true,
146            roam: false,
147        }
148    }
149}
150
151/// Default interactive hover tooltip configuration.
152impl Default for EuvChartTooltip {
153    /// Creates an axis-triggered tooltip with a vertical hairline crosshair.
154    ///
155    /// # Returns
156    ///
157    /// - `Self` - Default tooltip configuration.
158    fn default() -> Self {
159        Self {
160            show: true,
161            trigger: EuvChartTooltipTrigger::Axis,
162            axis_pointer: EuvChartAxisPointerType::Line,
163        }
164    }
165}
166
167/// Default interactive data-zoom slider configuration.
168impl Default for EuvChartDataZoom {
169    /// Creates a full-range slider data-zoom controller spanning `0%..=100%`.
170    ///
171    /// # Returns
172    ///
173    /// - `Self` - Default data-zoom controller.
174    fn default() -> Self {
175        Self {
176            kind: EuvChartDataZoomKind::Slider,
177            start_pct: 0.0,
178            end_pct: 100.0,
179            min_span_pct: ECHART_ZOOM_DEFAULT_MIN_SPAN,
180            show_preview: true,
181        }
182    }
183}
184
185/// Default visual-map gradient configuration.
186impl Default for EuvChartVisualMap {
187    /// Creates a visible continuous visual-map spanning `0.0..=100.0`.
188    ///
189    /// # Returns
190    ///
191    /// - `Self` - Default visual-map configuration.
192    fn default() -> Self {
193        Self {
194            show: true,
195            kind: EuvChartVisualMapKind::Continuous,
196            min: 0.0,
197            max: 100.0,
198            in_range_colors: Vec::new(),
199            pieces: Vec::new(),
200            orient: EuvChartOrient::Horizontal,
201            position: EuvChartPosition::Bottom,
202        }
203    }
204}
205
206/// Default compact icon-only toolbox configuration.
207impl Default for EuvChartToolbox {
208    /// Creates a toolbox with Restore, MagicType, DataView, and Fullscreen icons enabled.
209    ///
210    /// # Returns
211    ///
212    /// - `Self` - Default toolbox configuration.
213    fn default() -> Self {
214        Self {
215            show: true,
216            restore: true,
217            magic_type: true,
218            data_view: true,
219            fullscreen: true,
220        }
221    }
222}
223
224/// Default line series configuration.
225impl Default for EuvChartLineSeries {
226    /// Creates a crisp solid line series with circular point markers.
227    ///
228    /// # Returns
229    ///
230    /// - `Self` - Default line series.
231    fn default() -> Self {
232        Self {
233            values: Vec::new(),
234            xy_points: Vec::new(),
235            smooth: false,
236            step: EuvChartStepMode::None,
237            area_opacity: 0.0,
238            area_gradient: true,
239            stack: None,
240            dashed: false,
241            line_width: 2.2,
242            symbol: EuvChartSymbol::Circle,
243            symbol_size: 3.5,
244            connect_nulls: false,
245            show_labels: false,
246            coordinate_system: EuvChartCoordinateSystem::Cartesian2d,
247            x_axis_index: 0,
248            y_axis_index: 0,
249            annotations: EuvChartAnnotations::default(),
250            encode: None,
251        }
252    }
253}
254
255/// Default bar series configuration.
256impl Default for EuvChartBarSeries {
257    /// Creates a vertical grouped bar series with gently rounded caps.
258    ///
259    /// # Returns
260    ///
261    /// - `Self` - Default bar series.
262    fn default() -> Self {
263        Self {
264            values: Vec::new(),
265            stack: None,
266            bar_radius: 4.0,
267            bar_width_ratio: 0.62,
268            show_background: false,
269            show_labels: false,
270            coordinate_system: EuvChartCoordinateSystem::Cartesian2d,
271            x_axis_index: 0,
272            y_axis_index: 0,
273            annotations: EuvChartAnnotations::default(),
274            encode: None,
275        }
276    }
277}
278
279/// Default pie series configuration.
280impl Default for EuvChartPieSeries {
281    /// Creates a standard pie chart with external leader lines and labels.
282    ///
283    /// # Returns
284    ///
285    /// - `Self` - Default pie series.
286    fn default() -> Self {
287        Self {
288            slices: Vec::new(),
289            inner_radius_ratio: 0.0,
290            outer_radius_ratio: ECHART_PIE_DEFAULT_OUTER_RATIO,
291            rose_type: EuvChartRoseType::None,
292            pad_angle_deg: 1.5,
293            start_angle_deg: ECHART_PIE_DEFAULT_START_ANGLE,
294            show_labels: true,
295            show_leader_lines: true,
296            selected_offset: ECHART_PIE_DEFAULT_POPOUT,
297            center_x_ratio: 0.5,
298            center_y_ratio: 0.52,
299        }
300    }
301}
302
303/// Default scatter series configuration.
304impl Default for EuvChartScatterSeries {
305    /// Creates a Cartesian circular scatter series.
306    ///
307    /// # Returns
308    ///
309    /// - `Self` - Default scatter series.
310    fn default() -> Self {
311        Self {
312            points: Vec::new(),
313            symbol: EuvChartSymbol::Circle,
314            default_size: 6.0,
315            ripple_rings: 3,
316            ripple_scale: 2.6,
317            show_labels: false,
318            coordinate_system: EuvChartCoordinateSystem::Cartesian2d,
319            x_axis_index: 0,
320            y_axis_index: 0,
321            annotations: EuvChartAnnotations::default(),
322            encode: None,
323        }
324    }
325}
326
327/// Default radar series configuration.
328impl Default for EuvChartRadarSeries {
329    /// Creates a semi-transparent filled radar polygon series with vertex dots.
330    ///
331    /// # Returns
332    ///
333    /// - `Self` - Default radar series.
334    fn default() -> Self {
335        Self {
336            items: Vec::new(),
337            area_opacity: 0.24,
338            line_width: 2.0,
339            show_vertices: true,
340        }
341    }
342}
343
344/// Default candlestick series configuration.
345impl Default for EuvChartCandlestickSeries {
346    /// Creates an empty OHLC candlestick series on axis 0.
347    ///
348    /// # Returns
349    ///
350    /// - `Self` - Default candlestick series.
351    fn default() -> Self {
352        Self {
353            candles: Vec::new(),
354            bull_color: None,
355            bear_color: None,
356            x_axis_index: 0,
357            y_axis_index: 0,
358            annotations: EuvChartAnnotations::default(),
359        }
360    }
361}
362
363/// Default boxplot series configuration.
364impl Default for EuvChartBoxplotSeries {
365    /// Creates an empty five-number boxplot series on axis 0.
366    ///
367    /// # Returns
368    ///
369    /// - `Self` - Default boxplot series.
370    fn default() -> Self {
371        Self {
372            items: Vec::new(),
373            x_axis_index: 0,
374            y_axis_index: 0,
375            annotations: EuvChartAnnotations::default(),
376        }
377    }
378}
379
380/// Default heatmap series configuration.
381impl Default for EuvChartHeatmapSeries {
382    /// Creates a Cartesian matrix heatmap with cell labels enabled.
383    ///
384    /// # Returns
385    ///
386    /// - `Self` - Default heatmap series.
387    fn default() -> Self {
388        Self {
389            cells: Vec::new(),
390            show_labels: true,
391            cell_gap: 2.0,
392            coordinate_system: EuvChartCoordinateSystem::Cartesian2d,
393            x_axis_index: 0,
394            y_axis_index: 0,
395        }
396    }
397}
398
399/// Default treemap series configuration.
400impl Default for EuvChartTreemapSeries {
401    /// Creates a squarified treemap with group headers and subtle rounded corners.
402    ///
403    /// # Returns
404    ///
405    /// - `Self` - Default treemap series.
406    fn default() -> Self {
407        Self {
408            nodes: Vec::new(),
409            show_headers: true,
410            cell_gap: 3.0,
411            corner_radius: 4.0,
412        }
413    }
414}
415
416/// Default sunburst series configuration.
417impl Default for EuvChartSunburstSeries {
418    /// Creates a concentric hierarchical sunburst series.
419    ///
420    /// # Returns
421    ///
422    /// - `Self` - Default sunburst series.
423    fn default() -> Self {
424        Self {
425            nodes: Vec::new(),
426            inner_radius_ratio: 0.16,
427            outer_radius_ratio: 0.84,
428            pad_angle_deg: 1.0,
429            show_labels: true,
430        }
431    }
432}
433
434/// Default Sankey flow diagram configuration.
435impl Default for EuvChartSankeySeries {
436    /// Creates a layered Sankey series with translucent flow ribbons.
437    ///
438    /// # Returns
439    ///
440    /// - `Self` - Default Sankey series.
441    fn default() -> Self {
442        Self {
443            nodes: Vec::new(),
444            links: Vec::new(),
445            node_width: 14.0,
446            node_gap: 10.0,
447            ribbon_opacity: 0.36,
448        }
449    }
450}
451
452/// Default conversion funnel configuration.
453impl Default for EuvChartFunnelSeries {
454    /// Creates a descending conversion funnel with percentage labels.
455    ///
456    /// # Returns
457    ///
458    /// - `Self` - Default funnel series.
459    fn default() -> Self {
460        Self {
461            stages: Vec::new(),
462            sort: EuvChartFunnelSort::Descending,
463            gap: 3.0,
464            show_labels: true,
465            show_percent: true,
466        }
467    }
468}
469
470/// Default circular dial gauge configuration.
471impl Default for EuvChartGaugeSeries {
472    /// Creates a 270-degree dial gauge spanning `0..=100` with progress arc and pointer needle.
473    ///
474    /// # Returns
475    ///
476    /// - `Self` - Default gauge series.
477    fn default() -> Self {
478        Self {
479            value: 0.0,
480            min: 0.0,
481            max: 100.0,
482            unit: String::new(),
483            title: String::new(),
484            start_angle_deg: ECHART_GAUGE_DEFAULT_START_ANGLE,
485            end_angle_deg: ECHART_GAUGE_DEFAULT_END_ANGLE,
486            split_number: 5,
487            show_progress: true,
488            show_pointer: true,
489            segments: vec![
490                EuvChartGaugeSegment::new(0.35, Color::hex(ECHART_GAUGE_LOW_HEX)),
491                EuvChartGaugeSegment::new(0.75, Color::hex(ECHART_GAUGE_MID_HEX)),
492                EuvChartGaugeSegment::new(1.0, Color::hex(ECHART_GAUGE_HIGH_HEX)),
493            ],
494        }
495    }
496}
497
498/// Default relational network graph configuration.
499impl Default for EuvChartGraphSeries {
500    /// Creates a force-directed graph series with labels enabled.
501    ///
502    /// # Returns
503    ///
504    /// - `Self` - Default graph series.
505    fn default() -> Self {
506        Self {
507            nodes: Vec::new(),
508            edges: Vec::new(),
509            categories: Vec::new(),
510            layout: EuvChartGraphLayout::Force,
511            directed: true,
512            show_labels: true,
513            iterations: ECHART_GRAPH_DEFAULT_ITERS,
514        }
515    }
516}
517
518/// Default hierarchical tree series configuration.
519impl Default for EuvChartTreeSeries {
520    /// Creates a left-to-right orthogonal tree series.
521    ///
522    /// # Returns
523    ///
524    /// - `Self` - Default tree series.
525    fn default() -> Self {
526        Self {
527            root: EuvChartHierarchyNode::leaf(String::new(), 1.0),
528            layout: EuvChartTreeLayout::OrthogonalLeftRight,
529            symbol_size: 5.5,
530            show_labels: true,
531        }
532    }
533}
534
535/// Default parallel coordinates series configuration.
536impl Default for EuvChartParallelSeries {
537    /// Creates a parallel coordinates series with semi-transparent polylines.
538    ///
539    /// # Returns
540    ///
541    /// - `Self` - Default parallel series.
542    fn default() -> Self {
543        Self {
544            axes: Vec::new(),
545            rows: Vec::new(),
546            line_width: 1.8,
547            line_opacity: 0.72,
548        }
549    }
550}
551
552/// Default curved directional flow arcs configuration.
553impl Default for EuvChartLinesSeries {
554    /// Creates a Cartesian curved lines series with arrowheads enabled.
555    ///
556    /// # Returns
557    ///
558    /// - `Self` - Default lines series.
559    fn default() -> Self {
560        Self {
561            arcs: Vec::new(),
562            curveness: 0.22,
563            line_width: 2.0,
564            show_arrows: true,
565            coordinate_system: EuvChartCoordinateSystem::Cartesian2d,
566            x_axis_index: 0,
567            y_axis_index: 0,
568        }
569    }
570}
571
572/// Default ThemeRiver streamgraph configuration.
573impl Default for EuvChartThemeRiverSeries {
574    /// Creates a smooth centered ThemeRiver streamgraph with labels enabled.
575    ///
576    /// # Returns
577    ///
578    /// - `Self` - Default ThemeRiver series.
579    fn default() -> Self {
580        Self {
581            points: Vec::new(),
582            show_labels: true,
583            smooth: true,
584        }
585    }
586}
587
588/// Default pictorial bar series configuration.
589impl Default for EuvChartPictorialBarSeries {
590    /// Creates a repeated rounded-capsule pictorial bar series.
591    ///
592    /// # Returns
593    ///
594    /// - `Self` - Default pictorial bar series.
595    fn default() -> Self {
596        Self {
597            values: Vec::new(),
598            symbol: EuvChartSymbol::RoundRect,
599            symbol_repeat: true,
600            symbol_size: 10.0,
601            x_axis_index: 0,
602            y_axis_index: 0,
603        }
604    }
605}
606
607/// Default custom series configuration.
608impl Default for EuvChartCustomSeries {
609    /// Creates an empty custom painter series on axis 0.
610    ///
611    /// # Returns
612    ///
613    /// - `Self` - Default custom series.
614    fn default() -> Self {
615        Self {
616            values: Vec::new(),
617            painter: None,
618            x_axis_index: 0,
619            y_axis_index: 0,
620        }
621    }
622}
623
624/// Default geographic choropleth map series configuration.
625impl Default for EuvChartGeoMapSeries {
626    /// Creates a GeoMap series with labels and crisp borders enabled.
627    ///
628    /// # Returns
629    ///
630    /// - `Self` - Default GeoMap series.
631    fn default() -> Self {
632        Self {
633            data: Vec::new(),
634            show_labels: true,
635            border_width: 1.0,
636        }
637    }
638}
639
640/// Constructors and fluent builders for `EuvChartTitle`.
641impl EuvChartTitle {
642    /// Constructs a chart title with left alignment.
643    ///
644    /// # Arguments
645    ///
646    /// - `TextValue` - Primary chart title string.
647    ///
648    /// # Returns
649    ///
650    /// - `Self` - Constructed title block.
651    #[must_use]
652    pub fn new<TextValue>(text: TextValue) -> Self
653    where
654        TextValue: Into<String>,
655    {
656        Self {
657            text: text.into(),
658            subtext: String::new(),
659            align: EuvChartAlign::Left,
660        }
661    }
662
663    /// Sets an optional subtitle line fluently.
664    ///
665    /// # Arguments
666    ///
667    /// - `Self` - Source title block.
668    /// - `TextValue` - Subtitle copy.
669    ///
670    /// # Returns
671    ///
672    /// - `Self` - Updated title block.
673    #[must_use]
674    pub fn subtext<TextValue>(mut self, subtext: TextValue) -> Self
675    where
676        TextValue: Into<String>,
677    {
678        self.set_subtext(subtext.into());
679        self
680    }
681
682    /// Sets horizontal alignment fluently.
683    ///
684    /// # Arguments
685    ///
686    /// - `Self` - Source title block.
687    /// - `EuvChartAlign` - Title horizontal alignment.
688    ///
689    /// # Returns
690    ///
691    /// - `Self` - Updated title block.
692    #[must_use]
693    pub fn align(mut self, align: EuvChartAlign) -> Self {
694        self.set_align(align);
695        self
696    }
697}
698
699/// Fluent builders for `EuvChartLegend`.
700impl EuvChartLegend {
701    /// Creates a legend docked at `position`.
702    ///
703    /// # Arguments
704    ///
705    /// - `EuvChartPosition` - Docked legend edge.
706    ///
707    /// # Returns
708    ///
709    /// - `Self` - Configured legend.
710    #[must_use]
711    pub fn at(position: EuvChartPosition) -> Self {
712        let mut legend: Self = Self::default();
713        legend.set_position(position);
714        legend
715    }
716
717    /// Controls whether the legend strip is shown.
718    ///
719    /// # Arguments
720    ///
721    /// - `Self` - Source legend.
722    /// - `bool` - Visibility flag.
723    ///
724    /// # Returns
725    ///
726    /// - `Self` - Updated legend.
727    #[must_use]
728    pub fn show(mut self, show: bool) -> Self {
729        self.set_show(show);
730        self
731    }
732
733    /// Sets custom explicit legend item labels.
734    ///
735    /// # Arguments
736    ///
737    /// - `Self` - Source legend.
738    /// - `Vec<String>` - Explicit item labels.
739    ///
740    /// # Returns
741    ///
742    /// - `Self` - Updated legend.
743    #[must_use]
744    pub fn items(mut self, items: Vec<String>) -> Self {
745        self.set_items(items);
746        self
747    }
748}
749
750/// Fluent builders for `EuvChartGrid`.
751impl EuvChartGrid {
752    /// Creates a Cartesian subplot grid with explicit logical margins.
753    ///
754    /// # Arguments
755    ///
756    /// - `f32` - Left margin.
757    /// - `f32` - Right margin.
758    /// - `f32` - Top margin.
759    /// - `f32` - Bottom margin.
760    ///
761    /// # Returns
762    ///
763    /// - `Self` - Configured grid.
764    #[must_use]
765    pub fn margins(left: f32, right: f32, top: f32, bottom: f32) -> Self {
766        Self {
767            left,
768            right,
769            top,
770            bottom,
771            contain_label: true,
772            show_border: false,
773        }
774    }
775
776    /// Sets whether axis labels expand the grid margin automatically.
777    ///
778    /// # Arguments
779    ///
780    /// - `Self` - Source grid.
781    /// - `bool` - Label containment flag.
782    ///
783    /// # Returns
784    ///
785    /// - `Self` - Updated grid.
786    #[must_use]
787    pub fn contain_label(mut self, contain_label: bool) -> Self {
788        self.set_contain_label(contain_label);
789        self
790    }
791
792    /// Sets whether a frame border is drawn around the plot area.
793    ///
794    /// # Arguments
795    ///
796    /// - `Self` - Source grid.
797    /// - `bool` - Border visibility flag.
798    ///
799    /// # Returns
800    ///
801    /// - `Self` - Updated grid.
802    #[must_use]
803    pub fn show_border(mut self, show_border: bool) -> Self {
804        self.set_show_border(show_border);
805        self
806    }
807}
808
809/// Constructors, fluent builders, and safe option accessors for `EuvChartAxis`.
810impl EuvChartAxis {
811    /// Creates a discrete `Category` axis with the provided labels.
812    ///
813    /// # Arguments
814    ///
815    /// - `Vec<String>` - Ordered category labels.
816    ///
817    /// # Returns
818    ///
819    /// - `Self` - Category axis configuration.
820    #[must_use]
821    pub fn category(categories: Vec<String>) -> Self {
822        let mut axis: Self = Self::default();
823        axis.set_axis_type(EuvChartAxisType::Category);
824        axis.set_categories(categories);
825        axis.set_show_split_line(false);
826        axis
827    }
828
829    /// Creates a continuous linear `Value` axis.
830    ///
831    /// # Returns
832    ///
833    /// - `Self` - Value axis configuration.
834    #[must_use]
835    pub fn value() -> Self {
836        Self::default()
837    }
838
839    /// Creates a continuous `Time` axis formatting numeric timestamps.
840    ///
841    /// # Returns
842    ///
843    /// - `Self` - Time axis configuration.
844    #[must_use]
845    pub fn time() -> Self {
846        let mut axis: Self = Self::default();
847        axis.set_axis_type(EuvChartAxisType::Time);
848        axis
849    }
850
851    /// Creates a base-10 logarithmic `Log` axis.
852    ///
853    /// # Returns
854    ///
855    /// - `Self` - Logarithmic axis configuration.
856    #[must_use]
857    pub fn log() -> Self {
858        let mut axis: Self = Self::default();
859        axis.set_axis_type(EuvChartAxisType::Log);
860        axis
861    }
862
863    /// Sets the axis caption name fluently.
864    ///
865    /// # Arguments
866    ///
867    /// - `Self` - Source axis.
868    /// - `TextValue` - Axis name text.
869    ///
870    /// # Returns
871    ///
872    /// - `Self` - Updated axis.
873    #[must_use]
874    pub fn name<TextValue>(mut self, name: TextValue) -> Self
875    where
876        TextValue: Into<String>,
877    {
878        self.set_name(name.into());
879        self
880    }
881
882    /// Sets a unit suffix appended to numeric tick labels.
883    ///
884    /// # Arguments
885    ///
886    /// - `Self` - Source axis.
887    /// - `TextValue` - Unit suffix (e.g. `"%"` or `"ms"`).
888    ///
889    /// # Returns
890    ///
891    /// - `Self` - Updated axis.
892    #[must_use]
893    pub fn unit_suffix<TextValue>(mut self, suffix: TextValue) -> Self
894    where
895        TextValue: Into<String>,
896    {
897        self.set_unit_suffix(suffix.into());
898        self
899    }
900
901    /// Sets an explicit lower domain bound.
902    ///
903    /// # Arguments
904    ///
905    /// - `Self` - Source axis.
906    /// - `f32` - Explicit minimum domain value.
907    ///
908    /// # Returns
909    ///
910    /// - `Self` - Updated axis.
911    #[must_use]
912    pub fn min(mut self, min: f32) -> Self {
913        self.set_min(Some(min));
914        self
915    }
916
917    /// Sets an explicit upper domain bound.
918    ///
919    /// # Arguments
920    ///
921    /// - `Self` - Source axis.
922    /// - `f32` - Explicit maximum domain value.
923    ///
924    /// # Returns
925    ///
926    /// - `Self` - Updated axis.
927    #[must_use]
928    pub fn max(mut self, max: f32) -> Self {
929        self.set_max(Some(max));
930        self
931    }
932
933    /// Reverses axis direction when `inverse` is `true`.
934    ///
935    /// # Arguments
936    ///
937    /// - `Self` - Source axis.
938    /// - `bool` - Inverse direction flag.
939    ///
940    /// # Returns
941    ///
942    /// - `Self` - Updated axis.
943    #[must_use]
944    pub fn inverse(mut self, inverse: bool) -> Self {
945        self.set_inverse(inverse);
946        self
947    }
948
949    /// Sets the target tick split count.
950    ///
951    /// # Arguments
952    ///
953    /// - `Self` - Source axis.
954    /// - `usize` - Split interval count.
955    ///
956    /// # Returns
957    ///
958    /// - `Self` - Updated axis.
959    #[must_use]
960    pub fn split_number(mut self, count: usize) -> Self {
961        self.set_split_number(count.max(1));
962        self
963    }
964
965    /// Sets whether grid split lines are rendered.
966    ///
967    /// # Arguments
968    ///
969    /// - `Self` - Source axis.
970    /// - `bool` - Split line visibility flag.
971    ///
972    /// # Returns
973    ///
974    /// - `Self` - Updated axis.
975    #[must_use]
976    pub fn show_split_line(mut self, show: bool) -> Self {
977        self.set_show_split_line(show);
978        self
979    }
980
981    /// Sets whether alternating split background bands are rendered.
982    ///
983    /// # Arguments
984    ///
985    /// - `Self` - Source axis.
986    /// - `bool` - Split area visibility flag.
987    ///
988    /// # Returns
989    ///
990    /// - `Self` - Updated axis.
991    #[must_use]
992    pub fn show_split_area(mut self, show: bool) -> Self {
993        self.set_show_split_area(show);
994        self
995    }
996
997    /// Assigns this axis to a specific subplot grid index.
998    ///
999    /// # Arguments
1000    ///
1001    /// - `Self` - Source axis.
1002    /// - `usize` - Subplot grid index.
1003    ///
1004    /// # Returns
1005    ///
1006    /// - `Self` - Updated axis.
1007    #[must_use]
1008    pub fn grid_index(mut self, idx: usize) -> Self {
1009        self.set_grid_index(idx);
1010        self
1011    }
1012
1013    /// Overrides the axis side placement for dual-axis layouts.
1014    ///
1015    /// # Arguments
1016    ///
1017    /// - `Self` - Source axis.
1018    /// - `EuvChartPosition` - Explicit axis side.
1019    ///
1020    /// # Returns
1021    ///
1022    /// - `Self` - Updated axis.
1023    #[must_use]
1024    pub fn position(mut self, pos: EuvChartPosition) -> Self {
1025        self.set_position(Some(pos));
1026        self
1027    }
1028
1029    /// Returns the optional explicit minimum domain bound.
1030    ///
1031    /// # Arguments
1032    ///
1033    /// - `&Self` - Axis configuration.
1034    ///
1035    /// # Returns
1036    ///
1037    /// - `Option<f32>` - Explicit lower bound when configured.
1038    #[must_use]
1039    pub fn min_opt(&self) -> Option<f32> {
1040        let Self { min, .. } = *self;
1041        min
1042    }
1043
1044    /// Returns the optional explicit maximum domain bound.
1045    ///
1046    /// # Arguments
1047    ///
1048    /// - `&Self` - Axis configuration.
1049    ///
1050    /// # Returns
1051    ///
1052    /// - `Option<f32>` - Explicit upper bound when configured.
1053    #[must_use]
1054    pub fn max_opt(&self) -> Option<f32> {
1055        let Self { max, .. } = *self;
1056        max
1057    }
1058
1059    /// Returns the optional explicit side override.
1060    ///
1061    /// # Arguments
1062    ///
1063    /// - `&Self` - Axis configuration.
1064    ///
1065    /// # Returns
1066    ///
1067    /// - `Option<EuvChartPosition>` - Explicit side when set.
1068    #[must_use]
1069    pub fn position_opt(&self) -> Option<EuvChartPosition> {
1070        let Self { position, .. } = *self;
1071        position
1072    }
1073}
1074
1075/// Fluent constructors for `EuvChartPolar`.
1076impl EuvChartPolar {
1077    /// Creates a polar coordinate system from angle and radius axes.
1078    ///
1079    /// # Arguments
1080    ///
1081    /// - `EuvChartAxis` - Angular axis definition.
1082    /// - `EuvChartAxis` - Radial axis definition.
1083    ///
1084    /// # Returns
1085    ///
1086    /// - `Self` - Polar coordinate system.
1087    #[must_use]
1088    pub fn new(angle_axis: EuvChartAxis, radius_axis: EuvChartAxis) -> Self {
1089        Self {
1090            angle_axis,
1091            radius_axis,
1092            radius_ratio: 0.72,
1093            center_x_ratio: 0.5,
1094            center_y_ratio: 0.52,
1095        }
1096    }
1097}
1098
1099/// Fluent constructors for `EuvChartRadar`.
1100impl EuvChartRadar {
1101    /// Creates a radar web from ordered indicator definitions.
1102    ///
1103    /// # Arguments
1104    ///
1105    /// - `Vec<EuvChartRadarIndicator>` - Multivariate indicator spokes.
1106    ///
1107    /// # Returns
1108    ///
1109    /// - `Self` - Radar coordinate system.
1110    #[must_use]
1111    pub fn new(indicators: Vec<EuvChartRadarIndicator>) -> Self {
1112        let mut radar: Self = Self::default();
1113        radar.set_indicators(indicators);
1114        radar
1115    }
1116
1117    /// Sets polygon or circular web ring geometry.
1118    ///
1119    /// # Arguments
1120    ///
1121    /// - `Self` - Source radar configuration.
1122    /// - `EuvChartRadarShape` - Web ring geometry.
1123    ///
1124    /// # Returns
1125    ///
1126    /// - `Self` - Updated radar configuration.
1127    #[must_use]
1128    pub fn shape(mut self, shape: EuvChartRadarShape) -> Self {
1129        self.set_shape(shape);
1130        self
1131    }
1132
1133    /// Sets the number of concentric split rings.
1134    ///
1135    /// # Arguments
1136    ///
1137    /// - `Self` - Source radar configuration.
1138    /// - `usize` - Ring count.
1139    ///
1140    /// # Returns
1141    ///
1142    /// - `Self` - Updated radar configuration.
1143    #[must_use]
1144    pub fn split_number(mut self, split_number: usize) -> Self {
1145        self.set_split_number(split_number.max(1));
1146        self
1147    }
1148}
1149
1150/// Fluent constructors for `EuvChartSingleAxis`.
1151impl EuvChartSingleAxis {
1152    /// Creates a single-axis coordinate system wrapping `axis`.
1153    ///
1154    /// # Arguments
1155    ///
1156    /// - `EuvChartAxis` - Underlying 1D axis definition.
1157    ///
1158    /// # Returns
1159    ///
1160    /// - `Self` - Single-axis coordinate system.
1161    #[must_use]
1162    pub fn new(axis: EuvChartAxis) -> Self {
1163        Self {
1164            axis,
1165            center_y_ratio: 0.54,
1166        }
1167    }
1168}
1169
1170/// Fluent constructors for `EuvChartCalendar`.
1171impl EuvChartCalendar {
1172    /// Creates a calendar coordinate system for `year` and `weeks`.
1173    ///
1174    /// # Arguments
1175    ///
1176    /// - `u32` - Calendar year.
1177    /// - `usize` - Number of week columns.
1178    ///
1179    /// # Returns
1180    ///
1181    /// - `Self` - Calendar coordinate system.
1182    #[must_use]
1183    pub fn new(year: u32, weeks: usize) -> Self {
1184        let mut cal: Self = Self::default();
1185        cal.set_year(year);
1186        cal.set_weeks(weeks.max(1));
1187        cal
1188    }
1189
1190    /// Sets custom month header labels along the week span.
1191    ///
1192    /// # Arguments
1193    ///
1194    /// - `Self` - Source calendar.
1195    /// - `Vec<String>` - Ordered month labels.
1196    ///
1197    /// # Returns
1198    ///
1199    /// - `Self` - Updated calendar.
1200    #[must_use]
1201    pub fn month_labels(mut self, labels: Vec<String>) -> Self {
1202        self.set_month_labels(labels);
1203        self
1204    }
1205}
1206
1207/// Constructors and accessors for `EuvChartGeoRegion` and `EuvChartGeo`.
1208impl EuvChartGeoRegion {
1209    /// Creates a geographic polygon region from `(lon, lat)` rings.
1210    ///
1211    /// # Arguments
1212    ///
1213    /// - `TextValue` - Region name.
1214    /// - `CodeValue` - Region ISO or short code.
1215    /// - `Vec<Vec<(f32, f32)>>` - Closed exterior polygon rings.
1216    ///
1217    /// # Returns
1218    ///
1219    /// - `Self` - Constructed region.
1220    #[must_use]
1221    pub fn new<TextValue, CodeValue>(
1222        name: TextValue,
1223        code: CodeValue,
1224        polygons: Vec<Vec<(f32, f32)>>,
1225    ) -> Self
1226    where
1227        TextValue: Into<String>,
1228        CodeValue: Into<String>,
1229    {
1230        Self {
1231            name: name.into(),
1232            code: code.into(),
1233            polygons,
1234            label_center: None,
1235        }
1236    }
1237
1238    /// Sets an explicit `(lon, lat)` label anchor point.
1239    ///
1240    /// # Arguments
1241    ///
1242    /// - `Self` - Source region.
1243    /// - `(f32, f32)` - Label `(longitude, latitude)` coordinate.
1244    ///
1245    /// # Returns
1246    ///
1247    /// - `Self` - Updated region.
1248    #[must_use]
1249    pub fn label_center(mut self, center: (f32, f32)) -> Self {
1250        self.set_label_center(Some(center));
1251        self
1252    }
1253
1254    /// Returns the optional explicit label anchor.
1255    ///
1256    /// # Arguments
1257    ///
1258    /// - `&Self` - Source region.
1259    ///
1260    /// # Returns
1261    ///
1262    /// - `Option<(f32, f32)>` - Explicit `(lon, lat)` label anchor.
1263    #[must_use]
1264    pub fn label_center_opt(&self) -> Option<(f32, f32)> {
1265        let Self { label_center, .. } = *self;
1266        label_center
1267    }
1268}
1269
1270/// Fluent builders for `EuvChartGeo`.
1271impl EuvChartGeo {
1272    /// Creates a built-in stylized world map coordinate system.
1273    ///
1274    /// # Returns
1275    ///
1276    /// - `Self` - World geo coordinate system.
1277    #[must_use]
1278    pub fn world() -> Self {
1279        Self::default()
1280    }
1281
1282    /// Creates a custom geo coordinate system from caller-supplied regions.
1283    ///
1284    /// # Arguments
1285    ///
1286    /// - `Vec<EuvChartGeoRegion>` - Custom vector polygon regions.
1287    ///
1288    /// # Returns
1289    ///
1290    /// - `Self` - Custom geo coordinate system.
1291    #[must_use]
1292    pub fn custom(regions: Vec<EuvChartGeoRegion>) -> Self {
1293        Self {
1294            preset: EuvChartGeoMapPreset::Custom,
1295            regions,
1296            show_labels: true,
1297            roam: false,
1298        }
1299    }
1300
1301    /// Toggles region caption visibility on the map.
1302    ///
1303    /// # Arguments
1304    ///
1305    /// - `Self` - Source geo coordinate system.
1306    /// - `bool` - Label visibility flag.
1307    ///
1308    /// # Returns
1309    ///
1310    /// - `Self` - Updated geo coordinate system.
1311    #[must_use]
1312    pub fn show_labels(mut self, show: bool) -> Self {
1313        self.set_show_labels(show);
1314        self
1315    }
1316}
1317
1318/// Fluent constructors for `EuvChartTooltip`.
1319impl EuvChartTooltip {
1320    /// Creates a tooltip with `trigger` and `axis_pointer`.
1321    ///
1322    /// # Arguments
1323    ///
1324    /// - `EuvChartTooltipTrigger` - Tooltip trigger mode.
1325    /// - `EuvChartAxisPointerType` - Crosshair axis pointer style.
1326    ///
1327    /// # Returns
1328    ///
1329    /// - `Self` - Configured tooltip.
1330    #[must_use]
1331    pub fn new(trigger: EuvChartTooltipTrigger, axis_pointer: EuvChartAxisPointerType) -> Self {
1332        Self {
1333            show: trigger != EuvChartTooltipTrigger::None,
1334            trigger,
1335            axis_pointer,
1336        }
1337    }
1338
1339    /// Creates an item-snapping tooltip without crosshair bars.
1340    ///
1341    /// # Returns
1342    ///
1343    /// - `Self` - Item tooltip configuration.
1344    #[must_use]
1345    pub fn item() -> Self {
1346        Self::new(EuvChartTooltipTrigger::Item, EuvChartAxisPointerType::None)
1347    }
1348
1349    /// Creates an axis-snapping tooltip with a chosen crosshair style.
1350    ///
1351    /// # Arguments
1352    ///
1353    /// - `EuvChartAxisPointerType` - Crosshair pointer style.
1354    ///
1355    /// # Returns
1356    ///
1357    /// - `Self` - Axis tooltip configuration.
1358    #[must_use]
1359    pub fn axis(pointer: EuvChartAxisPointerType) -> Self {
1360        Self::new(EuvChartTooltipTrigger::Axis, pointer)
1361    }
1362}
1363
1364/// Fluent constructors for `EuvChartDataZoom`.
1365impl EuvChartDataZoom {
1366    /// Creates an `Inside` wheel-zoom and drag-pan controller.
1367    ///
1368    /// # Returns
1369    ///
1370    /// - `Self` - Inside data-zoom controller.
1371    #[must_use]
1372    pub fn inside() -> Self {
1373        let mut dz: Self = Self::default();
1374        dz.set_kind(EuvChartDataZoomKind::Inside);
1375        dz
1376    }
1377
1378    /// Creates a bottom interactive `Slider` range scrubber.
1379    ///
1380    /// # Returns
1381    ///
1382    /// - `Self` - Slider data-zoom controller.
1383    #[must_use]
1384    pub fn slider() -> Self {
1385        Self::default()
1386    }
1387
1388    /// Sets the initial percentage window `(start_pct, end_pct)`.
1389    ///
1390    /// # Arguments
1391    ///
1392    /// - `Self` - Source data-zoom controller.
1393    /// - `f32` - Start percentage in `[0.0, 100.0]`.
1394    /// - `f32` - End percentage in `[0.0, 100.0]`.
1395    ///
1396    /// # Returns
1397    ///
1398    /// - `Self` - Updated data-zoom controller.
1399    #[must_use]
1400    pub fn range(mut self, start_pct: f32, end_pct: f32) -> Self {
1401        let lo: f32 = start_pct.clamp(0.0, 99.0);
1402        let hi: f32 = end_pct.clamp(lo + 1.0, 100.0);
1403        self.set_start_pct(lo);
1404        self.set_end_pct(hi);
1405        self
1406    }
1407}
1408
1409/// Constructors and accessors for `EuvChartVisualPiece`.
1410impl EuvChartVisualPiece {
1411    /// Creates a discrete piecewise color bucket.
1412    ///
1413    /// # Arguments
1414    ///
1415    /// - `Option<f32>` - Optional inclusive lower threshold.
1416    /// - `Option<f32>` - Optional inclusive upper threshold.
1417    /// - `TextValue` - Display label.
1418    /// - `Color` - Bucket fill color.
1419    ///
1420    /// # Returns
1421    ///
1422    /// - `Self` - Visual-map piece.
1423    #[must_use]
1424    pub fn new<TextValue>(
1425        min: Option<f32>,
1426        max: Option<f32>,
1427        label: TextValue,
1428        color: Color,
1429    ) -> Self
1430    where
1431        TextValue: Into<String>,
1432    {
1433        Self {
1434            min,
1435            max,
1436            label: label.into(),
1437            color,
1438        }
1439    }
1440
1441    /// Returns the optional lower bound.
1442    ///
1443    /// # Arguments
1444    ///
1445    /// - `&Self` - Piece definition.
1446    ///
1447    /// # Returns
1448    ///
1449    /// - `Option<f32>` - Lower threshold.
1450    #[must_use]
1451    pub fn min_opt(&self) -> Option<f32> {
1452        let Self { min, .. } = *self;
1453        min
1454    }
1455
1456    /// Returns the optional upper bound.
1457    ///
1458    /// # Arguments
1459    ///
1460    /// - `&Self` - Piece definition.
1461    ///
1462    /// # Returns
1463    ///
1464    /// - `Option<f32>` - Upper threshold.
1465    #[must_use]
1466    pub fn max_opt(&self) -> Option<f32> {
1467        let Self { max, .. } = *self;
1468        max
1469    }
1470}
1471
1472/// Fluent constructors for `EuvChartVisualMap`.
1473impl EuvChartVisualMap {
1474    /// Creates a continuous gradient visual-map spanning `[min, max]`.
1475    ///
1476    /// # Arguments
1477    ///
1478    /// - `f32` - Minimum mapped value.
1479    /// - `f32` - Maximum mapped value.
1480    ///
1481    /// # Returns
1482    ///
1483    /// - `Self` - Continuous visual-map.
1484    #[must_use]
1485    pub fn continuous(min: f32, max: f32) -> Self {
1486        let mut vm: Self = Self::default();
1487        vm.set_kind(EuvChartVisualMapKind::Continuous);
1488        vm.set_min(min);
1489        vm.set_max(max);
1490        vm
1491    }
1492
1493    /// Creates a piecewise discrete range visual-map.
1494    ///
1495    /// # Arguments
1496    ///
1497    /// - `Vec<EuvChartVisualPiece>` - Ordered discrete buckets.
1498    ///
1499    /// # Returns
1500    ///
1501    /// - `Self` - Piecewise visual-map.
1502    #[must_use]
1503    pub fn piecewise(pieces: Vec<EuvChartVisualPiece>) -> Self {
1504        let mut vm: Self = Self::default();
1505        vm.set_kind(EuvChartVisualMapKind::Piecewise);
1506        vm.set_pieces(pieces);
1507        vm
1508    }
1509
1510    /// Overrides the ordered color stops used by continuous interpolation.
1511    ///
1512    /// # Arguments
1513    ///
1514    /// - `Self` - Source visual-map.
1515    /// - `Vec<Color>` - Ordered gradient color stops.
1516    ///
1517    /// # Returns
1518    ///
1519    /// - `Self` - Updated visual-map.
1520    #[must_use]
1521    pub fn colors(mut self, colors: Vec<Color>) -> Self {
1522        self.set_in_range_colors(colors);
1523        self
1524    }
1525
1526    /// Sets the visual-map bar dock position.
1527    ///
1528    /// # Arguments
1529    ///
1530    /// - `Self` - Source visual-map.
1531    /// - `EuvChartPosition` - Docked edge.
1532    ///
1533    /// # Returns
1534    ///
1535    /// - `Self` - Updated visual-map.
1536    #[must_use]
1537    pub fn position(mut self, position: EuvChartPosition) -> Self {
1538        self.set_position(position);
1539        self
1540    }
1541}
1542
1543/// Fluent builders for `EuvChartToolbox`.
1544impl EuvChartToolbox {
1545    /// Creates a toolbox with all standard actions enabled.
1546    ///
1547    /// # Returns
1548    ///
1549    /// - `Self` - Full toolbox configuration.
1550    #[must_use]
1551    pub fn full() -> Self {
1552        Self::default()
1553    }
1554
1555    /// Toggles MagicType switcher availability.
1556    ///
1557    /// # Arguments
1558    ///
1559    /// - `Self` - Source toolbox.
1560    /// - `bool` - Enabled flag.
1561    ///
1562    /// # Returns
1563    ///
1564    /// - `Self` - Updated toolbox.
1565    #[must_use]
1566    pub fn magic_type(mut self, enabled: bool) -> Self {
1567        self.set_magic_type(enabled);
1568        self
1569    }
1570
1571    /// Toggles DataView tabular inspection availability.
1572    ///
1573    /// # Arguments
1574    ///
1575    /// - `Self` - Source toolbox.
1576    /// - `bool` - Enabled flag.
1577    ///
1578    /// # Returns
1579    ///
1580    /// - `Self` - Updated toolbox.
1581    #[must_use]
1582    pub fn data_view(mut self, enabled: bool) -> Self {
1583        self.set_data_view(enabled);
1584        self
1585    }
1586
1587    /// Toggles Fullscreen modal availability.
1588    ///
1589    /// # Arguments
1590    ///
1591    /// - `Self` - Source toolbox.
1592    /// - `bool` - Enabled flag.
1593    ///
1594    /// # Returns
1595    ///
1596    /// - `Self` - Updated toolbox.
1597    #[must_use]
1598    pub fn fullscreen(mut self, enabled: bool) -> Self {
1599        self.set_fullscreen(enabled);
1600        self
1601    }
1602}
1603
1604/// Constructors and helpers for `EuvChartDataset` and `EuvChartEncode`.
1605impl EuvChartDataset {
1606    /// Constructs a tabular dataset from column names and rows.
1607    ///
1608    /// # Arguments
1609    ///
1610    /// - `Vec<String>` - Dimension column names.
1611    /// - `Vec<Vec<EuvChartCell>>` - Ordered data rows.
1612    ///
1613    /// # Returns
1614    ///
1615    /// - `Self` - Constructed dataset.
1616    #[must_use]
1617    pub fn new(dimensions: Vec<String>, rows: Vec<Vec<EuvChartCell>>) -> Self {
1618        Self { dimensions, rows }
1619    }
1620
1621    /// Resolves a dimension name (or decimal column index string) to its column index.
1622    ///
1623    /// # Arguments
1624    ///
1625    /// - `&Self` - Source dataset.
1626    /// - `&str` - Dimension name or numeric column index.
1627    ///
1628    /// # Returns
1629    ///
1630    /// - `Option<usize>` - Matched column index.
1631    #[must_use]
1632    pub fn column_index(&self, dim: &str) -> Option<usize> {
1633        if let Some(pos) = self
1634            .get_dimensions()
1635            .iter()
1636            .position(|text_value: &String| text_value.as_str() == dim)
1637        {
1638            return Some(pos);
1639        }
1640        dim.parse::<usize>().ok()
1641    }
1642}
1643
1644/// Fluent builders and accessors for `EuvChartEncode`.
1645impl EuvChartEncode {
1646    /// Maps the X channel to dimension `dim`.
1647    ///
1648    /// # Arguments
1649    ///
1650    /// - `Self` - Source encode mapping.
1651    /// - `TextValue` - Dimension name or column index.
1652    ///
1653    /// # Returns
1654    ///
1655    /// - `Self` - Updated encode mapping.
1656    #[must_use]
1657    pub fn x_dimension<TextValue>(mut self, dimension: TextValue) -> Self
1658    where
1659        TextValue: Into<String>,
1660    {
1661        self.set_x_dimension(Some(dimension.into()));
1662        self
1663    }
1664
1665    /// Maps the Y channel to dimension `dim`.
1666    ///
1667    /// # Arguments
1668    ///
1669    /// - `Self` - Source encode mapping.
1670    /// - `TextValue` - Dimension name or column index.
1671    ///
1672    /// # Returns
1673    ///
1674    /// - `Self` - Updated encode mapping.
1675    #[must_use]
1676    pub fn y_dimension<TextValue>(mut self, dimension: TextValue) -> Self
1677    where
1678        TextValue: Into<String>,
1679    {
1680        self.set_y_dimension(Some(dimension.into()));
1681        self
1682    }
1683
1684    /// Maps the scalar value channel to dimension `dim`.
1685    ///
1686    /// # Arguments
1687    ///
1688    /// - `Self` - Source encode mapping.
1689    /// - `TextValue` - Dimension name or column index.
1690    ///
1691    /// # Returns
1692    ///
1693    /// - `Self` - Updated encode mapping.
1694    #[must_use]
1695    pub fn value<TextValue>(mut self, dim: TextValue) -> Self
1696    where
1697        TextValue: Into<String>,
1698    {
1699        self.set_value(Some(dim.into()));
1700        self
1701    }
1702
1703    /// Maps the bubble size channel to dimension `dim`.
1704    ///
1705    /// # Arguments
1706    ///
1707    /// - `Self` - Source encode mapping.
1708    /// - `TextValue` - Dimension name or column index.
1709    ///
1710    /// # Returns
1711    ///
1712    /// - `Self` - Updated encode mapping.
1713    #[must_use]
1714    pub fn size<TextValue>(mut self, dim: TextValue) -> Self
1715    where
1716        TextValue: Into<String>,
1717    {
1718        self.set_size(Some(dim.into()));
1719        self
1720    }
1721
1722    /// Maps the item caption channel to dimension `dim`.
1723    ///
1724    /// # Arguments
1725    ///
1726    /// - `Self` - Source encode mapping.
1727    /// - `TextValue` - Dimension name or column index.
1728    ///
1729    /// # Returns
1730    ///
1731    /// - `Self` - Updated encode mapping.
1732    #[must_use]
1733    pub fn item_name<TextValue>(mut self, dim: TextValue) -> Self
1734    where
1735        TextValue: Into<String>,
1736    {
1737        self.set_item_name(Some(dim.into()));
1738        self
1739    }
1740
1741    /// Returns the X dimension name if mapped.
1742    ///
1743    /// # Arguments
1744    ///
1745    /// - `&Self` - Encode mapping.
1746    ///
1747    /// # Returns
1748    ///
1749    /// - `Option<&str>` - Mapped X dimension.
1750    #[must_use]
1751    pub fn x_dimension_opt(&self) -> Option<&str> {
1752        let Self { x_dimension, .. } = self;
1753        x_dimension.as_deref()
1754    }
1755
1756    /// Returns the Y dimension name if mapped.
1757    ///
1758    /// # Arguments
1759    ///
1760    /// - `&Self` - Encode mapping.
1761    ///
1762    /// # Returns
1763    ///
1764    /// - `Option<&str>` - Mapped Y dimension.
1765    #[must_use]
1766    pub fn y_dimension_opt(&self) -> Option<&str> {
1767        let Self { y_dimension, .. } = self;
1768        y_dimension.as_deref()
1769    }
1770
1771    /// Returns the value dimension name if mapped.
1772    ///
1773    /// # Arguments
1774    ///
1775    /// - `&Self` - Encode mapping.
1776    ///
1777    /// # Returns
1778    ///
1779    /// - `Option<&str>` - Mapped value dimension.
1780    #[must_use]
1781    pub fn value_opt(&self) -> Option<&str> {
1782        let Self { value, .. } = self;
1783        value.as_deref()
1784    }
1785
1786    /// Returns the size dimension name if mapped.
1787    ///
1788    /// # Arguments
1789    ///
1790    /// - `&Self` - Encode mapping.
1791    ///
1792    /// # Returns
1793    ///
1794    /// - `Option<&str>` - Mapped size dimension.
1795    #[must_use]
1796    pub fn size_opt(&self) -> Option<&str> {
1797        let Self { size, .. } = self;
1798        size.as_deref()
1799    }
1800
1801    /// Returns the item name dimension if mapped.
1802    ///
1803    /// # Arguments
1804    ///
1805    /// - `&Self` - Encode mapping.
1806    ///
1807    /// # Returns
1808    ///
1809    /// - `Option<&str>` - Mapped item name dimension.
1810    #[must_use]
1811    pub fn item_name_opt(&self) -> Option<&str> {
1812        let Self { item_name, .. } = self;
1813        item_name.as_deref()
1814    }
1815}
1816
1817/// Constructors and accessors for `EuvChartMarkPoint`, `EuvChartMarkLine`, and `EuvChartMarkArea`.
1818impl EuvChartMarkPoint {
1819    /// Creates a mark-point annotation pin.
1820    ///
1821    /// # Arguments
1822    ///
1823    /// - `EuvChartMarkPointKind` - Target datum rule.
1824    /// - `TextValue` - Callout label.
1825    ///
1826    /// # Returns
1827    ///
1828    /// - `Self` - Constructed mark point.
1829    #[must_use]
1830    pub fn new<TextValue>(kind: EuvChartMarkPointKind, name: TextValue) -> Self
1831    where
1832        TextValue: Into<String>,
1833    {
1834        Self {
1835            kind,
1836            name: name.into(),
1837            color: None,
1838        }
1839    }
1840
1841    /// Overrides the pin tint color.
1842    ///
1843    /// # Arguments
1844    ///
1845    /// - `Self` - Source mark point.
1846    /// - `Color` - Pin fill color.
1847    ///
1848    /// # Returns
1849    ///
1850    /// - `Self` - Updated mark point.
1851    #[must_use]
1852    pub fn color(mut self, color: Color) -> Self {
1853        self.set_color(Some(color));
1854        self
1855    }
1856
1857    /// Returns the optional color override.
1858    ///
1859    /// # Arguments
1860    ///
1861    /// - `&Self` - Source mark point.
1862    ///
1863    /// # Returns
1864    ///
1865    /// - `Option<Color>` - Explicit pin color.
1866    #[must_use]
1867    pub fn color_opt(&self) -> Option<Color> {
1868        let Self { color, .. } = *self;
1869        color
1870    }
1871}
1872
1873/// Constructors and accessors for `EuvChartMarkLine`.
1874impl EuvChartMarkLine {
1875    /// Creates a dashed reference mark line.
1876    ///
1877    /// # Arguments
1878    ///
1879    /// - `EuvChartMarkLineKind` - Target reference rule.
1880    /// - `TextValue` - Reference label text.
1881    ///
1882    /// # Returns
1883    ///
1884    /// - `Self` - Constructed mark line.
1885    #[must_use]
1886    pub fn new<TextValue>(kind: EuvChartMarkLineKind, name: TextValue) -> Self
1887    where
1888        TextValue: Into<String>,
1889    {
1890        Self {
1891            kind,
1892            name: name.into(),
1893            color: None,
1894            dashed: true,
1895        }
1896    }
1897
1898    /// Overrides the mark line stroke color.
1899    ///
1900    /// # Arguments
1901    ///
1902    /// - `Self` - Source mark line.
1903    /// - `Color` - Stroke color.
1904    ///
1905    /// # Returns
1906    ///
1907    /// - `Self` - Updated mark line.
1908    #[must_use]
1909    pub fn color(mut self, color: Color) -> Self {
1910        self.set_color(Some(color));
1911        self
1912    }
1913
1914    /// Returns the optional color override.
1915    ///
1916    /// # Arguments
1917    ///
1918    /// - `&Self` - Source mark line.
1919    ///
1920    /// # Returns
1921    ///
1922    /// - `Option<Color>` - Explicit stroke color.
1923    #[must_use]
1924    pub fn color_opt(&self) -> Option<Color> {
1925        let Self { color, .. } = *self;
1926        color
1927    }
1928}
1929
1930/// Constructors and accessors for `EuvChartMarkArea`.
1931impl EuvChartMarkArea {
1932    /// Creates a vertical highlight band spanning `start_x..=end_x`.
1933    ///
1934    /// # Arguments
1935    ///
1936    /// - `f32` - Lower X bound or category index.
1937    /// - `f32` - Upper X bound or category index.
1938    /// - `TextValue` - Band caption.
1939    ///
1940    /// # Returns
1941    ///
1942    /// - `Self` - Vertical mark area.
1943    #[must_use]
1944    pub fn x_range<TextValue>(start_x: f32, end_x: f32, name: TextValue) -> Self
1945    where
1946        TextValue: Into<String>,
1947    {
1948        Self {
1949            start_x: Some(start_x),
1950            end_x: Some(end_x),
1951            start_y: None,
1952            end_y: None,
1953            name: name.into(),
1954            color: None,
1955        }
1956    }
1957
1958    /// Creates a horizontal highlight band spanning `start_y..=end_y`.
1959    ///
1960    /// # Arguments
1961    ///
1962    /// - `f32` - Lower Y value.
1963    /// - `f32` - Upper Y value.
1964    /// - `TextValue` - Band caption.
1965    ///
1966    /// # Returns
1967    ///
1968    /// - `Self` - Horizontal mark area.
1969    #[must_use]
1970    pub fn y_range<TextValue>(start_y: f32, end_y: f32, name: TextValue) -> Self
1971    where
1972        TextValue: Into<String>,
1973    {
1974        Self {
1975            start_x: None,
1976            end_x: None,
1977            start_y: Some(start_y),
1978            end_y: Some(end_y),
1979            name: name.into(),
1980            color: None,
1981        }
1982    }
1983
1984    /// Overrides the highlight band tint color.
1985    ///
1986    /// # Arguments
1987    ///
1988    /// - `Self` - Source mark area.
1989    /// - `Color` - Band tint color.
1990    ///
1991    /// # Returns
1992    ///
1993    /// - `Self` - Updated mark area.
1994    #[must_use]
1995    pub fn color(mut self, color: Color) -> Self {
1996        self.set_color(Some(color));
1997        self
1998    }
1999
2000    /// Returns `(start_x, end_x, start_y, end_y)` bounds.
2001    ///
2002    /// # Arguments
2003    ///
2004    /// - `&Self` - Source mark area.
2005    ///
2006    /// # Returns
2007    ///
2008    /// - `(Option<f32>, Option<f32>, Option<f32>, Option<f32>)` - Optional data bounds.
2009    #[must_use]
2010    pub fn bounds_opt(&self) -> (Option<f32>, Option<f32>, Option<f32>, Option<f32>) {
2011        let Self {
2012            start_x,
2013            end_x,
2014            start_y,
2015            end_y,
2016            ..
2017        } = *self;
2018        (start_x, end_x, start_y, end_y)
2019    }
2020
2021    /// Returns the optional tint override.
2022    ///
2023    /// # Arguments
2024    ///
2025    /// - `&Self` - Source mark area.
2026    ///
2027    /// # Returns
2028    ///
2029    /// - `Option<Color>` - Explicit band tint.
2030    #[must_use]
2031    pub fn color_opt(&self) -> Option<Color> {
2032        let Self { color, .. } = *self;
2033        color
2034    }
2035}
2036
2037/// Fluent builders and accessors for `EuvChartLineSeries`.
2038impl EuvChartLineSeries {
2039    /// Creates a line series from dense numeric values.
2040    ///
2041    /// # Arguments
2042    ///
2043    /// - `Vec<f32>` - Ordered Y values.
2044    ///
2045    /// # Returns
2046    ///
2047    /// - `Self` - Line series.
2048    #[must_use]
2049    pub fn from_values(values: Vec<f32>) -> Self {
2050        let mut source_val: Self = Self::default();
2051        let mapped: Vec<Option<f32>> = values.into_iter().map(Some).collect();
2052        source_val.set_values(mapped);
2053        source_val
2054    }
2055
2056    /// Creates a line series supporting `None` null gaps.
2057    ///
2058    /// # Arguments
2059    ///
2060    /// - `Vec<Option<f32>>` - Nullable Y values.
2061    ///
2062    /// # Returns
2063    ///
2064    /// - `Self` - Line series.
2065    #[must_use]
2066    pub fn from_nullable(values: Vec<Option<f32>>) -> Self {
2067        let mut source_val: Self = Self::default();
2068        source_val.set_values(values);
2069        source_val
2070    }
2071
2072    /// Creates a line series from explicit `(x, y)` coordinate pairs.
2073    ///
2074    /// # Arguments
2075    ///
2076    /// - `Vec<(f32, f32)>` - Explicit `(x, y)` coordinates.
2077    ///
2078    /// # Returns
2079    ///
2080    /// - `Self` - Line series.
2081    #[must_use]
2082    pub fn from_xy(points: Vec<(f32, f32)>) -> Self {
2083        let mut source_val: Self = Self::default();
2084        source_val.set_xy_points(points);
2085        source_val
2086    }
2087
2088    /// Enables or disables smooth Catmull-Rom curve interpolation.
2089    ///
2090    /// # Arguments
2091    ///
2092    /// - `Self` - Source line series.
2093    /// - `bool` - Smooth curve flag.
2094    ///
2095    /// # Returns
2096    ///
2097    /// - `Self` - Updated line series.
2098    #[must_use]
2099    pub fn smooth(mut self, smooth: bool) -> Self {
2100        self.set_smooth(smooth);
2101        self
2102    }
2103
2104    /// Sets step-line interpolation mode.
2105    ///
2106    /// # Arguments
2107    ///
2108    /// - `Self` - Source line series.
2109    /// - `EuvChartStepMode` - Step mode.
2110    ///
2111    /// # Returns
2112    ///
2113    /// - `Self` - Updated line series.
2114    #[must_use]
2115    pub fn step(mut self, step: EuvChartStepMode) -> Self {
2116        self.set_step(step);
2117        self
2118    }
2119
2120    /// Enables translucent area shading under the line.
2121    ///
2122    /// # Arguments
2123    ///
2124    /// - `Self` - Source line series.
2125    /// - `f32` - Area fill opacity in `[0.0, 1.0]`.
2126    ///
2127    /// # Returns
2128    ///
2129    /// - `Self` - Updated line series.
2130    #[must_use]
2131    pub fn area(mut self, opacity: f32) -> Self {
2132        self.set_area_opacity(opacity.clamp(0.0, 1.0));
2133        self
2134    }
2135
2136    /// Assigns a stack group name for stacked line/area rendering.
2137    ///
2138    /// # Arguments
2139    ///
2140    /// - `Self` - Source line series.
2141    /// - `TextValue` - Stack group key.
2142    ///
2143    /// # Returns
2144    ///
2145    /// - `Self` - Updated line series.
2146    #[must_use]
2147    pub fn stack<TextValue>(mut self, stack: TextValue) -> Self
2148    where
2149        TextValue: Into<String>,
2150    {
2151        self.set_stack(Some(stack.into()));
2152        self
2153    }
2154
2155    /// Enables dashed stroke rendering.
2156    ///
2157    /// # Arguments
2158    ///
2159    /// - `Self` - Source line series.
2160    /// - `bool` - Dashed stroke flag.
2161    ///
2162    /// # Returns
2163    ///
2164    /// - `Self` - Updated line series.
2165    #[must_use]
2166    pub fn dashed(mut self, dashed: bool) -> Self {
2167        self.set_dashed(dashed);
2168        self
2169    }
2170
2171    /// Configures vertex symbol shape and radius.
2172    ///
2173    /// # Arguments
2174    ///
2175    /// - `Self` - Source line series.
2176    /// - `EuvChartSymbol` - Symbol shape.
2177    /// - `f32` - Symbol radius in logical pixels.
2178    ///
2179    /// # Returns
2180    ///
2181    /// - `Self` - Updated line series.
2182    #[must_use]
2183    pub fn symbol(mut self, symbol: EuvChartSymbol, size: f32) -> Self {
2184        self.set_symbol(symbol);
2185        self.set_symbol_size(size);
2186        self
2187    }
2188
2189    /// Controls whether `None` gaps are bridged continuously.
2190    ///
2191    /// # Arguments
2192    ///
2193    /// - `Self` - Source line series.
2194    /// - `bool` - Connect-nulls flag.
2195    ///
2196    /// # Returns
2197    ///
2198    /// - `Self` - Updated line series.
2199    #[must_use]
2200    pub fn connect_nulls(mut self, connect: bool) -> Self {
2201        self.set_connect_nulls(connect);
2202        self
2203    }
2204
2205    /// Binds the series to a specific `(x_axis_index, y_axis_index)` pair.
2206    ///
2207    /// # Arguments
2208    ///
2209    /// - `Self` - Source line series.
2210    /// - `usize` - X axis index.
2211    /// - `usize` - Y axis index.
2212    ///
2213    /// # Returns
2214    ///
2215    /// - `Self` - Updated line series.
2216    #[must_use]
2217    pub fn axes(mut self, x_axis_index: usize, y_axis_index: usize) -> Self {
2218        self.set_x_axis_index(x_axis_index);
2219        self.set_y_axis_index(y_axis_index);
2220        self
2221    }
2222
2223    /// Binds this line series to a non-default coordinate system (e.g. `Polar`).
2224    ///
2225    /// # Arguments
2226    ///
2227    /// - `Self` - Source line series.
2228    /// - `EuvChartCoordinateSystem` - Target coordinate system.
2229    ///
2230    /// # Returns
2231    ///
2232    /// - `Self` - Updated line series.
2233    #[must_use]
2234    pub fn coordinate_system(mut self, coord: EuvChartCoordinateSystem) -> Self {
2235        self.set_coordinate_system(coord);
2236        self
2237    }
2238
2239    /// Attaches a `MarkPoint` annotation.
2240    ///
2241    /// # Arguments
2242    ///
2243    /// - `Self` - Source line series.
2244    /// - `EuvChartMarkPoint` - Mark point descriptor.
2245    ///
2246    /// # Returns
2247    ///
2248    /// - `Self` - Updated line series.
2249    #[must_use]
2250    pub fn mark_point(mut self, mark: EuvChartMarkPoint) -> Self {
2251        self.get_mut_annotations().get_mut_mark_points().push(mark);
2252        self
2253    }
2254
2255    /// Attaches a `MarkLine` annotation.
2256    ///
2257    /// # Arguments
2258    ///
2259    /// - `Self` - Source line series.
2260    /// - `EuvChartMarkLine` - Mark line descriptor.
2261    ///
2262    /// # Returns
2263    ///
2264    /// - `Self` - Updated line series.
2265    #[must_use]
2266    pub fn mark_line(mut self, mark: EuvChartMarkLine) -> Self {
2267        self.get_mut_annotations().get_mut_mark_lines().push(mark);
2268        self
2269    }
2270
2271    /// Attaches a `MarkArea` annotation.
2272    ///
2273    /// # Arguments
2274    ///
2275    /// - `Self` - Source line series.
2276    /// - `EuvChartMarkArea` - Mark area descriptor.
2277    ///
2278    /// # Returns
2279    ///
2280    /// - `Self` - Updated line series.
2281    #[must_use]
2282    pub fn mark_area(mut self, mark: EuvChartMarkArea) -> Self {
2283        self.get_mut_annotations().get_mut_mark_areas().push(mark);
2284        self
2285    }
2286
2287    /// Attaches a `Dataset` column encoding mapping.
2288    ///
2289    /// # Arguments
2290    ///
2291    /// - `Self` - Source line series.
2292    /// - `EuvChartEncode` - Column mapping.
2293    ///
2294    /// # Returns
2295    ///
2296    /// - `Self` - Updated line series.
2297    #[must_use]
2298    pub fn encode(mut self, encode: EuvChartEncode) -> Self {
2299        self.set_encode(Some(encode));
2300        self
2301    }
2302
2303    /// Returns the optional stack group identifier.
2304    ///
2305    /// # Arguments
2306    ///
2307    /// - `&Self` - Line series.
2308    ///
2309    /// # Returns
2310    ///
2311    /// - `Option<&str>` - Stack group key.
2312    #[must_use]
2313    pub fn stack_opt(&self) -> Option<&str> {
2314        let Self { stack, .. } = self;
2315        stack.as_deref()
2316    }
2317
2318    /// Returns the optional dataset encode mapping.
2319    ///
2320    /// # Arguments
2321    ///
2322    /// - `&Self` - Line series.
2323    ///
2324    /// # Returns
2325    ///
2326    /// - `Option<&EuvChartEncode>` - Dataset column mapping.
2327    #[must_use]
2328    pub fn encode_opt(&self) -> Option<&EuvChartEncode> {
2329        let Self { encode, .. } = self;
2330        encode.as_ref()
2331    }
2332}
2333
2334/// Fluent builders and accessors for `EuvChartBarSeries`.
2335impl EuvChartBarSeries {
2336    /// Creates a bar series from numeric values.
2337    ///
2338    /// # Arguments
2339    ///
2340    /// - `Vec<f32>` - Ordered bar magnitudes.
2341    ///
2342    /// # Returns
2343    ///
2344    /// - `Self` - Bar series.
2345    #[must_use]
2346    pub fn from_values(values: Vec<f32>) -> Self {
2347        let mut source_val: Self = Self::default();
2348        let mapped: Vec<Option<f32>> = values.into_iter().map(Some).collect();
2349        source_val.set_values(mapped);
2350        source_val
2351    }
2352
2353    /// Assigns a stack group key for stacked bars.
2354    ///
2355    /// # Arguments
2356    ///
2357    /// - `Self` - Source bar series.
2358    /// - `TextValue` - Stack group key.
2359    ///
2360    /// # Returns
2361    ///
2362    /// - `Self` - Updated bar series.
2363    #[must_use]
2364    pub fn stack<TextValue>(mut self, stack: TextValue) -> Self
2365    where
2366        TextValue: Into<String>,
2367    {
2368        self.set_stack(Some(stack.into()));
2369        self
2370    }
2371
2372    /// Sets the bar cap corner radius.
2373    ///
2374    /// # Arguments
2375    ///
2376    /// - `Self` - Source bar series.
2377    /// - `f32` - Corner radius in logical pixels.
2378    ///
2379    /// # Returns
2380    ///
2381    /// - `Self` - Updated bar series.
2382    #[must_use]
2383    pub fn bar_radius(mut self, radius: f32) -> Self {
2384        self.set_bar_radius(radius.max(0.0));
2385        self
2386    }
2387
2388    /// Enables subtle background tracks behind each bar.
2389    ///
2390    /// # Arguments
2391    ///
2392    /// - `Self` - Source bar series.
2393    /// - `bool` - Background track flag.
2394    ///
2395    /// # Returns
2396    ///
2397    /// - `Self` - Updated bar series.
2398    #[must_use]
2399    pub fn show_background(mut self, show: bool) -> Self {
2400        self.set_show_background(show);
2401        self
2402    }
2403
2404    /// Enables numeric value labels on bars.
2405    ///
2406    /// # Arguments
2407    ///
2408    /// - `Self` - Source bar series.
2409    /// - `bool` - Value label flag.
2410    ///
2411    /// # Returns
2412    ///
2413    /// - `Self` - Updated bar series.
2414    #[must_use]
2415    pub fn show_labels(mut self, show: bool) -> Self {
2416        self.set_show_labels(show);
2417        self
2418    }
2419
2420    /// Binds this bar series to a coordinate system (`Cartesian2d` or `Polar`).
2421    ///
2422    /// # Arguments
2423    ///
2424    /// - `Self` - Source bar series.
2425    /// - `EuvChartCoordinateSystem` - Coordinate system.
2426    ///
2427    /// # Returns
2428    ///
2429    /// - `Self` - Updated bar series.
2430    #[must_use]
2431    pub fn coordinate_system(mut self, coord: EuvChartCoordinateSystem) -> Self {
2432        self.set_coordinate_system(coord);
2433        self
2434    }
2435
2436    /// Binds the series to a specific `(x_axis_index, y_axis_index)` pair.
2437    ///
2438    /// # Arguments
2439    ///
2440    /// - `Self` - Source bar series.
2441    /// - `usize` - X axis index.
2442    /// - `usize` - Y axis index.
2443    ///
2444    /// # Returns
2445    ///
2446    /// - `Self` - Updated bar series.
2447    #[must_use]
2448    pub fn axes(mut self, x_axis_index: usize, y_axis_index: usize) -> Self {
2449        self.set_x_axis_index(x_axis_index);
2450        self.set_y_axis_index(y_axis_index);
2451        self
2452    }
2453
2454    /// Attaches a `MarkLine` annotation.
2455    ///
2456    /// # Arguments
2457    ///
2458    /// - `Self` - Source bar series.
2459    /// - `EuvChartMarkLine` - Mark line descriptor.
2460    ///
2461    /// # Returns
2462    ///
2463    /// - `Self` - Updated bar series.
2464    #[must_use]
2465    pub fn mark_line(mut self, mark: EuvChartMarkLine) -> Self {
2466        self.get_mut_annotations().get_mut_mark_lines().push(mark);
2467        self
2468    }
2469
2470    /// Attaches a `Dataset` encode mapping.
2471    ///
2472    /// # Arguments
2473    ///
2474    /// - `Self` - Source bar series.
2475    /// - `EuvChartEncode` - Column mapping.
2476    ///
2477    /// # Returns
2478    ///
2479    /// - `Self` - Updated bar series.
2480    #[must_use]
2481    pub fn encode(mut self, encode: EuvChartEncode) -> Self {
2482        self.set_encode(Some(encode));
2483        self
2484    }
2485
2486    /// Returns the optional stack group key.
2487    ///
2488    /// # Arguments
2489    ///
2490    /// - `&Self` - Bar series.
2491    ///
2492    /// # Returns
2493    ///
2494    /// - `Option<&str>` - Stack group key.
2495    #[must_use]
2496    pub fn stack_opt(&self) -> Option<&str> {
2497        let Self { stack, .. } = self;
2498        stack.as_deref()
2499    }
2500
2501    /// Returns the optional dataset encode mapping.
2502    ///
2503    /// # Arguments
2504    ///
2505    /// - `&Self` - Bar series.
2506    ///
2507    /// # Returns
2508    ///
2509    /// - `Option<&EuvChartEncode>` - Dataset column mapping.
2510    #[must_use]
2511    pub fn encode_opt(&self) -> Option<&EuvChartEncode> {
2512        let Self { encode, .. } = self;
2513        encode.as_ref()
2514    }
2515}
2516
2517/// Constructors and accessors for `EuvChartPieSlice` and `EuvChartPieSeries`.
2518impl EuvChartPieSlice {
2519    /// Creates a labeled pie slice.
2520    ///
2521    /// # Arguments
2522    ///
2523    /// - `TextValue` - Slice label.
2524    /// - `f32` - Positive numeric weight.
2525    ///
2526    /// # Returns
2527    ///
2528    /// - `Self` - Pie slice.
2529    #[must_use]
2530    pub fn new<TextValue>(name: TextValue, value: f32) -> Self
2531    where
2532        TextValue: Into<String>,
2533    {
2534        Self {
2535            name: name.into(),
2536            value,
2537            color: None,
2538            selected: false,
2539        }
2540    }
2541
2542    /// Sets an explicit fill color for this slice.
2543    ///
2544    /// # Arguments
2545    ///
2546    /// - `Self` - Source slice.
2547    /// - `Color` - Fill color.
2548    ///
2549    /// # Returns
2550    ///
2551    /// - `Self` - Updated slice.
2552    #[must_use]
2553    pub fn color(mut self, color: Color) -> Self {
2554        self.set_color(Some(color));
2555        self
2556    }
2557
2558    /// Marks this slice as popped out radially.
2559    ///
2560    /// # Arguments
2561    ///
2562    /// - `Self` - Source slice.
2563    /// - `bool` - Selected pop-out state.
2564    ///
2565    /// # Returns
2566    ///
2567    /// - `Self` - Updated slice.
2568    #[must_use]
2569    pub fn selected(mut self, selected: bool) -> Self {
2570        self.set_selected(selected);
2571        self
2572    }
2573
2574    /// Returns the optional explicit slice color.
2575    ///
2576    /// # Arguments
2577    ///
2578    /// - `&Self` - Source slice.
2579    ///
2580    /// # Returns
2581    ///
2582    /// - `Option<Color>` - Explicit fill color.
2583    #[must_use]
2584    pub fn color_opt(&self) -> Option<Color> {
2585        let Self { color, .. } = *self;
2586        color
2587    }
2588}
2589
2590/// Fluent builders for `EuvChartPieSeries`.
2591impl EuvChartPieSeries {
2592    /// Creates a pie series from slices.
2593    ///
2594    /// # Arguments
2595    ///
2596    /// - `Vec<EuvChartPieSlice>` - Ordered pie slices.
2597    ///
2598    /// # Returns
2599    ///
2600    /// - `Self` - Pie series.
2601    #[must_use]
2602    pub fn new(slices: Vec<EuvChartPieSlice>) -> Self {
2603        let mut source_val: Self = Self::default();
2604        source_val.set_slices(slices);
2605        source_val
2606    }
2607
2608    /// Converts the pie into a donut chart with the given inner cutout ratio.
2609    ///
2610    /// # Arguments
2611    ///
2612    /// - `Self` - Source pie series.
2613    /// - `f32` - Inner radius ratio in `[0.0, 0.85]`.
2614    ///
2615    /// # Returns
2616    ///
2617    /// - `Self` - Updated pie series.
2618    #[must_use]
2619    pub fn donut(mut self, inner_ratio: f32) -> Self {
2620        self.set_inner_radius_ratio(inner_ratio.clamp(0.0, 0.85));
2621        self
2622    }
2623
2624    /// Sets Nightingale Rose mode (`Radius` or `Area`).
2625    ///
2626    /// # Arguments
2627    ///
2628    /// - `Self` - Source pie series.
2629    /// - `EuvChartRoseType` - Rose variation mode.
2630    ///
2631    /// # Returns
2632    ///
2633    /// - `Self` - Updated pie series.
2634    #[must_use]
2635    pub fn rose(mut self, rose_type: EuvChartRoseType) -> Self {
2636        self.set_rose_type(rose_type);
2637        self
2638    }
2639
2640    /// Sets angular gap between adjacent wedges in degrees.
2641    ///
2642    /// # Arguments
2643    ///
2644    /// - `Self` - Source pie series.
2645    /// - `f32` - Pad angle in degrees.
2646    ///
2647    /// # Returns
2648    ///
2649    /// - `Self` - Updated pie series.
2650    #[must_use]
2651    pub fn pad_angle(mut self, deg: f32) -> Self {
2652        self.set_pad_angle_deg(deg.clamp(0.0, 15.0));
2653        self
2654    }
2655}
2656
2657/// Constructors and accessors for `EuvChartScatterPoint` and `EuvChartScatterSeries`.
2658impl EuvChartScatterPoint {
2659    /// Creates a 2D scatter point `(x, y)` using the series default size.
2660    ///
2661    /// # Arguments
2662    ///
2663    /// - `f32` - X coordinate.
2664    /// - `f32` - Y coordinate.
2665    ///
2666    /// # Returns
2667    ///
2668    /// - `Self` - Scatter point.
2669    #[must_use]
2670    pub fn new(pos_x: f32, pos_y: f32) -> Self {
2671        Self {
2672            x: pos_x,
2673            y: pos_y,
2674            size: 0.0,
2675            value: None,
2676            label: String::new(),
2677        }
2678    }
2679
2680    /// Sets an explicit bubble radius in logical pixels.
2681    ///
2682    /// # Arguments
2683    ///
2684    /// - `Self` - Source scatter point.
2685    /// - `f32` - Bubble radius.
2686    ///
2687    /// # Returns
2688    ///
2689    /// - `Self` - Updated scatter point.
2690    #[must_use]
2691    pub fn size(mut self, size: f32) -> Self {
2692        self.set_size(size);
2693        self
2694    }
2695
2696    /// Sets a scalar value for `VisualMap` coloring.
2697    ///
2698    /// # Arguments
2699    ///
2700    /// - `Self` - Source scatter point.
2701    /// - `f32` - Mapped numeric value.
2702    ///
2703    /// # Returns
2704    ///
2705    /// - `Self` - Updated scatter point.
2706    #[must_use]
2707    pub fn value(mut self, value: f32) -> Self {
2708        self.set_value(Some(value));
2709        self
2710    }
2711
2712    /// Sets a point caption label.
2713    ///
2714    /// # Arguments
2715    ///
2716    /// - `Self` - Source scatter point.
2717    /// - `TextValue` - Caption text.
2718    ///
2719    /// # Returns
2720    ///
2721    /// - `Self` - Updated scatter point.
2722    #[must_use]
2723    pub fn label<TextValue>(mut self, label: TextValue) -> Self
2724    where
2725        TextValue: Into<String>,
2726    {
2727        self.set_label(label.into());
2728        self
2729    }
2730
2731    /// Returns the optional visual-map scalar value.
2732    ///
2733    /// # Arguments
2734    ///
2735    /// - `&Self` - Source scatter point.
2736    ///
2737    /// # Returns
2738    ///
2739    /// - `Option<f32>` - Mapped numeric value.
2740    #[must_use]
2741    pub fn value_opt(&self) -> Option<f32> {
2742        let Self { value, .. } = *self;
2743        value
2744    }
2745}
2746
2747/// Fluent builders for `EuvChartScatterSeries`.
2748impl EuvChartScatterSeries {
2749    /// Creates a scatter series from `(x, y)` points.
2750    ///
2751    /// # Arguments
2752    ///
2753    /// - `Vec<EuvChartScatterPoint>` - Scatter points.
2754    ///
2755    /// # Returns
2756    ///
2757    /// - `Self` - Scatter series.
2758    #[must_use]
2759    pub fn new(points: Vec<EuvChartScatterPoint>) -> Self {
2760        let mut source_val: Self = Self::default();
2761        source_val.set_points(points);
2762        source_val
2763    }
2764
2765    /// Sets marker glyph shape and default radius.
2766    ///
2767    /// # Arguments
2768    ///
2769    /// - `Self` - Source scatter series.
2770    /// - `EuvChartSymbol` - Symbol shape.
2771    /// - `f32` - Default radius in logical pixels.
2772    ///
2773    /// # Returns
2774    ///
2775    /// - `Self` - Updated scatter series.
2776    #[must_use]
2777    pub fn symbol(mut self, symbol: EuvChartSymbol, size: f32) -> Self {
2778        self.set_symbol(symbol);
2779        self.set_default_size(size.max(1.0));
2780        self
2781    }
2782
2783    /// Binds this scatter series to a coordinate system (`Cartesian2d`, `Polar`, `SingleAxis`, or `Geo`).
2784    ///
2785    /// # Arguments
2786    ///
2787    /// - `Self` - Source scatter series.
2788    /// - `EuvChartCoordinateSystem` - Hosting coordinate system.
2789    ///
2790    /// # Returns
2791    ///
2792    /// - `Self` - Updated scatter series.
2793    #[must_use]
2794    pub fn coordinate_system(mut self, coord: EuvChartCoordinateSystem) -> Self {
2795        self.set_coordinate_system(coord);
2796        self
2797    }
2798
2799    /// Enables point caption labels.
2800    ///
2801    /// # Arguments
2802    ///
2803    /// - `Self` - Source scatter series.
2804    /// - `bool` - Label visibility flag.
2805    ///
2806    /// # Returns
2807    ///
2808    /// - `Self` - Updated scatter series.
2809    #[must_use]
2810    pub fn show_labels(mut self, show: bool) -> Self {
2811        self.set_show_labels(show);
2812        self
2813    }
2814
2815    /// Attaches a dataset column encoding mapping.
2816    ///
2817    /// # Arguments
2818    ///
2819    /// - `Self` - Source scatter series.
2820    /// - `EuvChartEncode` - Column mapping.
2821    ///
2822    /// # Returns
2823    ///
2824    /// - `Self` - Updated scatter series.
2825    #[must_use]
2826    pub fn encode(mut self, encode: EuvChartEncode) -> Self {
2827        self.set_encode(Some(encode));
2828        self
2829    }
2830
2831    /// Returns the optional dataset encode mapping.
2832    ///
2833    /// # Arguments
2834    ///
2835    /// - `&Self` - Source scatter series.
2836    ///
2837    /// # Returns
2838    ///
2839    /// - `Option<&EuvChartEncode>` - Dataset column mapping.
2840    #[must_use]
2841    pub fn encode_opt(&self) -> Option<&EuvChartEncode> {
2842        let Self { encode, .. } = self;
2843        encode.as_ref()
2844    }
2845}
2846
2847/// Constructors and accessors for `EuvChartRadarItem` and `EuvChartRadarSeries`.
2848impl EuvChartRadarItem {
2849    /// Creates a radar polygon record.
2850    ///
2851    /// # Arguments
2852    ///
2853    /// - `TextValue` - Item display name.
2854    /// - `Vec<f32>` - Values aligned to radar indicators.
2855    ///
2856    /// # Returns
2857    ///
2858    /// - `Self` - Radar item.
2859    #[must_use]
2860    pub fn new<TextValue>(name: TextValue, values: Vec<f32>) -> Self
2861    where
2862        TextValue: Into<String>,
2863    {
2864        Self {
2865            name: name.into(),
2866            values,
2867            color: None,
2868        }
2869    }
2870
2871    /// Sets an explicit polygon color.
2872    ///
2873    /// # Arguments
2874    ///
2875    /// - `Self` - Source radar item.
2876    /// - `Color` - Stroke and tint color.
2877    ///
2878    /// # Returns
2879    ///
2880    /// - `Self` - Updated radar item.
2881    #[must_use]
2882    pub fn color(mut self, color: Color) -> Self {
2883        self.set_color(Some(color));
2884        self
2885    }
2886
2887    /// Returns the optional explicit color.
2888    ///
2889    /// # Arguments
2890    ///
2891    /// - `&Self` - Source radar item.
2892    ///
2893    /// # Returns
2894    ///
2895    /// - `Option<Color>` - Explicit polygon color.
2896    #[must_use]
2897    pub fn color_opt(&self) -> Option<Color> {
2898        let Self { color, .. } = *self;
2899        color
2900    }
2901}
2902
2903/// Fluent constructors for `EuvChartRadarSeries`.
2904impl EuvChartRadarSeries {
2905    /// Creates a radar series from multivariate items.
2906    ///
2907    /// # Arguments
2908    ///
2909    /// - `Vec<EuvChartRadarItem>` - Radar polygon records.
2910    ///
2911    /// # Returns
2912    ///
2913    /// - `Self` - Radar series.
2914    #[must_use]
2915    pub fn new(items: Vec<EuvChartRadarItem>) -> Self {
2916        let mut source_val: Self = Self::default();
2917        source_val.set_items(items);
2918        source_val
2919    }
2920}
2921
2922/// Fluent builders and accessors for `EuvChartCandlestickSeries`.
2923impl EuvChartCandlestickSeries {
2924    /// Creates a candlestick series from OHLC records.
2925    ///
2926    /// # Arguments
2927    ///
2928    /// - `Vec<EuvChartOhlcPoint>` - Ordered OHLC candles.
2929    ///
2930    /// # Returns
2931    ///
2932    /// - `Self` - Candlestick series.
2933    #[must_use]
2934    pub fn new(candles: Vec<EuvChartOhlcPoint>) -> Self {
2935        let mut source_val: Self = Self::default();
2936        source_val.set_candles(candles);
2937        source_val
2938    }
2939
2940    /// Overrides the bullish and bearish candle fill colors.
2941    ///
2942    /// # Arguments
2943    ///
2944    /// - `Self` - Source candlestick series.
2945    /// - `Color` - Bullish color (`close >= open`).
2946    /// - `Color` - Bearish color (`close < open`).
2947    ///
2948    /// # Returns
2949    ///
2950    /// - `Self` - Updated candlestick series.
2951    #[must_use]
2952    pub fn colors(mut self, bull: Color, bear: Color) -> Self {
2953        self.set_bull_color(Some(bull));
2954        self.set_bear_color(Some(bear));
2955        self
2956    }
2957
2958    /// Returns the resolved bullish candle color.
2959    ///
2960    /// # Arguments
2961    ///
2962    /// - `&Self` - Candlestick series.
2963    ///
2964    /// # Returns
2965    ///
2966    /// - `Color` - Bullish fill color.
2967    #[must_use]
2968    pub fn resolved_bull_color(&self) -> Color {
2969        let Self { bull_color, .. } = *self;
2970        bull_color.unwrap_or_else(|| Color::hex(ECHART_CANDLE_BULL_HEX))
2971    }
2972
2973    /// Returns the resolved bearish candle color.
2974    ///
2975    /// # Arguments
2976    ///
2977    /// - `&Self` - Candlestick series.
2978    ///
2979    /// # Returns
2980    ///
2981    /// - `Color` - Bearish fill color.
2982    #[must_use]
2983    pub fn resolved_bear_color(&self) -> Color {
2984        let Self { bear_color, .. } = *self;
2985        bear_color.unwrap_or_else(|| Color::hex(ECHART_CANDLE_BEAR_HEX))
2986    }
2987}
2988
2989/// Constructors for `EuvChartBoxplotItem` and `EuvChartBoxplotSeries`.
2990impl EuvChartBoxplotItem {
2991    /// Creates a five-number boxplot summary without outliers.
2992    ///
2993    /// # Arguments
2994    ///
2995    /// - `f32` - Lower whisker minimum.
2996    /// - `f32` - First quartile.
2997    /// - `f32` - Median value.
2998    /// - `f32` - Third quartile.
2999    /// - `f32` - Upper whisker maximum.
3000    ///
3001    /// # Returns
3002    ///
3003    /// - `Self` - Boxplot summary item.
3004    #[must_use]
3005    pub fn new(min: f32, q1: f32, median: f32, q3: f32, max: f32) -> Self {
3006        Self {
3007            min,
3008            q1,
3009            median,
3010            q3,
3011            max,
3012            outliers: Vec::new(),
3013        }
3014    }
3015
3016    /// Attaches outlier scalar values plotted above/below the whiskers.
3017    ///
3018    /// # Arguments
3019    ///
3020    /// - `Self` - Source boxplot item.
3021    /// - `Vec<f32>` - Outlier observations.
3022    ///
3023    /// # Returns
3024    ///
3025    /// - `Self` - Updated boxplot item.
3026    #[must_use]
3027    pub fn outliers(mut self, outliers: Vec<f32>) -> Self {
3028        self.set_outliers(outliers);
3029        self
3030    }
3031}
3032
3033/// Constructors for `EuvChartBoxplotSeries`.
3034impl EuvChartBoxplotSeries {
3035    /// Creates a boxplot series from summary items.
3036    ///
3037    /// # Arguments
3038    ///
3039    /// - `Vec<EuvChartBoxplotItem>` - Ordered boxplot summaries.
3040    ///
3041    /// # Returns
3042    ///
3043    /// - `Self` - Boxplot series.
3044    #[must_use]
3045    pub fn new(items: Vec<EuvChartBoxplotItem>) -> Self {
3046        let mut source_val: Self = Self::default();
3047        source_val.set_items(items);
3048        source_val
3049    }
3050}
3051
3052/// Constructors for `EuvChartHeatmapCell` and `EuvChartHeatmapSeries`.
3053impl EuvChartHeatmapCell {
3054    /// Creates a heatmap cell at `(x_index, y_index)` with `value`.
3055    ///
3056    /// # Arguments
3057    ///
3058    /// - `usize` - Column index.
3059    /// - `usize` - Row index.
3060    /// - `f32` - Numeric intensity.
3061    ///
3062    /// # Returns
3063    ///
3064    /// - `Self` - Heatmap cell.
3065    #[must_use]
3066    pub fn new(x_index: usize, y_index: usize, value: f32) -> Self {
3067        Self {
3068            x_index,
3069            y_index,
3070            value,
3071            label: String::new(),
3072        }
3073    }
3074}
3075
3076/// Fluent constructors for `EuvChartHeatmapSeries`.
3077impl EuvChartHeatmapSeries {
3078    /// Creates a Cartesian matrix heatmap series.
3079    ///
3080    /// # Arguments
3081    ///
3082    /// - `Vec<EuvChartHeatmapCell>` - Matrix cells.
3083    ///
3084    /// # Returns
3085    ///
3086    /// - `Self` - Heatmap series.
3087    #[must_use]
3088    pub fn new(cells: Vec<EuvChartHeatmapCell>) -> Self {
3089        let mut source_val: Self = Self::default();
3090        source_val.set_cells(cells);
3091        source_val
3092    }
3093
3094    /// Binds this heatmap to `Calendar` or `Cartesian2d` coordinates.
3095    ///
3096    /// # Arguments
3097    ///
3098    /// - `Self` - Source heatmap series.
3099    /// - `EuvChartCoordinateSystem` - Coordinate system.
3100    ///
3101    /// # Returns
3102    ///
3103    /// - `Self` - Updated heatmap series.
3104    #[must_use]
3105    pub fn coordinate_system(mut self, coord: EuvChartCoordinateSystem) -> Self {
3106        self.set_coordinate_system(coord);
3107        self
3108    }
3109
3110    /// Toggles numeric cell value captions.
3111    ///
3112    /// # Arguments
3113    ///
3114    /// - `Self` - Source heatmap series.
3115    /// - `bool` - Cell label flag.
3116    ///
3117    /// # Returns
3118    ///
3119    /// - `Self` - Updated heatmap series.
3120    #[must_use]
3121    pub fn show_labels(mut self, show: bool) -> Self {
3122        self.set_show_labels(show);
3123        self
3124    }
3125}
3126
3127/// Constructors and recursive aggregation helpers for `EuvChartHierarchyNode`.
3128impl EuvChartHierarchyNode {
3129    /// Creates a leaf hierarchy node with numeric `value`.
3130    ///
3131    /// # Arguments
3132    ///
3133    /// - `TextValue` - Node display label.
3134    /// - `f32` - Positive numeric weight.
3135    ///
3136    /// # Returns
3137    ///
3138    /// - `Self` - Leaf node.
3139    #[must_use]
3140    pub fn leaf<TextValue>(name: TextValue, value: f32) -> Self
3141    where
3142        TextValue: Into<String>,
3143    {
3144        Self {
3145            name: name.into(),
3146            value,
3147            color: None,
3148            children: Vec::new(),
3149        }
3150    }
3151
3152    /// Creates a parent branch hierarchy node wrapping `children`.
3153    ///
3154    /// # Arguments
3155    ///
3156    /// - `TextValue` - Branch display label.
3157    /// - `Vec<Self>` - Nested child nodes.
3158    ///
3159    /// # Returns
3160    ///
3161    /// - `Self` - Branch node whose weight sums its children.
3162    #[must_use]
3163    pub fn branch<TextValue>(name: TextValue, children: Vec<Self>) -> Self
3164    where
3165        TextValue: Into<String>,
3166    {
3167        let total: f32 = children.iter().map(Self::total_value).sum();
3168        Self {
3169            name: name.into(),
3170            value: total,
3171            color: None,
3172            children,
3173        }
3174    }
3175
3176    /// Overrides the node tint color.
3177    ///
3178    /// # Arguments
3179    ///
3180    /// - `Self` - Source hierarchy node.
3181    /// - `Color` - Explicit node color.
3182    ///
3183    /// # Returns
3184    ///
3185    /// - `Self` - Updated hierarchy node.
3186    #[must_use]
3187    pub fn color(mut self, color: Color) -> Self {
3188        self.set_color(Some(color));
3189        self
3190    }
3191
3192    /// Returns the optional explicit color tint.
3193    ///
3194    /// # Arguments
3195    ///
3196    /// - `&Self` - Source hierarchy node.
3197    ///
3198    /// # Returns
3199    ///
3200    /// - `Option<Color>` - Explicit node color.
3201    #[must_use]
3202    pub fn color_opt(&self) -> Option<Color> {
3203        let Self { color, .. } = *self;
3204        color
3205    }
3206
3207    /// Computes total positive weight recursively for treemap and sunburst proportionality.
3208    ///
3209    /// # Arguments
3210    ///
3211    /// - `&Self` - Hierarchy node.
3212    ///
3213    /// # Returns
3214    ///
3215    /// - `f32` - Positive aggregated weight.
3216    #[must_use]
3217    pub fn total_value(&self) -> f32 {
3218        let children: &[Self] = self.get_children().as_slice();
3219        if children.is_empty() {
3220            self.get_value().max(0.0)
3221        } else {
3222            let sum: f32 = children.iter().map(Self::total_value).sum();
3223            sum.max(self.get_value().max(0.0))
3224        }
3225    }
3226
3227    /// Returns the maximum subtree depth (`1` for a leaf).
3228    ///
3229    /// # Arguments
3230    ///
3231    /// - `&Self` - Hierarchy node.
3232    ///
3233    /// # Returns
3234    ///
3235    /// - `usize` - Subtree depth.
3236    #[must_use]
3237    pub fn max_depth(&self) -> usize {
3238        let children: &[Self] = self.get_children().as_slice();
3239        if children.is_empty() {
3240            1
3241        } else {
3242            let deepest: usize = children.iter().map(Self::max_depth).max().unwrap_or(0);
3243            1 + deepest
3244        }
3245    }
3246}
3247
3248/// Constructors for `EuvChartTreemapSeries`, `EuvChartSunburstSeries`, `EuvChartSankeySeries`, `EuvChartFunnelSeries`, `EuvChartGaugeSeries`, `EuvChartGraphSeries`, `EuvChartTreeSeries`, `EuvChartParallelSeries`, `EuvChartLinesSeries`, `EuvChartThemeRiverSeries`, `EuvChartPictorialBarSeries`, `EuvChartCustomSeries`, and `EuvChartGeoMapSeries`.
3249impl EuvChartTreemapSeries {
3250    /// Creates a treemap series from top-level nodes.
3251    ///
3252    /// # Arguments
3253    ///
3254    /// - `Vec<EuvChartHierarchyNode>` - Top-level hierarchy nodes.
3255    ///
3256    /// # Returns
3257    ///
3258    /// - `Self` - Treemap series.
3259    #[must_use]
3260    pub fn new(nodes: Vec<EuvChartHierarchyNode>) -> Self {
3261        let mut source_val: Self = Self::default();
3262        source_val.set_nodes(nodes);
3263        source_val
3264    }
3265}
3266
3267/// Constructors for `EuvChartSunburstSeries`.
3268impl EuvChartSunburstSeries {
3269    /// Creates a sunburst series from top-level nodes.
3270    ///
3271    /// # Arguments
3272    ///
3273    /// - `Vec<EuvChartHierarchyNode>` - Top-level hierarchy nodes.
3274    ///
3275    /// # Returns
3276    ///
3277    /// - `Self` - Sunburst series.
3278    #[must_use]
3279    pub fn new(nodes: Vec<EuvChartHierarchyNode>) -> Self {
3280        let mut source_val: Self = Self::default();
3281        source_val.set_nodes(nodes);
3282        source_val
3283    }
3284}
3285
3286/// Constructors and accessors for `EuvChartSankeyNode` and `EuvChartSankeySeries`.
3287impl EuvChartSankeyNode {
3288    /// Creates a named Sankey node.
3289    ///
3290    /// # Arguments
3291    ///
3292    /// - `TextValue` - Node identifier name.
3293    ///
3294    /// # Returns
3295    ///
3296    /// - `Self` - Sankey node.
3297    #[must_use]
3298    pub fn new<TextValue>(name: TextValue) -> Self
3299    where
3300        TextValue: Into<String>,
3301    {
3302        Self {
3303            name: name.into(),
3304            color: None,
3305            depth: None,
3306        }
3307    }
3308
3309    /// Overrides the node fill color.
3310    ///
3311    /// # Arguments
3312    ///
3313    /// - `Self` - Source node.
3314    /// - `Color` - Fill color.
3315    ///
3316    /// # Returns
3317    ///
3318    /// - `Self` - Updated node.
3319    #[must_use]
3320    pub fn color(mut self, color: Color) -> Self {
3321        self.set_color(Some(color));
3322        self
3323    }
3324
3325    /// Returns the optional explicit node color.
3326    ///
3327    /// # Arguments
3328    ///
3329    /// - `&Self` - Source node.
3330    ///
3331    /// # Returns
3332    ///
3333    /// - `Option<Color>` - Explicit node color.
3334    #[must_use]
3335    pub fn color_opt(&self) -> Option<Color> {
3336        let Self { color, .. } = *self;
3337        color
3338    }
3339
3340    /// Returns the optional explicit column depth.
3341    ///
3342    /// # Arguments
3343    ///
3344    /// - `&Self` - Source node.
3345    ///
3346    /// # Returns
3347    ///
3348    /// - `Option<usize>` - Explicit column depth.
3349    #[must_use]
3350    pub fn depth_opt(&self) -> Option<usize> {
3351        let Self { depth, .. } = *self;
3352        depth
3353    }
3354}
3355
3356/// Constructors for `EuvChartSankeySeries`.
3357impl EuvChartSankeySeries {
3358    /// Creates a Sankey diagram from nodes and weighted links.
3359    ///
3360    /// # Arguments
3361    ///
3362    /// - `Vec<EuvChartSankeyNode>` - Sankey nodes.
3363    /// - `Vec<EuvChartSankeyLink>` - Weighted flow links.
3364    ///
3365    /// # Returns
3366    ///
3367    /// - `Self` - Sankey series.
3368    #[must_use]
3369    pub fn new(nodes: Vec<EuvChartSankeyNode>, links: Vec<EuvChartSankeyLink>) -> Self {
3370        let mut source_val: Self = Self::default();
3371        source_val.set_nodes(nodes);
3372        source_val.set_links(links);
3373        source_val
3374    }
3375}
3376
3377/// Constructors and accessors for `EuvChartFunnelStage` and `EuvChartFunnelSeries`.
3378impl EuvChartFunnelStage {
3379    /// Creates a conversion funnel stage.
3380    ///
3381    /// # Arguments
3382    ///
3383    /// - `TextValue` - Stage display name.
3384    /// - `f32` - Positive stage weight.
3385    ///
3386    /// # Returns
3387    ///
3388    /// - `Self` - Funnel stage.
3389    #[must_use]
3390    pub fn new<TextValue>(name: TextValue, value: f32) -> Self
3391    where
3392        TextValue: Into<String>,
3393    {
3394        Self {
3395            name: name.into(),
3396            value,
3397            color: None,
3398        }
3399    }
3400
3401    /// Returns the optional explicit stage color.
3402    ///
3403    /// # Arguments
3404    ///
3405    /// - `&Self` - Source stage.
3406    ///
3407    /// # Returns
3408    ///
3409    /// - `Option<Color>` - Explicit stage color.
3410    #[must_use]
3411    pub fn color_opt(&self) -> Option<Color> {
3412        let Self { color, .. } = *self;
3413        color
3414    }
3415}
3416
3417/// Constructors for `EuvChartFunnelSeries`.
3418impl EuvChartFunnelSeries {
3419    /// Creates a funnel series from conversion stages.
3420    ///
3421    /// # Arguments
3422    ///
3423    /// - `Vec<EuvChartFunnelStage>` - Ordered conversion stages.
3424    ///
3425    /// # Returns
3426    ///
3427    /// - `Self` - Funnel series.
3428    #[must_use]
3429    pub fn new(stages: Vec<EuvChartFunnelStage>) -> Self {
3430        let mut source_val: Self = Self::default();
3431        source_val.set_stages(stages);
3432        source_val
3433    }
3434
3435    /// Sets vertical funnel sorting order.
3436    ///
3437    /// # Arguments
3438    ///
3439    /// - `Self` - Source funnel series.
3440    /// - `EuvChartFunnelSort` - Sorting mode.
3441    ///
3442    /// # Returns
3443    ///
3444    /// - `Self` - Updated funnel series.
3445    #[must_use]
3446    pub fn sort(mut self, sort: EuvChartFunnelSort) -> Self {
3447        self.set_sort(sort);
3448        self
3449    }
3450}
3451
3452/// Fluent constructors for `EuvChartGaugeSeries`.
3453impl EuvChartGaugeSeries {
3454    /// Creates a gauge reading `value` over `[min, max]`.
3455    ///
3456    /// # Arguments
3457    ///
3458    /// - `f32` - Active numeric reading.
3459    /// - `f32` - Lower dial bound.
3460    /// - `f32` - Upper dial bound.
3461    ///
3462    /// # Returns
3463    ///
3464    /// - `Self` - Gauge series.
3465    #[must_use]
3466    pub fn new(value: f32, min: f32, max: f32) -> Self {
3467        let mut green_val: Self = Self::default();
3468        green_val.set_value(value);
3469        green_val.set_min(min);
3470        green_val.set_max(max);
3471        green_val
3472    }
3473
3474    /// Sets the center unit suffix string.
3475    ///
3476    /// # Arguments
3477    ///
3478    /// - `Self` - Source gauge.
3479    /// - `TextValue` - Unit text.
3480    ///
3481    /// # Returns
3482    ///
3483    /// - `Self` - Updated gauge.
3484    #[must_use]
3485    pub fn unit<TextValue>(mut self, unit: TextValue) -> Self
3486    where
3487        TextValue: Into<String>,
3488    {
3489        self.set_unit(unit.into());
3490        self
3491    }
3492
3493    /// Sets the dial caption title.
3494    ///
3495    /// # Arguments
3496    ///
3497    /// - `Self` - Source gauge.
3498    /// - `TextValue` - Caption text.
3499    ///
3500    /// # Returns
3501    ///
3502    /// - `Self` - Updated gauge.
3503    #[must_use]
3504    pub fn title<TextValue>(mut self, title: TextValue) -> Self
3505    where
3506        TextValue: Into<String>,
3507    {
3508        self.set_title(title.into());
3509        self
3510    }
3511
3512    /// Sets custom arc start and end angles in degrees.
3513    ///
3514    /// # Arguments
3515    ///
3516    /// - `Self` - Source gauge.
3517    /// - `f32` - Start angle in degrees.
3518    /// - `f32` - End angle in degrees.
3519    ///
3520    /// # Returns
3521    ///
3522    /// - `Self` - Updated gauge.
3523    #[must_use]
3524    pub fn angles(mut self, start_deg: f32, end_deg: f32) -> Self {
3525        self.set_start_angle_deg(start_deg);
3526        self.set_end_angle_deg(end_deg);
3527        self
3528    }
3529}
3530
3531/// Constructors and accessors for `EuvChartGraphNode`, `EuvChartGraphEdge`, and `EuvChartGraphSeries`.
3532impl EuvChartGraphNode {
3533    /// Creates a graph vertex with `id`, `name`, radius `size`, and `category`.
3534    ///
3535    /// # Arguments
3536    ///
3537    /// - `IdValue` - Unique node identifier.
3538    /// - `NameValue` - Display caption.
3539    /// - `f32` - Visual radius in logical pixels.
3540    /// - `usize` - Category index.
3541    ///
3542    /// # Returns
3543    ///
3544    /// - `Self` - Graph node.
3545    #[must_use]
3546    pub fn new<IdValue, NameValue>(id: IdValue, name: NameValue, size: f32, category: usize) -> Self
3547    where
3548        IdValue: Into<String>,
3549        NameValue: Into<String>,
3550    {
3551        Self {
3552            id: id.into(),
3553            name: name.into(),
3554            value: size,
3555            size: size.max(4.0),
3556            category,
3557            x: None,
3558            y: None,
3559            color: None,
3560        }
3561    }
3562
3563    /// Returns optional pre-assigned `(x, y)` normalized coordinates.
3564    ///
3565    /// # Arguments
3566    ///
3567    /// - `&Self` - Source graph node.
3568    ///
3569    /// # Returns
3570    ///
3571    /// - `(Option<f32>, Option<f32>)` - Optional preset position.
3572    #[must_use]
3573    pub fn pos_opt(&self) -> (Option<f32>, Option<f32>) {
3574        let Self {
3575            x: pos_x, y: pos_y, ..
3576        } = *self;
3577        (pos_x, pos_y)
3578    }
3579
3580    /// Returns optional explicit vertex color.
3581    ///
3582    /// # Arguments
3583    ///
3584    /// - `&Self` - Source graph node.
3585    ///
3586    /// # Returns
3587    ///
3588    /// - `Option<Color>` - Explicit node color.
3589    #[must_use]
3590    pub fn color_opt(&self) -> Option<Color> {
3591        let Self { color, .. } = *self;
3592        color
3593    }
3594}
3595
3596/// Constructors for `EuvChartGraphEdge`.
3597impl EuvChartGraphEdge {
3598    /// Creates an edge connecting `source` and `target`.
3599    ///
3600    /// # Arguments
3601    ///
3602    /// - `TextValue` - Source node id.
3603    /// - `ValueType` - Target node id.
3604    ///
3605    /// # Returns
3606    ///
3607    /// - `Self` - Graph edge.
3608    #[must_use]
3609    pub fn new<TextValue, ValueType>(source: TextValue, target: ValueType) -> Self
3610    where
3611        TextValue: Into<String>,
3612        ValueType: Into<String>,
3613    {
3614        Self {
3615            source: source.into(),
3616            target: target.into(),
3617            weight: 1.5,
3618            label: String::new(),
3619            curveness: 0.14,
3620        }
3621    }
3622
3623    /// Sets edge curve bow ratio (`0.0` = straight).
3624    ///
3625    /// # Arguments
3626    ///
3627    /// - `Self` - Source edge.
3628    /// - `f32` - Curveness ratio.
3629    ///
3630    /// # Returns
3631    ///
3632    /// - `Self` - Updated edge.
3633    #[must_use]
3634    pub fn curveness(mut self, curveness: f32) -> Self {
3635        self.set_curveness(curveness);
3636        self
3637    }
3638}
3639
3640/// Constructors for `EuvChartGraphSeries`.
3641impl EuvChartGraphSeries {
3642    /// Creates a network graph series from vertices and edges.
3643    ///
3644    /// # Arguments
3645    ///
3646    /// - `Vec<EuvChartGraphNode>` - Vertices.
3647    /// - `Vec<EuvChartGraphEdge>` - Edges.
3648    ///
3649    /// # Returns
3650    ///
3651    /// - `Self` - Graph series.
3652    #[must_use]
3653    pub fn new(nodes: Vec<EuvChartGraphNode>, edges: Vec<EuvChartGraphEdge>) -> Self {
3654        let mut source_val: Self = Self::default();
3655        source_val.set_nodes(nodes);
3656        source_val.set_edges(edges);
3657        source_val
3658    }
3659
3660    /// Selects the graph layout algorithm (`Force`, `Circular`, or `None`).
3661    ///
3662    /// # Arguments
3663    ///
3664    /// - `Self` - Source graph series.
3665    /// - `EuvChartGraphLayout` - Layout strategy.
3666    ///
3667    /// # Returns
3668    ///
3669    /// - `Self` - Updated graph series.
3670    #[must_use]
3671    pub fn layout(mut self, layout: EuvChartGraphLayout) -> Self {
3672        self.set_layout(layout);
3673        self
3674    }
3675}
3676
3677/// Constructors for `EuvChartTreeSeries`.
3678impl EuvChartTreeSeries {
3679    /// Creates a tree series rooted at `root`.
3680    ///
3681    /// # Arguments
3682    ///
3683    /// - `EuvChartHierarchyNode` - Tree root node.
3684    ///
3685    /// # Returns
3686    ///
3687    /// - `Self` - Tree series.
3688    #[must_use]
3689    pub fn new(root: EuvChartHierarchyNode) -> Self {
3690        let mut source_val: Self = Self::default();
3691        source_val.set_root(root);
3692        source_val
3693    }
3694
3695    /// Selects tree layout geometry (`OrthogonalLeftRight`, `OrthogonalTopBottom`, or `Radial`).
3696    ///
3697    /// # Arguments
3698    ///
3699    /// - `Self` - Source tree series.
3700    /// - `EuvChartTreeLayout` - Tree layout mode.
3701    ///
3702    /// # Returns
3703    ///
3704    /// - `Self` - Updated tree series.
3705    #[must_use]
3706    pub fn layout(mut self, layout: EuvChartTreeLayout) -> Self {
3707        self.set_layout(layout);
3708        self
3709    }
3710}
3711
3712/// Constructors and accessors for `EuvChartParallelAxis`, `EuvChartParallelRow`, and `EuvChartParallelSeries`.
3713impl EuvChartParallelAxis {
3714    /// Creates a numeric parallel dimension axis.
3715    ///
3716    /// # Arguments
3717    ///
3718    /// - `TextValue` - Dimension caption.
3719    ///
3720    /// # Returns
3721    ///
3722    /// - `Self` - Parallel axis.
3723    #[must_use]
3724    pub fn new<TextValue>(name: TextValue) -> Self
3725    where
3726        TextValue: Into<String>,
3727    {
3728        Self {
3729            name: name.into(),
3730            min: None,
3731            max: None,
3732            categories: Vec::new(),
3733        }
3734    }
3735
3736    /// Sets explicit lower and upper numeric bounds for this dimension.
3737    ///
3738    /// # Arguments
3739    ///
3740    /// - `Self` - Source parallel axis.
3741    /// - `f32` - Minimum bound.
3742    /// - `f32` - Maximum bound.
3743    ///
3744    /// # Returns
3745    ///
3746    /// - `Self` - Updated parallel axis.
3747    #[must_use]
3748    pub fn range(mut self, min: f32, max: f32) -> Self {
3749        self.set_min(Some(min));
3750        self.set_max(Some(max));
3751        self
3752    }
3753
3754    /// Returns optional `(min, max)` bounds.
3755    ///
3756    /// # Arguments
3757    ///
3758    /// - `&Self` - Source parallel axis.
3759    ///
3760    /// # Returns
3761    ///
3762    /// - `(Option<f32>, Option<f32>)` - Optional domain bounds.
3763    #[must_use]
3764    pub fn bounds_opt(&self) -> (Option<f32>, Option<f32>) {
3765        let Self { min, max, .. } = *self;
3766        (min, max)
3767    }
3768}
3769
3770/// Constructors and accessors for `EuvChartParallelRow`.
3771impl EuvChartParallelRow {
3772    /// Creates a parallel coordinates observation row.
3773    ///
3774    /// # Arguments
3775    ///
3776    /// - `TextValue` - Observation label.
3777    /// - `Vec<f32>` - Dimension values.
3778    /// - `usize` - Category index.
3779    ///
3780    /// # Returns
3781    ///
3782    /// - `Self` - Parallel row.
3783    #[must_use]
3784    pub fn new<TextValue>(name: TextValue, values: Vec<f32>, category: usize) -> Self
3785    where
3786        TextValue: Into<String>,
3787    {
3788        Self {
3789            name: name.into(),
3790            values,
3791            category,
3792            color: None,
3793        }
3794    }
3795
3796    /// Returns optional explicit stroke color.
3797    ///
3798    /// # Arguments
3799    ///
3800    /// - `&Self` - Source row.
3801    ///
3802    /// # Returns
3803    ///
3804    /// - `Option<Color>` - Explicit stroke color.
3805    #[must_use]
3806    pub fn color_opt(&self) -> Option<Color> {
3807        let Self { color, .. } = *self;
3808        color
3809    }
3810}
3811
3812/// Constructors for `EuvChartParallelSeries`.
3813impl EuvChartParallelSeries {
3814    /// Creates a parallel coordinates series from axes and observation rows.
3815    ///
3816    /// # Arguments
3817    ///
3818    /// - `Vec<EuvChartParallelAxis>` - Dimension axes.
3819    /// - `Vec<EuvChartParallelRow>` - Observation rows.
3820    ///
3821    /// # Returns
3822    ///
3823    /// - `Self` - Parallel series.
3824    #[must_use]
3825    pub fn new(axes: Vec<EuvChartParallelAxis>, rows: Vec<EuvChartParallelRow>) -> Self {
3826        let mut source_val: Self = Self::default();
3827        source_val.set_axes(axes);
3828        source_val.set_rows(rows);
3829        source_val
3830    }
3831}
3832
3833/// Constructors and accessors for `EuvChartFlowArc` and `EuvChartLinesSeries`.
3834impl EuvChartFlowArc {
3835    /// Creates a directed curved flow arc between `(from_x, from_y)` and `(to_x, to_y)`.
3836    ///
3837    /// # Arguments
3838    ///
3839    /// - `FirstText` - Origin label.
3840    /// - `LabelValue` - Destination label.
3841    /// - `(f32, f32)` - Origin `(x, y)` or `(lon, lat)`.
3842    /// - `(f32, f32)` - Destination `(x, y)` or `(lon, lat)`.
3843    /// - `f32` - Flow magnitude value.
3844    ///
3845    /// # Returns
3846    ///
3847    /// - `Self` - Flow arc descriptor.
3848    #[must_use]
3849    pub fn new<FirstText, LabelValue>(
3850        from_name: FirstText,
3851        to_name: LabelValue,
3852        from: (f32, f32),
3853        to: (f32, f32),
3854        value: f32,
3855    ) -> Self
3856    where
3857        FirstText: Into<String>,
3858        LabelValue: Into<String>,
3859    {
3860        Self {
3861            from_name: from_name.into(),
3862            to_name: to_name.into(),
3863            from_x: from.0,
3864            from_y: from.1,
3865            to_x: to.0,
3866            to_y: to.1,
3867            value,
3868            color: None,
3869        }
3870    }
3871
3872    /// Returns optional explicit arc color.
3873    ///
3874    /// # Arguments
3875    ///
3876    /// - `&Self` - Source flow arc.
3877    ///
3878    /// # Returns
3879    ///
3880    /// - `Option<Color>` - Explicit arc stroke color.
3881    #[must_use]
3882    pub fn color_opt(&self) -> Option<Color> {
3883        let Self { color, .. } = *self;
3884        color
3885    }
3886}
3887
3888/// Constructors for `EuvChartLinesSeries`.
3889impl EuvChartLinesSeries {
3890    /// Creates a curved directional lines series from arcs.
3891    ///
3892    /// # Arguments
3893    ///
3894    /// - `Vec<EuvChartFlowArc>` - Directed arcs.
3895    ///
3896    /// # Returns
3897    ///
3898    /// - `Self` - Lines series.
3899    #[must_use]
3900    pub fn new(arcs: Vec<EuvChartFlowArc>) -> Self {
3901        let mut source_val: Self = Self::default();
3902        source_val.set_arcs(arcs);
3903        source_val
3904    }
3905
3906    /// Binds this lines series to `Cartesian2d` or `Geo` coordinates.
3907    ///
3908    /// # Arguments
3909    ///
3910    /// - `Self` - Source lines series.
3911    /// - `EuvChartCoordinateSystem` - Coordinate system.
3912    ///
3913    /// # Returns
3914    ///
3915    /// - `Self` - Updated lines series.
3916    #[must_use]
3917    pub fn coordinate_system(mut self, coord: EuvChartCoordinateSystem) -> Self {
3918        self.set_coordinate_system(coord);
3919        self
3920    }
3921}
3922
3923/// Constructors for `EuvChartThemeRiverSeries`, `EuvChartPictorialBarSeries`, `EuvChartCustomSeries`, `EuvChartCustomDrawContext`, `EuvChartGeoDatum`, and `EuvChartGeoMapSeries`.
3924impl EuvChartThemeRiverSeries {
3925    /// Creates a ThemeRiver streamgraph from `(time, value, theme)` observations.
3926    ///
3927    /// # Arguments
3928    ///
3929    /// - `Vec<EuvChartThemeRiverPoint>` - Stream observations.
3930    ///
3931    /// # Returns
3932    ///
3933    /// - `Self` - ThemeRiver series.
3934    #[must_use]
3935    pub fn new(points: Vec<EuvChartThemeRiverPoint>) -> Self {
3936        let mut source_val: Self = Self::default();
3937        source_val.set_points(points);
3938        source_val
3939    }
3940}
3941
3942/// Constructors for `EuvChartPictorialBarSeries`.
3943impl EuvChartPictorialBarSeries {
3944    /// Creates a stacked symbol pictorial bar series.
3945    ///
3946    /// # Arguments
3947    ///
3948    /// - `Vec<f32>` - Category values.
3949    /// - `EuvChartSymbol` - Repeated glyph symbol.
3950    ///
3951    /// # Returns
3952    ///
3953    /// - `Self` - Pictorial bar series.
3954    #[must_use]
3955    pub fn new(values: Vec<f32>, symbol: EuvChartSymbol) -> Self {
3956        let mut source_val: Self = Self::default();
3957        source_val.set_values(values);
3958        source_val.set_symbol(symbol);
3959        source_val
3960    }
3961}
3962
3963/// Accessors for `EuvChartCustomDrawContext`.
3964impl EuvChartCustomDrawContext {
3965    /// Returns the active pointer coordinates when hovering the plot area.
3966    ///
3967    /// # Arguments
3968    ///
3969    /// - `&Self` - Draw context.
3970    ///
3971    /// # Returns
3972    ///
3973    /// - `Option<Point>` - Pointer coordinates.
3974    #[must_use]
3975    pub fn hover_pos_opt(&self) -> Option<Point> {
3976        let Self { hover_pos, .. } = *self;
3977        hover_pos
3978    }
3979}
3980
3981/// Constructors and accessors for `EuvChartCustomSeries`.
3982impl EuvChartCustomSeries {
3983    /// Creates a custom vector painter series.
3984    ///
3985    /// # Arguments
3986    ///
3987    /// - `Vec<f32>` - Numeric reference values used for auto-scaling.
3988    /// - `CallbackFn` - Custom `DrawCommand` painter closure.
3989    ///
3990    /// # Returns
3991    ///
3992    /// - `Self` - Custom series.
3993    #[must_use]
3994    pub fn new<CallbackFn>(values: Vec<f32>, painter: CallbackFn) -> Self
3995    where
3996        CallbackFn: Fn(Rect, &EuvChartCustomDrawContext, &mut DisplayList) + 'static,
3997    {
3998        let mut source_val: Self = Self::default();
3999        source_val.set_values(values);
4000        source_val.set_painter(Some(Rc::new(painter)));
4001        source_val
4002    }
4003
4004    /// Returns the optional custom painter handle.
4005    ///
4006    /// # Arguments
4007    ///
4008    /// - `&Self` - Custom series.
4009    ///
4010    /// # Returns
4011    ///
4012    /// - `Option<EuvChartCustomPainter>` - Cloned painter handle.
4013    #[must_use]
4014    pub fn painter_opt(&self) -> Option<EuvChartCustomPainter> {
4015        let Self { painter, .. } = self;
4016        painter.clone()
4017    }
4018}
4019
4020/// Constructors and accessors for `EuvChartGeoDatum` and `EuvChartGeoMapSeries`.
4021impl EuvChartGeoDatum {
4022    /// Creates a region choropleth metric entry.
4023    ///
4024    /// # Arguments
4025    ///
4026    /// - `TextValue` - Region name.
4027    /// - `f32` - Numeric intensity.
4028    ///
4029    /// # Returns
4030    ///
4031    /// - `Self` - Geo datum.
4032    #[must_use]
4033    pub fn new<TextValue>(region_name: TextValue, value: f32) -> Self
4034    where
4035        TextValue: Into<String>,
4036    {
4037        Self {
4038            region_name: region_name.into(),
4039            value,
4040            color: None,
4041        }
4042    }
4043
4044    /// Returns optional explicit region color.
4045    ///
4046    /// # Arguments
4047    ///
4048    /// - `&Self` - Geo datum.
4049    ///
4050    /// # Returns
4051    ///
4052    /// - `Option<Color>` - Explicit fill color.
4053    #[must_use]
4054    pub fn color_opt(&self) -> Option<Color> {
4055        let Self { color, .. } = *self;
4056        color
4057    }
4058}
4059
4060/// Constructors for `EuvChartGeoMapSeries`.
4061impl EuvChartGeoMapSeries {
4062    /// Creates a geographic choropleth map series.
4063    ///
4064    /// # Arguments
4065    ///
4066    /// - `Vec<EuvChartGeoDatum>` - Region metric entries.
4067    ///
4068    /// # Returns
4069    ///
4070    /// - `Self` - GeoMap series.
4071    #[must_use]
4072    pub fn new(data: Vec<EuvChartGeoDatum>) -> Self {
4073        let mut source_val: Self = Self::default();
4074        source_val.set_data(data);
4075        source_val
4076    }
4077}
4078
4079/// Constructors and accessors for `EuvChartSeries`.
4080impl EuvChartSeries {
4081    /// Creates a visible named series wrapping `data`.
4082    ///
4083    /// # Arguments
4084    ///
4085    /// - `TextValue` - Legend and tooltip series name.
4086    /// - `EuvChartSeriesData` - Typed series payload.
4087    ///
4088    /// # Returns
4089    ///
4090    /// - `Self` - Named series entry.
4091    #[must_use]
4092    pub fn new<TextValue>(name: TextValue, data: EuvChartSeriesData) -> Self
4093    where
4094        TextValue: Into<String>,
4095    {
4096        Self {
4097            name: name.into(),
4098            color: None,
4099            visible: true,
4100            data,
4101        }
4102    }
4103
4104    /// Overrides the series color fluently.
4105    ///
4106    /// # Arguments
4107    ///
4108    /// - `Self` - Source series.
4109    /// - `Color` - Explicit tint color.
4110    ///
4111    /// # Returns
4112    ///
4113    /// - `Self` - Updated series.
4114    #[must_use]
4115    pub fn color(mut self, color: Color) -> Self {
4116        self.set_color(Some(color));
4117        self
4118    }
4119
4120    /// Sets initial series visibility.
4121    ///
4122    /// # Arguments
4123    ///
4124    /// - `Self` - Source series.
4125    /// - `bool` - Initial visibility flag.
4126    ///
4127    /// # Returns
4128    ///
4129    /// - `Self` - Updated series.
4130    #[must_use]
4131    pub fn visible(mut self, visible: bool) -> Self {
4132        self.set_visible(visible);
4133        self
4134    }
4135
4136    /// Returns the optional explicit series color.
4137    ///
4138    /// # Arguments
4139    ///
4140    /// - `&Self` - Source series.
4141    ///
4142    /// # Returns
4143    ///
4144    /// - `Option<Color>` - Explicit series color.
4145    #[must_use]
4146    pub fn color_opt(&self) -> Option<Color> {
4147        let Self { color, .. } = *self;
4148        color
4149    }
4150}
4151
4152/// Fluent declarative builders and safe option accessors for `EuvChartOption`.
4153impl EuvChartOption {
4154    /// Creates an empty declarative chart option ready for fluent chaining.
4155    ///
4156    /// # Returns
4157    ///
4158    /// - `Self` - Empty chart option.
4159    #[must_use]
4160    pub fn new() -> Self {
4161        Self::default()
4162    }
4163
4164    /// Sets the chart title block fluently.
4165    ///
4166    /// # Arguments
4167    ///
4168    /// - `Self` - Source chart option.
4169    /// - `EuvChartTitle` - Title configuration.
4170    ///
4171    /// # Returns
4172    ///
4173    /// - `Self` - Updated chart option.
4174    #[must_use]
4175    pub fn title(mut self, title: EuvChartTitle) -> Self {
4176        self.set_title(Some(title));
4177        self
4178    }
4179
4180    /// Sets the interactive legend configuration fluently.
4181    ///
4182    /// # Arguments
4183    ///
4184    /// - `Self` - Source chart option.
4185    /// - `EuvChartLegend` - Legend configuration.
4186    ///
4187    /// # Returns
4188    ///
4189    /// - `Self` - Updated chart option.
4190    #[must_use]
4191    pub fn legend(mut self, legend: EuvChartLegend) -> Self {
4192        self.set_legend(Some(legend));
4193        self
4194    }
4195
4196    /// Appends a Cartesian subplot grid fluently.
4197    ///
4198    /// # Arguments
4199    ///
4200    /// - `Self` - Source chart option.
4201    /// - `EuvChartGrid` - Subplot grid specification.
4202    ///
4203    /// # Returns
4204    ///
4205    /// - `Self` - Updated chart option.
4206    #[must_use]
4207    pub fn add_grid(mut self, grid: EuvChartGrid) -> Self {
4208        self.get_mut_grid().push(grid);
4209        self
4210    }
4211
4212    /// Appends an X axis fluently (supporting dual or multi-axis layouts).
4213    ///
4214    /// # Arguments
4215    ///
4216    /// - `Self` - Source chart option.
4217    /// - `EuvChartAxis` - X axis configuration.
4218    ///
4219    /// # Returns
4220    ///
4221    /// - `Self` - Updated chart option.
4222    #[must_use]
4223    pub fn x_axis(mut self, axis: EuvChartAxis) -> Self {
4224        self.get_mut_x_axes().push(axis);
4225        self
4226    }
4227
4228    /// Appends a Y axis fluently (supporting dual or multi-axis layouts).
4229    ///
4230    /// # Arguments
4231    ///
4232    /// - `Self` - Source chart option.
4233    /// - `EuvChartAxis` - Y axis configuration.
4234    ///
4235    /// # Returns
4236    ///
4237    /// - `Self` - Updated chart option.
4238    #[must_use]
4239    pub fn y_axis(mut self, axis: EuvChartAxis) -> Self {
4240        self.get_mut_y_axes().push(axis);
4241        self
4242    }
4243
4244    /// Sets the polar coordinate system fluently.
4245    ///
4246    /// # Arguments
4247    ///
4248    /// - `Self` - Source chart option.
4249    /// - `EuvChartPolar` - Polar coordinate configuration.
4250    ///
4251    /// # Returns
4252    ///
4253    /// - `Self` - Updated chart option.
4254    #[must_use]
4255    pub fn polar(mut self, polar: EuvChartPolar) -> Self {
4256        self.set_polar(Some(polar));
4257        self
4258    }
4259
4260    /// Sets the radar coordinate system fluently.
4261    ///
4262    /// # Arguments
4263    ///
4264    /// - `Self` - Source chart option.
4265    /// - `EuvChartRadar` - Radar coordinate configuration.
4266    ///
4267    /// # Returns
4268    ///
4269    /// - `Self` - Updated chart option.
4270    #[must_use]
4271    pub fn radar(mut self, radar: EuvChartRadar) -> Self {
4272        self.set_radar(Some(radar));
4273        self
4274    }
4275
4276    /// Sets the single-axis coordinate system fluently.
4277    ///
4278    /// # Arguments
4279    ///
4280    /// - `Self` - Source chart option.
4281    /// - `EuvChartSingleAxis` - Single-axis configuration.
4282    ///
4283    /// # Returns
4284    ///
4285    /// - `Self` - Updated chart option.
4286    #[must_use]
4287    pub fn single_axis(mut self, single_axis: EuvChartSingleAxis) -> Self {
4288        self.set_single_axis(Some(single_axis));
4289        self
4290    }
4291
4292    /// Sets the calendar coordinate system fluently.
4293    ///
4294    /// # Arguments
4295    ///
4296    /// - `Self` - Source chart option.
4297    /// - `EuvChartCalendar` - Calendar configuration.
4298    ///
4299    /// # Returns
4300    ///
4301    /// - `Self` - Updated chart option.
4302    #[must_use]
4303    pub fn calendar(mut self, calendar: EuvChartCalendar) -> Self {
4304        self.set_calendar(Some(calendar));
4305        self
4306    }
4307
4308    /// Sets the geographic coordinate system fluently.
4309    ///
4310    /// # Arguments
4311    ///
4312    /// - `Self` - Source chart option.
4313    /// - `EuvChartGeo` - Geo configuration.
4314    ///
4315    /// # Returns
4316    ///
4317    /// - `Self` - Updated chart option.
4318    #[must_use]
4319    pub fn geo(mut self, geo: EuvChartGeo) -> Self {
4320        self.set_geo(Some(geo));
4321        self
4322    }
4323
4324    /// Sets the interactive hover tooltip configuration fluently.
4325    ///
4326    /// # Arguments
4327    ///
4328    /// - `Self` - Source chart option.
4329    /// - `EuvChartTooltip` - Tooltip configuration.
4330    ///
4331    /// # Returns
4332    ///
4333    /// - `Self` - Updated chart option.
4334    #[must_use]
4335    pub fn tooltip(mut self, tooltip: EuvChartTooltip) -> Self {
4336        self.set_tooltip(Some(tooltip));
4337        self
4338    }
4339
4340    /// Appends a data-zoom controller (`Inside` or `Slider`) fluently.
4341    ///
4342    /// # Arguments
4343    ///
4344    /// - `Self` - Source chart option.
4345    /// - `EuvChartDataZoom` - Data-zoom controller.
4346    ///
4347    /// # Returns
4348    ///
4349    /// - `Self` - Updated chart option.
4350    #[must_use]
4351    pub fn data_zoom(mut self, zoom: EuvChartDataZoom) -> Self {
4352        self.get_mut_data_zoom().push(zoom);
4353        self
4354    }
4355
4356    /// Sets the continuous or piecewise visual-map controller fluently.
4357    ///
4358    /// # Arguments
4359    ///
4360    /// - `Self` - Source chart option.
4361    /// - `EuvChartVisualMap` - Visual-map configuration.
4362    ///
4363    /// # Returns
4364    ///
4365    /// - `Self` - Updated chart option.
4366    #[must_use]
4367    pub fn visual_map(mut self, visual_map: EuvChartVisualMap) -> Self {
4368        self.set_visual_map(Some(visual_map));
4369        self
4370    }
4371
4372    /// Sets the compact icon-only toolbox toolbar fluently.
4373    ///
4374    /// # Arguments
4375    ///
4376    /// - `Self` - Source chart option.
4377    /// - `EuvChartToolbox` - Toolbox configuration.
4378    ///
4379    /// # Returns
4380    ///
4381    /// - `Self` - Updated chart option.
4382    #[must_use]
4383    pub fn toolbox(mut self, toolbox: EuvChartToolbox) -> Self {
4384        self.set_toolbox(Some(toolbox));
4385        self
4386    }
4387
4388    /// Sets a shared tabular dataset fluently.
4389    ///
4390    /// # Arguments
4391    ///
4392    /// - `Self` - Source chart option.
4393    /// - `EuvChartDataset` - Shared dataset.
4394    ///
4395    /// # Returns
4396    ///
4397    /// - `Self` - Updated chart option.
4398    #[must_use]
4399    pub fn dataset(mut self, dataset: EuvChartDataset) -> Self {
4400        self.set_dataset(Some(dataset));
4401        self
4402    }
4403
4404    /// Overrides the categorical color palette fluently.
4405    ///
4406    /// # Arguments
4407    ///
4408    /// - `Self` - Source chart option.
4409    /// - `Vec<Color>` - Custom ordered palette colors.
4410    ///
4411    /// # Returns
4412    ///
4413    /// - `Self` - Updated chart option.
4414    #[must_use]
4415    pub fn color_palette(mut self, colors: Vec<Color>) -> Self {
4416        self.set_color_palette(Some(colors));
4417        self
4418    }
4419
4420    /// Appends a typed series fluently.
4421    ///
4422    /// # Arguments
4423    ///
4424    /// - `Self` - Source chart option.
4425    /// - `EuvChartSeries` - Named series entry.
4426    ///
4427    /// # Returns
4428    ///
4429    /// - `Self` - Updated chart option.
4430    #[must_use]
4431    pub fn add_series(mut self, series: EuvChartSeries) -> Self {
4432        self.get_mut_series().push(series);
4433        self
4434    }
4435
4436    /// Overrides the canvas background color fluently.
4437    ///
4438    /// # Arguments
4439    ///
4440    /// - `Self` - Source chart option.
4441    /// - `Color` - Explicit background color.
4442    ///
4443    /// # Returns
4444    ///
4445    /// - `Self` - Updated chart option.
4446    #[must_use]
4447    pub fn background(mut self, color: Color) -> Self {
4448        self.set_background(Some(color));
4449        self
4450    }
4451
4452    /// Resolves the active categorical color palette for `tokens`.
4453    ///
4454    /// # Arguments
4455    ///
4456    /// - `&Self` - Source chart option.
4457    /// - `ThemeTokens` - Active UI theme tokens.
4458    ///
4459    /// # Returns
4460    ///
4461    /// - `Vec<Color>` - Non-empty high-contrast categorical color palette.
4462    #[must_use]
4463    pub fn resolved_palette(&self, tokens: ThemeTokens) -> Vec<Color> {
4464        let Self { color_palette, .. } = self;
4465        if let Some(custom) = color_palette.as_ref()
4466            && !custom.is_empty()
4467        {
4468            return custom.clone();
4469        }
4470        let hexes: &[u32; 10] = match tokens.get_mode() {
4471            ThemeMode::Light => &ECHART_PALETTE_LIGHT,
4472            ThemeMode::Dark => &ECHART_PALETTE_DARK,
4473        };
4474        let mut out: Vec<Color> = Vec::with_capacity(hexes.len());
4475        for &hex in hexes.iter() {
4476            out.push(Color::hex(hex));
4477        }
4478        out
4479    }
4480
4481    /// Returns the optional chart title reference.
4482    ///
4483    /// # Arguments
4484    ///
4485    /// - `&Self` - Chart option.
4486    ///
4487    /// # Returns
4488    ///
4489    /// - `Option<&EuvChartTitle>` - Title configuration.
4490    #[must_use]
4491    pub fn title_opt(&self) -> Option<&EuvChartTitle> {
4492        let Self { title, .. } = self;
4493        title.as_ref()
4494    }
4495
4496    /// Returns a cloned chart option with its `title` cleared so host header chrome can render the title once without canvas duplication.
4497    ///
4498    /// # Arguments
4499    ///
4500    /// - `&Self` - Source chart option.
4501    ///
4502    /// # Returns
4503    ///
4504    /// - `Self` - Cloned option with `title` set to `None`.
4505    #[must_use]
4506    pub fn without_title(&self) -> Self {
4507        let mut copy: Self = self.clone();
4508        copy.set_title(None);
4509        copy
4510    }
4511
4512    /// Returns the optional legend reference.
4513    ///
4514    /// # Arguments
4515    ///
4516    /// - `&Self` - Chart option.
4517    ///
4518    /// # Returns
4519    ///
4520    /// - `Option<&EuvChartLegend>` - Legend configuration.
4521    #[must_use]
4522    pub fn legend_opt(&self) -> Option<&EuvChartLegend> {
4523        let Self { legend, .. } = self;
4524        legend.as_ref()
4525    }
4526
4527    /// Returns the optional polar coordinate system reference.
4528    ///
4529    /// # Arguments
4530    ///
4531    /// - `&Self` - Chart option.
4532    ///
4533    /// # Returns
4534    ///
4535    /// - `Option<&EuvChartPolar>` - Polar coordinate configuration.
4536    #[must_use]
4537    pub fn polar_opt(&self) -> Option<&EuvChartPolar> {
4538        let Self { polar, .. } = self;
4539        polar.as_ref()
4540    }
4541
4542    /// Returns the optional radar coordinate system reference.
4543    ///
4544    /// # Arguments
4545    ///
4546    /// - `&Self` - Chart option.
4547    ///
4548    /// # Returns
4549    ///
4550    /// - `Option<&EuvChartRadar>` - Radar coordinate configuration.
4551    #[must_use]
4552    pub fn radar_opt(&self) -> Option<&EuvChartRadar> {
4553        let Self { radar, .. } = self;
4554        radar.as_ref()
4555    }
4556
4557    /// Returns the optional single-axis coordinate system reference.
4558    ///
4559    /// # Arguments
4560    ///
4561    /// - `&Self` - Chart option.
4562    ///
4563    /// # Returns
4564    ///
4565    /// - `Option<&EuvChartSingleAxis>` - Single-axis configuration.
4566    #[must_use]
4567    pub fn single_axis_opt(&self) -> Option<&EuvChartSingleAxis> {
4568        let Self { single_axis, .. } = self;
4569        single_axis.as_ref()
4570    }
4571
4572    /// Returns the optional calendar coordinate system reference.
4573    ///
4574    /// # Arguments
4575    ///
4576    /// - `&Self` - Chart option.
4577    ///
4578    /// # Returns
4579    ///
4580    /// - `Option<&EuvChartCalendar>` - Calendar configuration.
4581    #[must_use]
4582    pub fn calendar_opt(&self) -> Option<&EuvChartCalendar> {
4583        let Self { calendar, .. } = self;
4584        calendar.as_ref()
4585    }
4586
4587    /// Returns the optional geographic coordinate system reference.
4588    ///
4589    /// # Arguments
4590    ///
4591    /// - `&Self` - Chart option.
4592    ///
4593    /// # Returns
4594    ///
4595    /// - `Option<&EuvChartGeo>` - Geo coordinate configuration.
4596    #[must_use]
4597    pub fn geo_opt(&self) -> Option<&EuvChartGeo> {
4598        let Self { geo, .. } = self;
4599        geo.as_ref()
4600    }
4601
4602    /// Returns the optional tooltip configuration reference.
4603    ///
4604    /// # Arguments
4605    ///
4606    /// - `&Self` - Chart option.
4607    ///
4608    /// # Returns
4609    ///
4610    /// - `Option<&EuvChartTooltip>` - Tooltip configuration.
4611    #[must_use]
4612    pub fn tooltip_opt(&self) -> Option<&EuvChartTooltip> {
4613        let Self { tooltip, .. } = self;
4614        tooltip.as_ref()
4615    }
4616
4617    /// Returns the optional visual-map configuration reference.
4618    ///
4619    /// # Arguments
4620    ///
4621    /// - `&Self` - Chart option.
4622    ///
4623    /// # Returns
4624    ///
4625    /// - `Option<&EuvChartVisualMap>` - Visual-map configuration.
4626    #[must_use]
4627    pub fn visual_map_opt(&self) -> Option<&EuvChartVisualMap> {
4628        let Self { visual_map, .. } = self;
4629        visual_map.as_ref()
4630    }
4631
4632    /// Returns the optional toolbox configuration reference.
4633    ///
4634    /// # Arguments
4635    ///
4636    /// - `&Self` - Chart option.
4637    ///
4638    /// # Returns
4639    ///
4640    /// - `Option<&EuvChartToolbox>` - Toolbox configuration.
4641    #[must_use]
4642    pub fn toolbox_opt(&self) -> Option<&EuvChartToolbox> {
4643        let Self { toolbox, .. } = self;
4644        toolbox.as_ref()
4645    }
4646
4647    /// Returns the optional shared dataset reference.
4648    ///
4649    /// # Arguments
4650    ///
4651    /// - `&Self` - Chart option.
4652    ///
4653    /// # Returns
4654    ///
4655    /// - `Option<&EuvChartDataset>` - Shared dataset.
4656    #[must_use]
4657    pub fn dataset_opt(&self) -> Option<&EuvChartDataset> {
4658        let Self { dataset, .. } = self;
4659        dataset.as_ref()
4660    }
4661
4662    /// Returns the optional explicit background color.
4663    ///
4664    /// # Arguments
4665    ///
4666    /// - `&Self` - Chart option.
4667    ///
4668    /// # Returns
4669    ///
4670    /// - `Option<Color>` - Explicit background color.
4671    #[must_use]
4672    pub fn background_opt(&self) -> Option<Color> {
4673        let Self { background, .. } = *self;
4674        background
4675    }
4676}