Skip to content

Commit 8eb947f

Browse files
authored
Charts: Document animation feature across all supported charts (#46326)
* Charts: Document animation feature across all supported charts - Update documentation guidelines and template with animation section - Add animation documentation to all chart types with animation support - Include animation prop in API reference docs for all applicable charts - Document radial wipe, rising, and stretching animation effects - Note accessibility support for prefers-reduced-motion * Charts: Add changelog
1 parent 6be6876 commit 8eb947f

File tree

18 files changed

+254
-0
lines changed

18 files changed

+254
-0
lines changed
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
Significance: patch
2+
Type: fixed
3+
4+
Charts: Add documentation and API references of animation feature.

projects/js-packages/charts/docs/ai-documentation-guide.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,23 @@ For the Theming Integration section, use the standardized format from the `featu
183183
- A code example showing how to wrap the chart in `GlobalChartsProvider` with a custom theme
184184

185185
See the template for the complete section structure.
186+
187+
## Animation
188+
189+
Only include this section if the chart component supports animation (check the implementation for an `animation` prop). If animation is not supported, remove this section entirely.
190+
191+
When documenting animation:
192+
193+
- Show the Animation story with a Canvas example
194+
- Include a basic code example with `animation={true}`
195+
- Document animation behavior in a bulleted list covering:
196+
- Opt-in nature (disabled by default)
197+
- Accessibility (respects `prefers-reduced-motion`)
198+
- Effect description (e.g., "radial wipe reveal effect")
199+
- Duration in milliseconds
200+
- Note that animation plays once on initial render and does not repeat
201+
202+
See the `feature-documentation.mdx.template` for the complete section structure.
186203
```
187204

188205
### 8. Advanced Usage
@@ -319,6 +336,7 @@ Before considering documentation complete, verify both main docs and API referen
319336
- [ ] Visual examples for all major variations in main docs
320337
- [ ] Code examples are complete and runnable in main docs
321338
- [ ] Accessibility considerations covered in main docs
339+
- [ ] Animation section included if chart supports animation (check for `animation` prop)
322340
- [ ] Browser compatibility notes included where relevant
323341
- [ ] Both documents created using appropriate templates
324342

projects/js-packages/charts/docs/feature-documentation.mdx.template

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,31 @@ Controls [what this affects]:
151151
</GlobalChartsProvider>` }
152152
/>
153153

154+
## Animation
155+
156+
[Only include this section if the chart component supports animation. Remove this section entirely if animation is not supported.]
157+
158+
The [Component] component supports an optional entry animation that creates a smooth reveal effect when the chart first renders:
159+
160+
<Canvas of={ [FeatureName]Stories.Animation } />
161+
162+
<Source
163+
language="tsx"
164+
code={ `<[Component]
165+
data={ data }
166+
animation={ true }
167+
/>` }
168+
/>
169+
170+
### Animation Behavior
171+
172+
- **Opt-in**: Animation is disabled by default and must be explicitly enabled with the `animation` prop
173+
- **Accessibility**: Automatically respects the user's `prefers-reduced-motion` system setting - animation will not play for users who prefer reduced motion
174+
- **Effect**: Creates a [describe the animation effect, e.g., "radial wipe reveal effect" for pie charts, or the specific animation type for the chart]
175+
- **Duration**: [Animation duration in milliseconds, e.g., "1000ms (1 second)"]
176+
177+
**Note**: The animation plays once when the chart initially renders and does not repeat.
178+
154179
## Custom [Feature Name]
155180

156181
### Custom [Aspect] Rendering

projects/js-packages/charts/src/charts/bar-chart/stories/index.api.mdx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ Main chart component with responsive behavior by default.
1919
| `orientation` | `'vertical' \| 'horizontal'` | `'vertical'` | Bar orientation |
2020
| `withTooltips` | `boolean` | `false` | Enable interactive tooltips |
2121
| `withPatterns` | `boolean` | `false` | Use pattern fills for accessibility |
22+
| `animation` | `boolean` | `false` | Enable entry animation on initial render. Vertical bars rise from the bottom; horizontal bars stretch from the left. Automatically respects user's `prefers-reduced-motion` system setting |
2223
| `showZeroValues` | `boolean` | `false` | Display zero values with minimum visual height |
2324
| `showLegend` | `boolean` | `false` | Display chart legend |
2425
| `legendOrientation` | `'horizontal' \| 'vertical'` | `'horizontal'` | Legend layout orientation |

projects/js-packages/charts/src/charts/bar-chart/stories/index.docs.mdx

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -554,3 +554,28 @@ Bar Charts integrate seamlessly with the chart theming system. The default theme
554554
<BarChart data={data} />
555555
</GlobalChartsProvider>` }
556556
/>
557+
558+
## Animation
559+
560+
The Bar Chart component supports an optional entry animation that creates a smooth reveal effect when the chart first renders:
561+
562+
<Canvas of={ BarChartStories.Animation } />
563+
564+
<Source
565+
language="tsx"
566+
code={ `<BarChart
567+
data={ data }
568+
width={ 800 }
569+
height={ 400 }
570+
animation={ true }
571+
/>` }
572+
/>
573+
574+
### Animation Behavior
575+
576+
- **Opt-in**: Animation is disabled by default and must be explicitly enabled with the `animation` prop
577+
- **Accessibility**: Automatically respects the user's `prefers-reduced-motion` system setting - animation will not play for users who prefer reduced motion
578+
- **Effect**: Creates a growing effect where bars scale from zero to their full size. Vertical bars rise from the bottom, while horizontal bars stretch from the left
579+
- **Duration**: 1000ms (1 second) with ease-out timing
580+
581+
**Note**: The animation plays once when the chart initially renders and does not repeat.

projects/js-packages/charts/src/charts/bar-list-chart/stories/index.api.mdx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ A horizontal bar chart component optimized for list-style data presentation.
1717
| `height` | `number` | `400` | Chart height in pixels |
1818
| `margin` | `ChartMargin` | `{ left: 0, right: 20, bottom: 0, top: 0 }` | Chart margins |
1919
| `withTooltips` | `boolean` | `false` | Enable interactive tooltips |
20+
| `animation` | `boolean` | `false` | Enable entry animation on initial render. Bars stretch from left to right. Automatically respects user's `prefers-reduced-motion` system setting |
2021
| `renderTooltip` | `Function` | - | Custom tooltip render function |
2122
| `options` | `BarListChartOptions` | `{}` | Chart configuration options |
2223

projects/js-packages/charts/src/charts/bar-list-chart/stories/index.docs.mdx

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -270,6 +270,29 @@ Bar List Charts integrate seamlessly with the chart theming system. The default
270270
</GlobalChartsProvider>` }
271271
/>
272272

273+
## Animation
274+
275+
The Bar List Chart component supports an optional entry animation that creates a smooth reveal effect when the chart first renders:
276+
277+
<Canvas of={ BarListChartStories.Animation } />
278+
279+
<Source
280+
language="tsx"
281+
code={ `<BarListChart
282+
data={ data }
283+
animation={ true }
284+
/>` }
285+
/>
286+
287+
### Animation Behavior
288+
289+
- **Opt-in**: Animation is disabled by default and must be explicitly enabled with the `animation` prop
290+
- **Accessibility**: Automatically respects the user's `prefers-reduced-motion` system setting - animation will not play for users who prefer reduced motion
291+
- **Effect**: Creates a stretching effect where bars grow from left to right, revealing the data progressively
292+
- **Duration**: 1000ms (1 second) with ease-out timing
293+
294+
**Note**: The animation plays once when the chart initially renders and does not repeat.
295+
273296
## Advanced Features
274297

275298
### Scale Configuration

projects/js-packages/charts/src/charts/conversion-funnel-chart/stories/index.api.mdx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ Main component for displaying conversion funnel visualizations.
1616
| `steps` | `FunnelStep[]` | - | **Required.** Array of funnel steps |
1717
| `changeIndicator` | `string` | - | Change indicator (e.g., "+2%", "-1.5%") |
1818
| `loading` | `boolean` | `false` | Whether the chart is in loading state |
19+
| `animation` | `boolean` | `false` | Enable entry animation on initial render. Funnel bars grow from bottom to full height. Automatically respects user's `prefers-reduced-motion` system setting |
1920
| `className` | `string` | - | Additional CSS class name |
2021
| `chartId` | `string` | - | Optional unique identifier for the chart |
2122
| `style` | `React.CSSProperties` | - | Custom styling for the chart container |

projects/js-packages/charts/src/charts/conversion-funnel-chart/stories/index.docs.mdx

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -262,6 +262,30 @@ Use the `style` prop or `className` prop for custom styling:
262262
/>` }
263263
/>
264264

265+
## Animation
266+
267+
The Conversion Funnel Chart component supports an optional entry animation that creates a smooth reveal effect when the chart first renders:
268+
269+
<Canvas of={ ConversionFunnelChartStories.Animation } />
270+
271+
<Source
272+
language="tsx"
273+
code={ `<ConversionFunnelChart
274+
mainRate={ 10.3 }
275+
steps={ funnelData }
276+
animation={ true }
277+
/>` }
278+
/>
279+
280+
### Animation Behavior
281+
282+
- **Opt-in**: Animation is disabled by default and must be explicitly enabled with the `animation` prop
283+
- **Accessibility**: Automatically respects the user's `prefers-reduced-motion` system setting - animation will not play for users who prefer reduced motion
284+
- **Effect**: Creates a rising effect where funnel bars grow from the bottom to their full height, revealing the conversion data progressively
285+
- **Duration**: 1000ms (1 second) with ease-out timing
286+
287+
**Note**: The animation plays once when the chart initially renders and does not repeat.
288+
265289
## Use Cases and Examples
266290

267291
### E-commerce Conversion Funnel

projects/js-packages/charts/src/charts/leaderboard-chart/stories/index.api.mdx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ Main chart component for displaying ranked data with optional comparison values.
2020
| `valueFormatter` | `(value: number) => string` | `defaultValueFormatter` | Custom formatter for values |
2121
| `deltaFormatter` | `(value: number) => string` | `defaultDeltaFormatter` | Custom formatter for delta values |
2222
| `loading` | `boolean` | `false` | Whether the chart is in loading state |
23+
| `animation` | `boolean` | `false` | Enable entry animation on initial render. Bars stretch from left to right. Automatically respects user's `prefers-reduced-motion` system setting |
2324
| `showLegend` | `boolean` | `false` | Whether to display the legend |
2425
| `legendPosition` | `'top' \| 'bottom'` | `'bottom'` | Position of the legend |
2526
| `legendAlignment` | `'start' \| 'center' \| 'end'` | `'center'` | Alignment within position |

0 commit comments

Comments
 (0)