1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
//! [`PieChart`] root component.
use Callback;
use *;
use ;
use component_doc;
use crateChartKind;
use crate;
use crate::;
/// Show proportions of a single total when slice share matters more than precise comparison.
///
/// Configure slice values, optional labels, and radii on `PieChart`. Arc labels and
/// highlight behavior are controlled on the series and `arc_label` props — not ad-hoc CSS.
///
/// # When to use
///
/// - Market share, budget allocation, or status breakdowns with few segments (≤7).
/// - Donut layouts with a center KPI when the hole can host a summary metric.
/// - Highlight-on-hover when users explore slice contribution interactively.
///
/// # Usage
///
/// 1. Bind a [`Dataset`] with `label_field` and `value_field`, or pass inline `series` + category labels on `x_axis`.
/// 2. Set `inner_radius` for donut charts; use `children` for centered overlay text.
/// 3. Tune `arc_label` for formatted values; link to `charts-label` for location-aware formatters.
/// 4. Leave `skip_animation` unset to honor reduced-motion; arc sweep runs on enter otherwise.
/// 5. Wrap the chart in a native element with `data-testid` for E2E hooks.
///
/// # Best Practices
///
/// ## Do's
///
/// * Prefer donut + center label when one aggregate KPI anchors the card.
/// * Use `padding_angle` to separate thin slices for readability.
/// * Link to `charts-highlighting` for controlled cross-chart selection patterns.
///
/// ## Don'ts
///
/// * Do not use pie charts for precise value comparison — prefer [`crate::BarChart`].
/// * Do not overload a pie with more than ~7 slices; group the rest into "Other".
/// * Do not put `data-testid` on the component itself — wrap with a native element.
///
/// # Related previews
///
/// Cross-cutting UX: `charts-legend`, `charts-tooltip`, `charts-highlighting`, `charts-label`.
///
/// # Examples
///
/// ## Composition breakdown
/// Four-slice pie with formatted arc labels. `min_angle` hides labels on thin slices so
/// text does not collide — start here for standard share breakdowns.
/// <!-- preview -->
/// ```rust,ignore
/// use crate::PieChart;
/// use crate::preview::fixtures::{market_share_pie_slices, market_share_x_axis};
/// use crate::{ArcLabelMode, PieArcLabelConfig};
/// view! {
/// <div data-testid="pie-chart-preview">
/// <PieChart
/// series=vec![market_share_pie_slices()]
/// x_axis=vec![market_share_x_axis()]
/// arc_label=PieArcLabelConfig {
/// mode: Some(ArcLabelMode::FormattedValue),
/// min_angle: Some(15.0),
/// ..Default::default()
/// }
/// width=520.0
/// height=320.0
/// />
/// </div>
/// }
/// ```
///
/// ## Donut with padding
/// Donut layout with `inner_radius` and `padding_angle` between slices. Use when a center
/// KPI or icon will sit in the hole, or when thin slices need visual separation.
/// <!-- preview -->
/// ```rust,ignore
/// use crate::PieChart;
/// use crate::preview::fixtures::{market_share_pie_slices, market_share_x_axis};
/// view! {
/// <div data-testid="pie-chart-donut-preview">
/// <PieChart
/// series=vec![market_share_pie_slices()]
/// x_axis=vec![market_share_x_axis()]
/// inner_radius="45%".to_string()
/// padding_angle=2.0
/// width=520.0
/// height=320.0
/// />
/// </div>
/// }
/// ```
///
/// ## Center KPI label
/// Donut with centered overlay text in the hole via `children`. Pair with `inner_radius`
/// around 50–60% so the label has room without crowding arc labels.
/// <!-- preview -->
/// ```rust,ignore
/// use crate::PieChart;
/// use crate::preview::fixtures::{market_share_pie_slices, market_share_x_axis};
/// view! {
/// <div data-testid="pie-chart-center-preview">
/// <PieChart
/// series=vec![market_share_pie_slices()]
/// x_axis=vec![market_share_x_axis()]
/// inner_radius="55%".to_string()
/// width=520.0
/// height=320.0
/// >
/// <text
/// class="orb-pie-center-label"
/// x="50%"
/// y="50%"
/// text-anchor="middle"
/// dominant-baseline="central"
/// >
/// "72%"
/// </text>
/// </PieChart>
/// </div>
/// }
/// ```
///
/// ## Highlight on hover
/// `highlight_scope` fades non-hovered slices — see `charts-highlighting` for axis
/// crosshair patterns on cartesian charts.
/// <!-- preview -->
/// ```rust,ignore
/// use crate::PieChart;
/// use crate::preview::fixtures::{market_share_pie_slices, market_share_x_axis};
/// use crate::{FadeMode, HighlightMode, HighlightScope};
/// view! {
/// <div data-testid="pie-chart-highlight-preview">
/// <PieChart
/// series=vec![market_share_pie_slices()]
/// x_axis=vec![market_share_x_axis()]
/// highlight_scope=HighlightScope {
/// highlight: HighlightMode::Item,
/// fade: FadeMode::Global,
/// }
/// width=520.0
/// height=320.0
/// />
/// </div>
/// }
/// ```
]
inner_radius: String,
/// Outer radius (px number or percent string).
outer_radius: String,
/// Gap between slices in degrees.
padding_angle: f64,
/// Arc label configuration.
arc_label: ,
/// Highlight and fade scope.
highlight_scope: ,
/// Fired when a slice is clicked.
on_item_click: ,
/// Center label or custom overlay children.
children: ,
/// Optional CSS class.
class: ,
)