Skip to content
This repository was archived by the owner on Jun 6, 2025. It is now read-only.

Commit 82ca7d0

Browse files
committed
Add padAngle to DonutChart
1 parent 160db46 commit 82ca7d0

File tree

3 files changed

+47
-2
lines changed

3 files changed

+47
-2
lines changed

packages/polaris-viz/CHANGELOG.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,11 @@ All notable changes to this project will be documented in this file.
55
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
66
and adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).
77

8-
<!-- ## Unreleased -->
8+
## Unreleased
9+
10+
### Changed
11+
12+
- Added padding between slices in `<DonutChart />` to improve visibility of small values.
913

1014
## [16.15.2] - 2025-05-02
1115

packages/polaris-viz/src/components/DonutChart/Chart.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,8 @@ export function Chart({
166166

167167
const createPie = pie<DataPoint>()
168168
.value(({value}) => value!)
169-
.sort(null);
169+
.sort(null)
170+
.padAngle(0.05);
170171
const pieChartData = createPie(points);
171172
const isEveryValueZero = points.every(({value}) => value === 0);
172173
const emptyState = pieChartData.length === 0 || isEveryValueZero;
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
import type {Story} from '@storybook/react';
2+
3+
import {META} from './meta';
4+
5+
import type {DonutChartProps} from '../DonutChart';
6+
7+
import {DEFAULT_PROPS, Template} from './data';
8+
9+
export default {
10+
...META,
11+
title: 'polaris-viz/Chromatic/Charts/DonutChart',
12+
parameters: {
13+
...META.parameters,
14+
chromatic: {disableSnapshot: false},
15+
},
16+
};
17+
18+
export const TinySlices: Story<DonutChartProps> = Template.bind({});
19+
20+
TinySlices.args = {
21+
...DEFAULT_PROPS,
22+
data: [
23+
{
24+
name: 'Shopify Payments',
25+
data: [{key: 'april - march', value: 5000000}],
26+
},
27+
{
28+
name: 'Paypal',
29+
data: [{key: 'april - march', value: 250}],
30+
},
31+
{
32+
name: 'Other',
33+
data: [{key: 'april - march', value: 1000000}],
34+
},
35+
{
36+
name: 'Amazon Pay',
37+
data: [{key: 'april - march', value: 400}],
38+
},
39+
],
40+
};

0 commit comments

Comments
 (0)