-
Notifications
You must be signed in to change notification settings - Fork 839
Charts: Simplify PieSemiCircleChart API to use children composition #45369
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
annacmc
wants to merge
10
commits into
trunk
from
charts-65-iterate-over-pie-and-piesemicircle-composition
Closed
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
b08ca0d
Remove label and note props from PieSemiCircleChart
annacmc a898fbe
Update PieSemiCircleChart test to use children composition
annacmc 0fa5155
Update PieSemiCircleChart stories to use children composition
annacmc baf39ee
Update chart-context stories to use PieSemiCircleChart children
annacmc 21d2e47
changelog
annacmc 53bd7ec
Add migration examples to PieSemiCircleChart children prop docblock
annacmc e064744
Refactor PieSemiCircleChart tests to use renderPieChart helper
annacmc 1690e0d
Update PieSemiCircleChart docs to use composition API
annacmc 2156e22
Update PieSemiCircleChart API reference with compound components
annacmc e4c62be
Document breaking changes for WooCommerce Analytics consumers
annacmc File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,93 @@ | ||
| # Breaking Changes - PieSemiCircleChart | ||
|
|
||
| ## Summary | ||
|
|
||
| The `label` and `note` props have been removed from `PieSemiCircleChart` in favor of the more flexible composition API using the `children` prop. | ||
|
|
||
| ## Migration Guide | ||
|
|
||
| ### Before (Deprecated) | ||
| ```tsx | ||
| <PieSemiCircleChart | ||
| data={data} | ||
| width={400} | ||
| label="Operating Systems" | ||
| note="Windows +10%" | ||
| /> | ||
| ``` | ||
|
|
||
| ### After (New API) | ||
|
|
||
| **Option 1: Direct Group usage** | ||
| ```tsx | ||
| import { Group } from '@visx/group'; | ||
| import { Text } from '@visx/text'; | ||
|
|
||
| <PieSemiCircleChart | ||
| data={data} | ||
| width={400} | ||
| > | ||
| <Group> | ||
| <Text textAnchor="middle" y={-40} fontSize={16} fontWeight={600}> | ||
| Operating Systems | ||
| </Text> | ||
| <Text textAnchor="middle" y={-20} fontSize={14}> | ||
| Windows +10% | ||
| </Text> | ||
| </Group> | ||
| </PieSemiCircleChart> | ||
| ``` | ||
|
|
||
| **Option 2: Compound components (more explicit)** | ||
| ```tsx | ||
| import { Group } from '@visx/group'; | ||
| import { Text } from '@visx/text'; | ||
|
|
||
| <PieSemiCircleChart | ||
| data={data} | ||
| width={400} | ||
| > | ||
| <PieSemiCircleChart.SVG> | ||
| <Group> | ||
| <Text textAnchor="middle" y={-40} fontSize={16} fontWeight={600}> | ||
| Operating Systems | ||
| </Text> | ||
| <Text textAnchor="middle" y={-20} fontSize={14}> | ||
| Windows +10% | ||
| </Text> | ||
| </Group> | ||
| </PieSemiCircleChart.SVG> | ||
| </PieSemiCircleChart> | ||
| ``` | ||
|
|
||
| ## Affected Consumer Files | ||
|
|
||
| ### WooCommerce Analytics | ||
|
|
||
| The following files in the WooCommerce Analytics repository need to be updated: | ||
|
|
||
| 1. **`/js/src/widgets/payments-by-method/payments-by-method.tsx`** (Lines 41-43) | ||
| - Uses: `label="$122K"` and `note="+3%"` | ||
| - Action: Convert to composition API | ||
|
|
||
| 2. **`/js/src/widgets/taxes-by-code/index.tsx`** (Lines 45-47) | ||
| - Uses: `label={label}` and `note={info}` | ||
| - Action: Convert to composition API | ||
|
|
||
| 3. **`/js/src/widgets/coupons-widget/coupons-widget.tsx`** (Line 82) | ||
| - Uses: `label=""` | ||
| - Action: Remove empty label prop | ||
|
|
||
| 4. **`/next-woocommerce-analytics/packages/widgets/src/shared/semi-circle-chart/semi-circle-chart.tsx`** (Line 93) | ||
| - Uses: `label=""` | ||
| - Action: Remove empty label prop | ||
|
|
||
| ### Jetpack Stats | ||
|
|
||
| No breaking changes found - PieSemiCircleChart is not currently used in Jetpack Stats. | ||
|
|
||
| ## Notes | ||
|
|
||
| - The `label=""` empty string usage can simply be removed without replacement | ||
| - For actual label/note values, use the composition API examples above | ||
| - Import `Group` from `@visx/group` and `Text` from `@visx/text` when using the composition API |
4 changes: 4 additions & 0 deletions
4
...cts/js-packages/charts/changelog/charts-65-iterate-over-pie-and-piesemicircle-composition
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| Significance: minor | ||
| Type: changed | ||
|
|
||
| Charts: improve pie semi circle chart composition | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removing the label and note props is a breaking API change. Please mark this as a breaking change in the changelog (e.g., Significance: major and/or Type: breaking-change) and include a brief migration note showing how to render labels via children (Group/Text or PieSemiCircleChart.SVG).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think the semi-circle chart
labelandnoteprops are currently being used by any consumers, so I don't think it needs to be a significant/major change in the changelog. I'm open to having my mind changed on this, but at this time I don't think this feedback is necessary.