You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
docs(charts): Update pie chart size/dimension docs
The size prop no longer controls container dimensions — it
constrains the maximum pie diameter. Width and height now
control the container. Updated JSDoc, API reference, stories
argTypes, and the docs MDX to reflect the new behavior and
remove the broken Responsiveness story reference.
Co-authored-by: Cursor <cursoragent@cursor.com>
@@ -53,16 +52,18 @@ The simplest pie chart requires only a `data` prop with percentage-based data:
53
52
### Required Props
54
53
55
54
-**`data`**: Array of `DataPointPercentage` objects containing label, value, and percentage
56
-
-**`size`**: Diameter of the chart in pixels (when not using responsive mode)
57
55
58
56
### Optional Props
59
57
58
+
-**`size`**: Maximum diameter of the pie in pixels. The pie shrinks if the container is smaller. When omitted, the pie fills available space.
59
+
-**`width`** / **`height`**: Explicit container dimensions in pixels. When omitted, the chart fills its parent.
60
60
-**`padding`** (default: `20`): Padding around the chart in pixels
61
61
-**`withTooltips`** (default: `false`): Enables interactive tooltips on hover
62
62
-**`showLegend`** (default: `false`): Shows a legend for the chart data
63
63
-**`thickness`** (default: `1`): Thickness of the pie chart segments (0-1). Values less than 1 create donut charts
64
64
-**`gapScale`** (default: `0`): Scale of gaps between segments (0-1)
65
65
-**`cornerScale`** (default: `0`): Scale of corner rounding for segments (0-1)
66
+
-**`gap`** (default: `'md'`): Gap between chart elements (SVG, legend, children). Uses WordPress design system tokens.
66
67
-**`children`**: Optional React node to render inside the chart center (useful for donut charts)
67
68
68
69
For detailed prop information, compound components, and type definitions, see the [Pie Chart API Reference](./?path=/docs/js-packages-charts-library-charts-pie-chart-api-reference--docs).
@@ -80,24 +81,24 @@ The composition API allows you to add custom SVG and HTML elements to your chart
80
81
<Source
81
82
language="jsx"
82
83
code={`<PieChart data={ data } size={ 400 }>
83
-
{/* HTML elements rendered outside the SVG */}
84
-
<PieChart.HTML>
85
-
<h3>Chart Title</h3>
86
-
</PieChart.HTML>
87
-
88
-
{/* SVG elements rendered inside the chart */}
89
-
<PieChart.SVG>
90
-
<text x={ 0 } y={ 0 } textAnchor="middle">
91
-
Center Text
92
-
</text>
93
-
</PieChart.SVG>
94
-
95
-
{/* More HTML elements */}
96
-
<PieChart.HTML>
97
-
<PieChart.Legend position="bottom" />
98
-
<p>Additional information</p>
99
-
</PieChart.HTML>
100
-
</PieChart>`}
84
+
{/* HTML elements rendered outside the SVG */}
85
+
<PieChart.HTML>
86
+
<h3>Chart Title</h3>
87
+
</PieChart.HTML>
88
+
89
+
{/* SVG elements rendered inside the chart */}
90
+
<PieChart.SVG>
91
+
<text x={ 0 } y={ 0 } textAnchor="middle">
92
+
Center Text
93
+
</text>
94
+
</PieChart.SVG>
95
+
96
+
{/* More HTML elements */}
97
+
<PieChart.HTML>
98
+
<PieChart.Legend position="bottom" />
99
+
<p>Additional information</p>
100
+
</PieChart.HTML>
101
+
</PieChart>`}
101
102
/>
102
103
103
104
### Benefits of Composition API
@@ -128,27 +129,31 @@ Enable interactive tooltips that display data information on hover:
128
129
129
130
### Responsive Behavior
130
131
131
-
The Pie Chart component supports responsive sizing by omitting the `size` prop:
132
-
133
-
<Canvasof={PieChartStories.Responsiveness} />
132
+
By default, charts **fill their parent container's dimensions**. The parent must have an explicit height:
134
133
135
134
<Source
136
135
language="jsx"
137
-
code={`// Responsive - fills parent container
138
-
<PieChart
139
-
data={ data }
140
-
maxWidth={ 600 }
141
-
aspectRatio={ 1 }
142
-
/>
136
+
code={`// Fill parent container (default) - parent needs explicit height
Use the `size` prop to constrain the maximum pie diameter. The pie will shrink if the container is smaller, but won't grow beyond this value:
146
+
147
+
<Canvasof={PieChartStories.WithSize} />
149
148
149
+
<Source
150
+
language="jsx"
151
+
code={`// Constrained pie diameter (container still fills parent)
152
+
<PieChart data={data} size={200} />`}
150
153
/>
151
154
155
+
For more details on responsive behavior, see the [Responsive Design section](./?path=/docs/js-packages-charts-library-introduction--docs#responsive-design) in the introduction.
156
+
152
157
### Data Validation and Error Handling
153
158
154
159
The component includes built-in data validation with helpful error states:
0 commit comments