1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
//! Composition mode preview — mixed charts and custom SVG layers.
use *;
use component_doc;
use crate;
use crate;
/// Wrap your data definitions in a chart container, then stack plot, axis, and interaction components as children.
///
/// Explicit `chart_type` on each [`SeriesDef`] tells plot layers which geometry to render;
/// child order controls z-order (bars beneath lines, annotations on top).
///
/// # When to use
///
/// Build mixed-type dashboards by placing explicit plot children inside
/// [`ChartContainer`]. Each [`SeriesDef`] must declare `chart_type`; child
/// order controls z-order.
///
/// # Usage
///
/// 1. Place [`ChartContainer`] at the root with series, axes, and optional `dataset` binding.
/// 2. Add plot children (`BarPlot`, `LinePlot`, …) with required `chart_type` on each series.
/// 3. Wrap plots in [`PlotClip`] when marks extend past plot bounds.
/// 4. Add [`ChartCustomBaseline`] or custom SVG using scale hooks for annotations.
///
/// # Best Practices
///
/// ## Do's
///
/// * Place [`BarPlot`] before [`LinePlot`] when bars should sit beneath lines.
/// * Use unique clip path ids per chart instance (`orb-clip-*` prefix).
/// * Prefer [`ResponsiveChartContainer`] for dashboard tiles that fill parent width.
/// * Respect [`ChartCompositionOrder`]: first plot child inside [`PlotClip`] renders on the bottom.
///
/// ## Don'ts
///
/// * Do not omit `chart_type` on series in composition mode — inference is disabled.
/// * Do not mix composition and convenience `*Chart` wrappers on the same surface.
/// * Do not place legend or tooltip as composition children — configure them via container props.
///
/// # Examples
///
/// ## Mixed bar and line chart
/// Revenue bars with a target line overlay, clipped to the plot area. Demonstrates z-order,
/// mixed `chart_type` series, and [`PlotClip`] for overflow control.
/// <!-- preview -->
/// ```rust,ignore
/// use crate::ChartComposition;
/// use crate::preview::fixtures::{full_grid, mixed_bar_line_series, mixed_bar_line_x_axis, revenue_y_axis};
/// view! {
/// <div data-testid="chart-composition-preview">
/// <ChartComposition
/// variant=ChartCompositionVariant::MixedBarLine
/// series=mixed_bar_line_series()
/// x_axis=vec![mixed_bar_line_x_axis()]
/// y_axis=vec![revenue_y_axis()]
/// grid=full_grid()
/// width=560.0
/// height=320.0
/// />
/// </div>
/// }
/// ```
///
/// ## Custom SVG layer via hooks
/// Dashed revenue baseline using [`use_drawing_area`] and [`use_y_scale`]. Use when annotations
/// must stay aligned to data coordinates on resize.
/// <!-- preview -->
/// ```rust,ignore
/// use crate::ChartComposition;
/// use crate::preview::fixtures::{quarter_x_axis, revenue_series, revenue_y_axis};
/// view! {
/// <div data-testid="chart-composition-custom-layer-preview">
/// <ChartComposition
/// variant=ChartCompositionVariant::CustomLayer
/// series=vec![revenue_series()]
/// x_axis=vec![quarter_x_axis()]
/// y_axis=vec![revenue_y_axis()]
/// width=520.0
/// height=320.0
/// />
/// </div>
/// }
/// ```
]
series: ,
/// X-axis definitions.
x_axis: ,
/// Y-axis definitions.
y_axis: ,
/// Background grid configuration.
grid: crateGridConfig,
/// Chart width in pixels.
width: f64,
/// Chart height in pixels.
height: f64,
/// Optional CSS class on the root element.
class: ,
)
/// Composition preview variants.