@automattic/charts 0.19.1 → 0.20.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -5,6 +5,10 @@ All notable changes to this project will be documented in this file.
5
5
  The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
6
6
  and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
7
 
8
+ ## [0.20.0] - 2025-07-23
9
+ ### Added
10
+ - Line Chart: Add documentation [#44410]
11
+
8
12
  ## [0.19.1] - 2025-07-22
9
13
  ### Changed
10
14
  - Removed dependency on jetpack-components [#44411]
@@ -304,6 +308,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
304
308
  - Fixed lints following ESLint rule changes for TS [#40584]
305
309
  - Fixing a bug in Chart storybook data. [#40640]
306
310
 
311
+ [0.20.0]: https://github.com/Automattic/charts/compare/v0.19.1...v0.20.0
307
312
  [0.19.1]: https://github.com/Automattic/charts/compare/v0.19.0...v0.19.1
308
313
  [0.19.0]: https://github.com/Automattic/charts/compare/v0.18.0...v0.19.0
309
314
  [0.18.0]: https://github.com/Automattic/charts/compare/v0.17.0...v0.18.0
@@ -0,0 +1,353 @@
1
+ # AI Documentation Guide for Automattic Charts
2
+
3
+ This guide provides instructions for AI agents to generate comprehensive documentation for chart components and features following the established patterns in `@automattic/charts`.
4
+
5
+ ## Documentation Structure Template
6
+
7
+ All chart documentation should follow this standardized structure:
8
+
9
+ ### 1. File Header & Imports
10
+
11
+ ```mdx
12
+ import { Meta, Canvas, Story, Source } from '@storybook/addon-docs/blocks';
13
+ import * as [FeatureName]Stories from './[feature-name].stories';
14
+
15
+ <Meta title="JS Packages/Charts/[Category]/[Component]/[Feature]" of={ [FeatureName]Stories } />
16
+ ```
17
+
18
+ ### 2. Title & Introduction
19
+
20
+ ```mdx
21
+ # [Component] [Feature Name]
22
+
23
+ Brief 1-2 sentence description of what this feature does and its primary use case.
24
+
25
+ <Canvas of={ [FeatureName]Stories.Default } />
26
+ ```
27
+
28
+ ### 3. Overview Section
29
+
30
+ Always include:
31
+
32
+ - High-level explanation of the feature
33
+ - Basic code example showing the compound component pattern
34
+ - Key concepts or terminology
35
+
36
+ ```mdx
37
+ ## Overview
38
+
39
+ The [Component] component supports [feature description], providing [benefits]:
40
+
41
+ <Source
42
+ language="jsx"
43
+ code={ `import { [Component] } from '@automattic/charts';
44
+
45
+ <[Component] data={ data }>
46
+ <[Component].[FeatureComponent]>
47
+ <[Component].[SubComponent]
48
+ [key-props]
49
+ />
50
+ </[Component].[FeatureComponent]>
51
+ </[Component]>` }
52
+
53
+ />
54
+ ```
55
+
56
+ ### 4. Basic Usage Section
57
+
58
+ ```mdx
59
+ ## Basic Usage
60
+
61
+ ### Basic [Feature Name]
62
+
63
+ Description of simplest implementation:
64
+
65
+ <Canvas of={ [FeatureName]Stories.Default } />
66
+
67
+ <Source language="jsx" code={ `[minimal-example]` } />
68
+
69
+ ### Required Props
70
+
71
+ - **`propName`**: Description of what this prop does
72
+ - **`anotherProp`**: Description
73
+
74
+ ### Optional Props
75
+
76
+ - **`optionalProp`**: Description and default behavior
77
+ - **`anotherOptional`**: Description
78
+ ```
79
+
80
+ ### 5. Feature Variations
81
+
82
+ Document all major variations with:
83
+
84
+ - Descriptive subsection title
85
+ - Canvas example
86
+ - Code snippet
87
+ - Explanation of when to use
88
+
89
+ ```mdx
90
+ ## [Feature] Types
91
+
92
+ ### [Variation Name] (Default/Primary)
93
+
94
+ Description of this variation:
95
+
96
+ <Canvas of={ [FeatureName]Stories.[VariationName] } />
97
+
98
+ ### [Another Variation]
99
+
100
+ Description and use case:
101
+
102
+ <Canvas of={ [FeatureName]Stories.[AnotherVariation] } />
103
+
104
+ <Source language="jsx" code={ `example-code` } />
105
+ ```
106
+
107
+ ### 6. Styling and Customization
108
+
109
+ ```mdx
110
+ ## Styling and Customization
111
+
112
+ ### Custom [Styling Aspect]
113
+
114
+ How to customize appearance:
115
+
116
+ <Canvas of={ [FeatureName]Stories.Styled } />
117
+
118
+ <Source language="jsx" code={ `styling-example` } />
119
+
120
+ ### Styling Options
121
+
122
+ The `styles` prop accepts the following nested objects:
123
+
124
+ #### `[styleCategory]`
125
+
126
+ Controls [what this category affects]:
127
+
128
+ - `property`: Description and possible values
129
+ - `anotherProperty`: Description
130
+
131
+ ### Theme Integration
132
+
133
+ Explanation of how feature integrates with chart themes.
134
+ ```
135
+
136
+ ### 7. Advanced Features
137
+
138
+ Document complex functionality:
139
+
140
+ ```mdx
141
+ ## Advanced Features
142
+
143
+ ### [Advanced Feature Name]
144
+
145
+ Explanation of complex functionality with examples.
146
+
147
+ ### [Another Advanced Feature]
148
+
149
+ More advanced usage patterns.
150
+ ```
151
+
152
+ ### 8. Accessibility Section
153
+
154
+ Always include accessibility information:
155
+
156
+ ```mdx
157
+ ## Accessibility
158
+
159
+ ### Keyboard Navigation
160
+
161
+ - Key interactions and behaviors
162
+
163
+ ### Screen Reader Support
164
+
165
+ - ARIA attributes and labels
166
+ - Any limitations or considerations
167
+
168
+ ### Focus Management
169
+
170
+ - Focus behavior and visual indicators
171
+ ```
172
+
173
+ ### 9. Browser Compatibility
174
+
175
+ Include any browser-specific considerations:
176
+
177
+ ```mdx
178
+ ## Browser Compatibility
179
+
180
+ ### [Browser Name] Considerations
181
+
182
+ Any browser-specific behaviors or workarounds.
183
+
184
+ ### [API/Feature] Support
185
+
186
+ Information about feature support and fallbacks.
187
+ ```
188
+
189
+ ### 10. API Reference
190
+
191
+ Comprehensive prop documentation:
192
+
193
+ ````mdx
194
+ ## API Reference
195
+
196
+ ### [Component].[SubComponent]
197
+
198
+ Description of the component.
199
+
200
+ **Props:**
201
+
202
+ - `children`: Description
203
+
204
+ ### [Component].[MainComponent]
205
+
206
+ Description of main component.
207
+
208
+ **Props:**
209
+ | Prop | Type | Default | Description |
210
+ | ---- | ---- | ------- | ----------- |
211
+ | `requiredProp` | `Type` | - | **Required.** Description |
212
+ | `optionalProp` | `Type \| Other` | `default` | Description |
213
+
214
+ ### [TypeName] Type
215
+
216
+ ```typescript
217
+ type TypeName = {
218
+ property: Type;
219
+ optional?: Type;
220
+ };
221
+ ```
222
+ ````
223
+
224
+ ````
225
+
226
+ ### 11. Migration
227
+ ```mdx
228
+ ## Migration from [Legacy/Previous API]
229
+ If applicable, provide migration examples:
230
+
231
+ <Source language="jsx" code={`
232
+ // Old API
233
+ [old-example]
234
+
235
+ // New API
236
+ [new-example]
237
+ `} />
238
+ ````
239
+
240
+ ## Content Guidelines
241
+
242
+ ### Writing Style
243
+
244
+ - **Be concise but comprehensive**: Each section should be thorough but not verbose
245
+ - **Use active voice**: "Annotations allow you to..." vs "You can use annotations to..."
246
+ - **Include practical examples**: Always show real code that users can copy-paste
247
+ - **Explain the "why"**: Don't just document what props do, explain when to use them
248
+
249
+ ### Code Examples
250
+
251
+ - **Always use realistic data**: Show complete, runnable examples
252
+ - **Follow TypeScript patterns**: Include proper typing in examples
253
+ - **Use consistent naming**: `data`, `dataPoint`, `sampleData` for chart data
254
+ - **Show progressive complexity**: Start simple, build up to advanced usage
255
+
256
+ ### Canvas Examples
257
+
258
+ - **Every major feature needs a visual**: Use `<Canvas of={ Story } />`
259
+ - **Order logically**: Default → Basic variations → Advanced → Custom
260
+ - **Keep stories focused**: Each story should demonstrate one clear concept
261
+
262
+ ### Props Documentation
263
+
264
+ - **Mark required props clearly**: Use bold "**Required.**" prefix
265
+ - **Include defaults**: Show what happens if prop is omitted
266
+ - **Type information**: Always include TypeScript types
267
+ - **Practical descriptions**: Explain impact and use cases, not just data types
268
+
269
+ ### Cross-References
270
+
271
+ - **Link to related documentation**: Reference other chart features when relevant
272
+ - **Reference external docs**: Link to third-party libraries (visx, etc.) when applicable
273
+
274
+ ## File Organization
275
+
276
+ ### File Naming
277
+
278
+ - Main docs: `[feature-name].docs.mdx`
279
+ - Stories: `[feature-name].stories.tsx`
280
+
281
+ ### Directory Structure
282
+
283
+ ```
284
+ src/components/[chart-type]/stories/
285
+ ├── [feature-name].docs.mdx
286
+ ├── [feature-name].stories.tsx
287
+ ```
288
+
289
+ ### Storybook Integration
290
+
291
+ - Use consistent story naming: `Default`, `Styled`, `Custom`, `[VariationType]`
292
+ - Group related stories logically in Storybook hierarchy
293
+ - Include descriptive story descriptions for context
294
+
295
+ ## Quality Checklist
296
+
297
+ Before considering documentation complete, verify:
298
+
299
+ ### Completeness
300
+
301
+ - [ ] All props documented with types and descriptions
302
+ - [ ] Visual examples for all major variations
303
+ - [ ] Code examples are complete and runnable
304
+ - [ ] Accessibility considerations covered
305
+ - [ ] Browser compatibility notes included
306
+
307
+ ### Accuracy
308
+
309
+ - [ ] Code examples match actual implementation
310
+ - [ ] Type definitions are current
311
+ - [ ] Examples use current API patterns
312
+
313
+ ### Usability
314
+
315
+ - [ ] Progressive complexity (simple → advanced)
316
+ - [ ] Clear section headings and navigation
317
+ - [ ] Practical use case examples
318
+ - [ ] Migration guidance where applicable
319
+
320
+ ### Standards Compliance
321
+
322
+ - [ ] Follows compound component patterns
323
+ - [ ] Uses established styling conventions
324
+ - [ ] Integrates with chart theming system
325
+ - [ ] Maintains accessibility standards
326
+
327
+ ## Using the Feature Documentation Template
328
+
329
+ AI agents should use the provided `feature-documentation.mdx.template` as a starting point for any new chart feature documentation:
330
+
331
+ 1. **Copy the template**: Start with `feature-documentation.mdx.template`
332
+ 2. **Replace all bracketed placeholders**: Fill in `[Component]`, `[FeatureName]`, `[feature-name]`, etc. with actual values
333
+ 3. **Follow the structure**: Keep all sections but adapt content to your specific feature
334
+ 4. **Remove irrelevant sections**: If your feature doesn't have certain capabilities (e.g., no interactive features), remove those sections
335
+ 5. **Add feature-specific sections**: Include additional sections if your feature has unique aspects not covered in the template
336
+
337
+ The template includes all the standard sections, proper MDX formatting, and placeholder text to guide content creation.
338
+
339
+ ## Example Analysis
340
+
341
+ The `annotation.docs.mdx` file exemplifies these patterns:
342
+
343
+ 1. **Clear structure**: Logical flow from basic to advanced
344
+ 2. **Visual examples**: Every feature variation has a Canvas example
345
+ 3. **Complete API docs**: Comprehensive prop tables with types
346
+ 4. **Practical guidance**: Real-world usage scenarios and best practices
347
+ 5. **Accessibility focus**: Dedicated section covering keyboard, screen reader, and focus behavior
348
+ 6. **Browser considerations**: Honest discussion of Safari limitations
349
+ 7. **Migration support**: Clear guidance for upgrading from legacy API
350
+
351
+ Follow this structure and level of detail for all chart component documentation to ensure consistency and usefulness across the entire charts library. Examples and stories are accessible through the Storybook UI, so they don't need to be listed in the documentation.
352
+
353
+ **Important**: When documenting performance considerations, only include optimizations and limitations that are actually implemented, documented, or evidenced in the codebase. Avoid general web development best practices unless they are specifically relevant and tested for the chart components.
@@ -0,0 +1,244 @@
1
+ import { Meta, Canvas, Story, Source } from '@storybook/addon-docs/blocks';
2
+ import * as [FeatureName]Stories from './[feature-name].stories';
3
+
4
+ <Meta title="JS Packages/Charts/[Category]/[Component]/[Feature]" of={ [FeatureName]Stories } />
5
+
6
+ # [Component] [Feature Name]
7
+
8
+ [Brief 1-2 sentence description of what this feature does and its primary use case.]
9
+
10
+ <Canvas of={ [FeatureName]Stories.Default } />
11
+
12
+ ## Overview
13
+
14
+ The [Component] component supports [feature description], providing [benefits and key capabilities]:
15
+
16
+ <Source
17
+ language="jsx"
18
+ code={ `import { [Component] } from '@automattic/charts';
19
+
20
+ <[Component] data={ data }>
21
+ <[Component].[FeatureComponent]>
22
+ <[Component].[SubComponent]
23
+ [key-required-props]
24
+ [key-optional-props]
25
+ />
26
+ </[Component].[FeatureComponent]>
27
+ </[Component]>` }
28
+ />
29
+
30
+ ## Basic Usage
31
+
32
+ ### Basic [Feature Name]
33
+
34
+ [Description of the simplest implementation and when to use it]:
35
+
36
+ <Canvas of={ [FeatureName]Stories.Default } />
37
+
38
+ <Source
39
+ language="jsx"
40
+ code={ `<[Component] data={data}>
41
+ <[Component].[FeatureComponent]>
42
+ <[Component].[SubComponent]
43
+ [minimal-props-example]
44
+ />
45
+ </[Component].[FeatureComponent]>
46
+ </[Component]>` }
47
+ />
48
+
49
+ ### Required Props
50
+
51
+ - **`[propName]`**: [Description of what this prop does and its purpose]
52
+ - **`[anotherRequiredProp]`**: [Description]
53
+
54
+ ### Optional Props
55
+
56
+ - **`[optionalProp]`**: [Description and default behavior]
57
+ - **`[anotherOptional]`**: [Description and use cases]
58
+
59
+ ## [Feature] Types
60
+
61
+ ### [Primary Type] (Default)
62
+
63
+ [Description of the default/primary variation and when to use it]:
64
+
65
+ <Canvas of={ [FeatureName]Stories.Default } />
66
+
67
+ ### [Variation Type]
68
+
69
+ [Description and specific use case for this variation]:
70
+
71
+ <Canvas of={ [FeatureName]Stories.[VariationName] } />
72
+
73
+ <Source
74
+ language="jsx"
75
+ code={ `<[Component].[SubComponent]
76
+ [variation-specific-props]
77
+ />` }
78
+ />
79
+
80
+ ### [Another Variation Type]
81
+
82
+ [Description and use case]:
83
+
84
+ <Canvas of={ [FeatureName]Stories.[AnotherVariation] } />
85
+
86
+ ### [Mixed/Combined Usage]
87
+
88
+ [If applicable, show how different variations work together]:
89
+
90
+ <Canvas of={ [FeatureName]Stories.Mixed } />
91
+
92
+ ## Styling and Customization
93
+
94
+ ### Custom [Styling Aspect]
95
+
96
+ [Explanation of how to customize appearance with examples]:
97
+
98
+ <Canvas of={ [FeatureName]Stories.Styled } />
99
+
100
+ <Source
101
+ language="jsx"
102
+ code={ `<[Component].[SubComponent]
103
+ [props]
104
+ styles={{
105
+ [styleCategory]: {
106
+ [property]: '[value]',
107
+ },
108
+ }}
109
+ />` }
110
+ />
111
+
112
+ ### Styling Options
113
+
114
+ The `styles` prop accepts the following nested objects[, based on [external library reference if applicable]]:
115
+
116
+ #### `[styleCategory]`
117
+
118
+ Controls [what this category affects]:
119
+
120
+ - `[property]`: [Description and possible values]
121
+ - `[anotherProperty]`: [Description]
122
+
123
+ #### `[anotherStyleCategory]`
124
+
125
+ Controls [what this affects]:
126
+
127
+ - `[property]`: [Description]
128
+
129
+ ### Theme Integration
130
+
131
+ [Explanation of how feature integrates with chart themes and any theme-specific styling].
132
+
133
+ ## Custom [Feature Name]
134
+
135
+ ### Custom [Aspect] Rendering
136
+
137
+ [Explanation of custom rendering capabilities]:
138
+
139
+ <Canvas of={ [FeatureName]Stories.Custom } />
140
+
141
+ <Source
142
+ language="jsx"
143
+ code={`[custom-implementation-example]`}
144
+ />
145
+
146
+ ### Interactive [Feature Name]
147
+
148
+ [If applicable, show interactive capabilities]:
149
+
150
+ <Source
151
+ language="jsx"
152
+ code={ `[interactive-example]` }
153
+ />
154
+
155
+ ## Advanced Features
156
+
157
+ ### [Advanced Feature Name]
158
+
159
+ [Explanation of complex functionality with practical examples].
160
+
161
+ ### [Another Advanced Feature]
162
+
163
+ [More advanced usage patterns and edge cases].
164
+
165
+ ## Accessibility
166
+
167
+ ### Keyboard Navigation
168
+
169
+ - [Key interactions and expected behaviors]
170
+ - [Navigation patterns]
171
+
172
+ ### Screen Reader Support
173
+
174
+ - [ARIA attributes and labels used]
175
+ - [Any limitations or considerations for screen readers]
176
+
177
+ ### Focus Management
178
+
179
+ - [Focus behavior and visual indicators]
180
+ - [Focus trapping or restoration if applicable]
181
+
182
+ ## Browser Compatibility
183
+
184
+ ### [Browser] Considerations
185
+
186
+ [Any browser-specific behaviors, workarounds, or limitations].
187
+
188
+ ### [API/Feature] Support
189
+
190
+ [Information about modern web API usage, polyfills, or fallback behavior].
191
+
192
+ ## API Reference
193
+
194
+ ### [Component].[FeatureComponent]
195
+
196
+ [Description of the container/wrapper component].
197
+
198
+ **Props:**
199
+
200
+ - `children`: [Description of expected children]
201
+
202
+ ### [Component].[SubComponent]
203
+
204
+ [Description of the main feature component].
205
+
206
+ **Props:**
207
+
208
+ | Prop | Type | Default | Description |
209
+ | ---- | ---- | ------- | ----------- |
210
+ | `[requiredProp]` | `[Type]` | - | **Required.** [Description] |
211
+ | `[optionalProp]` | `[Type] \| [AlternativeType]` | `[default]` | [Description] |
212
+ | `[anotherProp]` | `[ComplexType]` | - | [Description] |
213
+
214
+ ### [TypeName] Type
215
+
216
+ ```typescript
217
+ type [TypeName] = {
218
+ [property]: [Type];
219
+ [optionalProperty]?: [Type];
220
+ };
221
+ ```
222
+
223
+ ### [AnotherTypeName] Type
224
+
225
+ ```typescript
226
+ type [AnotherTypeName] = {
227
+ [property]: [Type];
228
+ };
229
+ ```
230
+
231
+ ## Migration from [Legacy API]
232
+
233
+ [If applicable, provide migration examples]:
234
+
235
+ <Source
236
+ language="jsx"
237
+ code={`// Old API (deprecated)
238
+ [legacy-example]
239
+
240
+ // New API
241
+ [new-api-example]
242
+ `} />
243
+
244
+ [Brief explanation of benefits of the new approach and any breaking changes to be aware of].
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@automattic/charts",
3
- "version": "0.19.1",
3
+ "version": "0.20.0",
4
4
  "description": "Display charts within Automattic products.",
5
5
  "homepage": "https://github.com/Automattic/jetpack/tree/HEAD/projects/js-packages/charts/#readme",
6
6
  "bugs": {