Pie.
COMMUNITYShow the proportions that make up a whole.
LIVE EXAMPLE
Composition
Appearance and style14
Legend and interaction11
Title and dimensions3
Treat the sum of four items as the whole and show their proportions. All values are sample data.
View code
<div id="chart-container" style="width: 100%; min-width: 0;"></div>
<script type="module">
import { defineCustomElement as define0 } from '@syidax/advanced/components/sy-pie-chart.js';
define0();
const specs = [
{
"id": "example-chart",
"tag": "sy-pie-chart",
"props": {
"engine": "standard",
"values": [
{
"name": "Product A",
"value": 42,
"color": "#8263d9"
},
{
"name": "Product B",
"value": 28,
"color": "#239c91"
},
{
"name": "Product C",
"value": 18,
"color": "#e99954"
},
{
"name": "Other",
"value": 12,
"color": "#d76c8f"
}
],
"legend": true,
"labelsContent": "name-percent",
"width": 640,
"height": 360,
"brandPosition": "bottom-right",
"brandLogo": ""
}
}
];
const container = document.querySelector('#chart-container');
const elements = specs.map(({ tag, id, props }) => {
const element = document.createElement(tag);
element.id = id;
Object.assign(element, props);
element.setAttribute('aria-label', 'pie example chart');
return element;
});
container.replaceChildren(...elements);
const chart = elements.at(-1);
const onEvent = event => {
console.log('sliceClick', event.detail);
};
chart.addEventListener('sliceClick', onEvent);
const observer = new ResizeObserver(([entry]) => {
const width = Math.max(160, Math.floor(entry.contentRect.width));
elements.forEach(element => { element.width = width; });
});
observer.observe(container);
// In an SPA, call this function when the view is disposed.
function disposeChart() {
observer.disconnect();
chart.removeEventListener('sliceClick', onEvent);
container.replaceChildren();
}
</script>Usage and data
#Use when the total is meaningful and there are few categories.
Not suitable for negative values or overlapping categories. Use bars for precise comparisons between similar values.
Data contract
| Property | Input format |
|---|---|
values | An array of { name, value, color? }. Positive values determine the angles. |
innerSize | The donut's inner radius ratio. |
labelsContent | Choose names, values, or percentages for labels. |
Updating data
Assign a new array or object to the property instead of mutating values inside an array. Chart events provide selection results through event.detail. When disposing of the view, clean up ResizeObserver and event listeners registered by your app.
Feature examples
#Try 31 interactive feature examples and inspect their code. Select “Edit in preview” to combine more options in the settings panel above.
Half donut
Set start and end angles to show composition in a semicircle.
View code
Center summary
Place the key value and description in the donut's center.
View code
Outside labels
Read item names and percentages through outside connectors.
View code
Separate and select slices
B starts separated. Click slices or use the buttons to inspect selection state.
View code
Inspect values with the pointer
Point to data to view the value at that location.
View code
Replay animation
Redraw the same example to inspect its initial display animation.
View code
Accessibility
Compare 2 examples of Accessibility. Buttons and options update both the live result and source code.
View code
Animation
Compare 1 examples of Animation. Buttons and options update both the live result and source code.
View code
Border
Compare 5 examples of Border. Buttons and options update both the live result and source code.
View code
Center text
Compare 3 examples of Center text. Buttons and options update both the live result and source code.
View code
Detailed label settings
Compare 5 examples of Detailed label settings. Buttons and options update both the live result and source code.
View code
Donut
Compare 5 examples of Donut. Buttons and options update both the live result and source code.
View code
Half donut
Compare 5 examples of Half donut. Buttons and options update both the live result and source code.
View code
Label
Compare 4 examples of Label. Buttons and options update both the live result and source code.
View code
Label connector
Compare 4 examples of Label connector. Buttons and options update both the live result and source code.
View code
Legend
Compare 4 examples of Legend. Buttons and options update both the live result and source code.
View code
Color palette
Compare 6 examples of Color palette. Buttons and options update both the live result and source code.
View code
Large datasets
Compare 3 examples of Large datasets. Buttons and options update both the live result and source code.
View code
Highlight state
Compare 4 examples of Highlight state. Buttons and options update both the live result and source code.
View code
Size and center
Compare 4 examples of Size and center. Buttons and options update both the live result and source code.
View code
Sliced And Select
Compare 3 examples of Sliced And Select. Buttons and options update both the live result and source code.
View code
Tooltip
Compare 11 examples of Tooltip. Buttons and options update both the live result and source code.
View code
Data input
Compare 3 examples of Data input. Buttons and options update both the live result and source code.
View code
Variable radius
Compare 6 examples of Variable radius. Buttons and options update both the live result and source code.
View code
Context menu
Compare 1 examples of Context menu. Buttons and options update both the live result and source code.
View code
Data context menu
Compare 1 examples of Data context menu. Buttons and options update both the live result and source code.
View code
Slice events
Compare 1 examples of Slice events. Buttons and options update both the live result and source code.
View code
Read coordinates and data
Compare 1 examples of Read coordinates and data. Buttons and options update both the live result and source code.
View code
Runtime API
Compare 1 examples of Runtime API. Buttons and options update both the live result and source code.
View code
Overview
Compare 1 examples of Overview. Buttons and options update both the live result and source code.
View code
Streaming · Add and update live dataPRO
Compare 3 examples of Add and update live data. Buttons and options update both the live result and source code.
View code
Add to your interface
#The code tabs below the preview contain the full data, options, event bindings, and responsive sizing for the current example. Copy them into an app project, such as Vite, that can resolve the installed packages.
API reference
#The full public API for sy-pie-chart. Pass objects and arrays as JavaScript properties. Select a name to view usage code and type definitions.
Key properties
| Attribute / Property | Type / Default | Description |
|---|---|---|
PieChartValuesDefault: [] | An array of { name, value, color? }. Positive values determine the angles. | |
numberDefault: 480 | Chart width in pixels. Update with ResizeObserver when the container changes. | |
numberDefault: 360 | Chart height in pixels. | |
| brandLogo | stringDefault: undefined | The default is the Syidax logo. With the Pro chart.branding entitlement, use none or a PNG, JPEG, or WebP data URL. |
| brandPosition | 'top-left' | 'top-right' | 'bottom-left' | 'bottom-right'Default: 'bottom-right' | The corner where the logo is anchored. Applies equally to Community and Pro, on screen and in image exports. |
| borderColor | stringDefault: '#ffffff' | Set as an HTML attribute or JavaScript property. type: string. |
| borderWidth | numberDefault: 1 | Set as an HTML attribute or JavaScript property. type: number. |
| innerSize | number | stringDefault: undefined | The donut's inner radius ratio. |
| startAngle | numberDefault: 0 | Set as an HTML attribute or JavaScript property. type: number. |
| endAngle | numberDefault: 360 | Set as an HTML attribute or JavaScript property. type: number. |
| centerText | stringDefault: undefined | Set as an HTML attribute or JavaScript property. type: string. |
| centerSubtext | stringDefault: undefined | Set as an HTML attribute or JavaScript property. type: string. |
| chartTitle | stringDefault: undefined | The title inside the chart. Explain the data's unit and meaning alongside it. |
| chartSubtitle | stringDefault: undefined | The subtitle inside the chart. |
booleanDefault: false | Whether to show a legend for series or items. | |
| legendPosition | PieChartLegendPositionDefault: 'bottom' | Where the legend is positioned. |
| labelsMode | PieChartLabelModeDefault: 'none' | Allowed values: none, auto, inside, outside. Default: 'none'. |
| labelsContent | PieChartLabelContentDefault: 'name-percent' | Choose names, values, or percentages for labels. |
| labelsDistance | numberDefault: 24 | Set as an HTML attribute or JavaScript property. type: number. |
| labelsFontSize | numberDefault: 12 | Set as an HTML attribute or JavaScript property. type: number. |
| labelsConnector | booleanDefault: true | Set as an HTML attribute or JavaScript property. type: boolean. |
| tooltipShow | booleanDefault: true | Whether to display the built-in tooltip. |
PieChartTooltipInputDefault: undefined | Tooltip settings for pointer-driven values, position, and content. | |
| animated | booleanDefault: false | Whether to animate initial display and data changes. |
| animationDuration | numberDefault: 600 | Animation duration in milliseconds. |
| animationEasing | PieChartEasingDefault: 'ease-out' | Allowed values: linear, ease-out, ease-in, ease-in-out. Default: 'ease-out'. |
| animationType | PieChartAnimationTypeDefault: undefined | Allowed values: initial, update. Default: undefined. |
Other properties 36
| Attribute / Property | Type / Default | Description |
|---|---|---|
PieChartPaletteNameDefault: 'tableau10' | Allowed values: tableau10, tableau20, observable10, paired12, set3_12. Default: 'tableau10'. | |
ReadonlyArray<string>Default: undefined | Pass as a JavaScript property. type: ReadonlyArray<string>. | |
| slicedOffset | numberDefault: 10 | Set as an HTML attribute or JavaScript property. type: number. |
number | stringDefault: undefined | Pass as a JavaScript property. type: number | string. | |
| centerX | number | stringDefault: undefined | Pass as a JavaScript property. type: number | string. |
| centerY | number | stringDefault: undefined | Pass as a JavaScript property. type: number | string. |
| minSize | numberDefault: 80 | Set as an HTML attribute or JavaScript property. type: number. |
numberDefault: undefined | Set as an HTML attribute or JavaScript property. type: number. | |
| variableRadius | booleanDefault: false | Variable-radius mode (Highcharts variablepie). Each datum's `z` maps to the slice's outer radius between `min-point-size` and `max-point-size` while `value` keeps owning the angular sweep. Data without any finite `z` renders as a uniform pie even when this is on. |
| sizeBy | PieChartSizeByDefault: 'area' | `'area'` (default) scales slice AREA linearly with z (radius ∝ √z̄); `'radius'` scales the radius linearly. |
| zMin | numberDefault: undefined | Lower z-domain bound. Defaults to the data minimum; smaller z clamp to the minimum radius. |
| zMax | numberDefault: undefined | Upper z-domain bound. Defaults to the data maximum; larger z clamp to the maximum radius. |
| minPointSize | number | stringDefault: '10%' | Smallest slice outer DIAMETER — px number or `'%'` of the full outer diameter (Highcharts minPointSize). |
| maxPointSize | number | stringDefault: '100%' | Largest slice outer DIAMETER — px number or `'%'` of the full outer diameter (Highcharts maxPointSize). |
| legendItems | LegendItem[]Default: undefined | Pass as a JavaScript property. type: LegendItem[]. |
| labelsFontWeight | numberDefault: 500 | Set as an HTML attribute or JavaScript property. type: number. |
| labelsColor | stringDefault: '#1f2937' | Set as an HTML attribute or JavaScript property. type: string. |
| labelsMinSweep | numberDefault: 0.02 | Set as an HTML attribute or JavaScript property. type: number. |
| labelsConnectorColor | stringDefault: '#9ca3af' | Set as an HTML attribute or JavaScript property. type: string. |
| labelsConnectorWidth | numberDefault: 1 | Set as an HTML attribute or JavaScript property. type: number. |
| labelsConnectorPadding | numberDefault: 5 | Set as an HTML attribute or JavaScript property. type: number. |
| labelsConnectorShape | 'crooked' | 'straight'Default: 'crooked' | Allowed values: straight, crooked. Default: 'crooked'. |
| labelsAllowOverlap | booleanDefault: false | Set as an HTML attribute or JavaScript property. type: boolean. |
| tooltipFormat | (slice: PieChartResolvedSlice) => stringDefault: undefined | Pass as a JavaScript property. type: (slice: PieChartResolvedSlice) => string. |
| enableMouseTracking | booleanDefault: true | Set as an HTML attribute or JavaScript property. type: boolean. |
| stickyTracking | booleanDefault: false | Set as an HTML attribute or JavaScript property. type: boolean. |
| allowSelect | booleanDefault: true | Set as an HTML attribute or JavaScript property. type: boolean. |
| inactiveOtherSlices | booleanDefault: false | Set as an HTML attribute or JavaScript property. type: boolean. |
| inactiveSliceOpacity | numberDefault: 0.45 | Set as an HTML attribute or JavaScript property. type: number. |
| activeSliceIndex | numberDefault: undefined | Set as an HTML attribute or JavaScript property. type: number. |
PieChartEngineModeDefault: 'auto' | Renderer selection: auto, standard, or pro. Engine selection is separate from permission to use a Pro chart type. | |
| proThreshold | numberDefault: 50_000 | Set as an HTML attribute or JavaScript property. type: number. |
PieChartUnavailableBehaviourDefault: 'fallback' | Allowed values: fallback, error, throw. Default: 'fallback'. | |
| streamSource | PieChartStreamSourceDefault: undefined | A stream source for live data. Check the contract for the specific type. |
| streamWindow | numberDefault: undefined | The streaming data range to keep visible. |
| streamMax | numberDefault: undefined | The maximum number of streaming data points to retain. |
Events 15
| Events | Detail type | Description |
|---|---|---|
PieChartRenderResult & { tier: PieChartEngineTier } | Emits rendering results in detail when chart drawing completes. | |
PieChartSliceEventDetail | CustomEvent.detail type: PieChartSliceEventDetail. Event names are case-sensitive. | |
PieChartSliceEventDetail | null | CustomEvent.detail type: PieChartSliceEventDetail | null. Event names are case-sensitive. | |
ChartPointContextMenuEventDetail<PieChartSliceEventDetail> | CustomEvent.detail type: ChartPointContextMenuEventDetail<PieChartSliceEventDetail>. Event names are case-sensitive. | |
PieChartSelectedEventDetail | CustomEvent.detail type: PieChartSelectedEventDetail. Event names are case-sensitive. | |
{ index: number; sliceId: string; label: string; disabled: boolean } | CustomEvent.detail type: { index: number; sliceId: string; label: string; disabled: boolean }. Event names are case-sensitive. | |
{ index: number; sliceId: string; disabled: boolean } | CustomEvent.detail type: { index: number; sliceId: string; disabled: boolean }. Event names are case-sensitive. | |
{ count: number } | CustomEvent.detail type: { count: number }. Event names are case-sensitive. | |
{ dropped: number } | CustomEvent.detail type: { dropped: number }. Event names are case-sensitive. | |
void | CustomEvent.detail type: void. Event names are case-sensitive. | |
void | CustomEvent.detail type: void. Event names are case-sensitive. | |
void | CustomEvent.detail type: void. Event names are case-sensitive. | |
PieChartTooltipShowEventDetail | Whether to display the built-in tooltip. | |
void | CustomEvent.detail type: void. Event names are case-sensitive. | |
PieChartTooltipActionEventDetail | CustomEvent.detail type: PieChartTooltipActionEventDetail. Event names are case-sensitive. |
Methods 22
Stencil methods return Promises. Use await within an async function to read the result.
| Method / Arguments | Return type | Description |
|---|---|---|
Promise<PieChartRenderResult> | An asynchronous method. Check the argument and return types below. | |
Promise<PieChartEngineTier> | An asynchronous method. Check the argument and return types below. | |
| datum: PieChartDatum, opts?: { insertAt?: number } | Promise<number> | An asynchronous method. Check the argument and return types below. |
| idOrIndex: string | number | Promise<boolean> | An asynchronous method. Check the argument and return types below. |
| idOrIndex: string | number, patch: Partial<Exclude<PieChartDatum, number>> | Promise<boolean> | An asynchronous method. Check the argument and return types below. |
| idOrIndex: string | number, value: number | Promise<boolean> | An asynchronous method. Check the argument and return types below. |
| datum: PieChartDatum | Promise<void> | An asynchronous method. Check the argument and return types below. |
| datums: ReadonlyArray<PieChartDatum> | Promise<void> | An asynchronous method. Check the argument and return types below. |
| count?: number | Promise<void> | An asynchronous method. Check the argument and return types below. |
| datums: ReadonlyArray<PieChartDatum> | Promise<void> | An asynchronous method. Check the argument and return types below. |
Promise<PieChartStreamSource | undefined> | An asynchronous method. Check the argument and return types below. | |
| options: { duration?: number; easing?: PieChartEasing; enabled?: boolean; type?: PieChartAnimationType } | Promise<void> | An asynchronous method. Check the argument and return types below. |
Promise<void> | An asynchronous method. Check the argument and return types below. | |
Promise<void> | An asynchronous method. Check the argument and return types below. | |
Promise<void> | Replay the initial sweep-from-zero reveal. No-op when animation is off. | |
| idOrIndex: string | number, selected?: boolean | Promise<boolean> | An asynchronous method. Check the argument and return types below. |
| idOrIndex: string | number | Promise<boolean> | An asynchronous method. Check the argument and return types below. |
Promise<string[]> | An asynchronous method. Check the argument and return types below. | |
| cssX: number, cssY: number | Promise<{ sliceIndex: number; sliceId: string } | null> | An asynchronous method. Check the argument and return types below. |
| idOrIndex: string | number | Promise<PieChartSliceEventDetail | null> | An asynchronous method. Check the argument and return types below. |
Promise<void> | An asynchronous method. Check the argument and return types below. | |
Promise<ChartEngineStatus> | Requested engine vs what runs, and why (CHART-ADD-08): always Standard (this type has no WebGPU renderer); read without side effects, never consults the license. |
No matching APIs.