Pie.

COMMUNITY

Show the proportions that make up a whole.

Live preview31 feature examples

LIVE EXAMPLE

Composition

Match the page theme
Interact with the chart to see selection and range-change results here.
OptionsChanges are reflected in the preview and code.
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
Current preview
<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

PropertyInput format
valuesAn array of { name, value, color? }. Positive values determine the angles.
innerSizeThe donut's inner radius ratio.
labelsContentChoose 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.

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.

Shared sy-chart API versus direct tags

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 / PropertyType / DefaultDescription
PieChartValuesDefault: []An array of { name, value, color? }. Positive values determine the angles.
numberDefault: 480Chart width in pixels. Update with ResizeObserver when the container changes.
numberDefault: 360Chart height in pixels.
brandLogostringDefault: undefinedThe 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.
borderColorstringDefault: '#ffffff'Set as an HTML attribute or JavaScript property. type: string.
borderWidthnumberDefault: 1Set as an HTML attribute or JavaScript property. type: number.
innerSizenumber | stringDefault: undefinedThe donut's inner radius ratio.
startAnglenumberDefault: 0Set as an HTML attribute or JavaScript property. type: number.
endAnglenumberDefault: 360Set as an HTML attribute or JavaScript property. type: number.
centerTextstringDefault: undefinedSet as an HTML attribute or JavaScript property. type: string.
centerSubtextstringDefault: undefinedSet as an HTML attribute or JavaScript property. type: string.
chartTitlestringDefault: undefinedThe title inside the chart. Explain the data's unit and meaning alongside it.
chartSubtitlestringDefault: undefinedThe subtitle inside the chart.
booleanDefault: falseWhether to show a legend for series or items.
legendPositionPieChartLegendPositionDefault: 'bottom'Where the legend is positioned.
labelsModePieChartLabelModeDefault: 'none'Allowed values: none, auto, inside, outside. Default: 'none'.
labelsContentPieChartLabelContentDefault: 'name-percent'Choose names, values, or percentages for labels.
labelsDistancenumberDefault: 24Set as an HTML attribute or JavaScript property. type: number.
labelsFontSizenumberDefault: 12Set as an HTML attribute or JavaScript property. type: number.
labelsConnectorbooleanDefault: trueSet as an HTML attribute or JavaScript property. type: boolean.
tooltipShowbooleanDefault: trueWhether to display the built-in tooltip.
PieChartTooltipInputDefault: undefinedTooltip settings for pointer-driven values, position, and content.
animatedbooleanDefault: falseWhether to animate initial display and data changes.
animationDurationnumberDefault: 600Animation duration in milliseconds.
animationEasingPieChartEasingDefault: 'ease-out'Allowed values: linear, ease-out, ease-in, ease-in-out. Default: 'ease-out'.
animationTypePieChartAnimationTypeDefault: undefinedAllowed values: initial, update. Default: undefined.
Other properties 36
Attribute / PropertyType / DefaultDescription
PieChartPaletteNameDefault: 'tableau10'Allowed values: tableau10, tableau20, observable10, paired12, set3_12. Default: 'tableau10'.
ReadonlyArray<string>Default: undefinedPass as a JavaScript property. type: ReadonlyArray<string>.
slicedOffsetnumberDefault: 10Set as an HTML attribute or JavaScript property. type: number.
number | stringDefault: undefinedPass as a JavaScript property. type: number | string.
centerXnumber | stringDefault: undefinedPass as a JavaScript property. type: number | string.
centerYnumber | stringDefault: undefinedPass as a JavaScript property. type: number | string.
minSizenumberDefault: 80Set as an HTML attribute or JavaScript property. type: number.
numberDefault: undefinedSet as an HTML attribute or JavaScript property. type: number.
variableRadiusbooleanDefault: falseVariable-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.
sizeByPieChartSizeByDefault: 'area'`'area'` (default) scales slice AREA linearly with z (radius ∝ √z̄); `'radius'` scales the radius linearly.
zMinnumberDefault: undefinedLower z-domain bound. Defaults to the data minimum; smaller z clamp to the minimum radius.
zMaxnumberDefault: undefinedUpper z-domain bound. Defaults to the data maximum; larger z clamp to the maximum radius.
minPointSizenumber | stringDefault: '10%'Smallest slice outer DIAMETER — px number or `'%'` of the full outer diameter (Highcharts minPointSize).
maxPointSizenumber | stringDefault: '100%'Largest slice outer DIAMETER — px number or `'%'` of the full outer diameter (Highcharts maxPointSize).
legendItemsLegendItem[]Default: undefinedPass as a JavaScript property. type: LegendItem[].
labelsFontWeightnumberDefault: 500Set as an HTML attribute or JavaScript property. type: number.
labelsColorstringDefault: '#1f2937'Set as an HTML attribute or JavaScript property. type: string.
labelsMinSweepnumberDefault: 0.02Set as an HTML attribute or JavaScript property. type: number.
labelsConnectorColorstringDefault: '#9ca3af'Set as an HTML attribute or JavaScript property. type: string.
labelsConnectorWidthnumberDefault: 1Set as an HTML attribute or JavaScript property. type: number.
labelsConnectorPaddingnumberDefault: 5Set as an HTML attribute or JavaScript property. type: number.
labelsConnectorShape'crooked' | 'straight'Default: 'crooked'Allowed values: straight, crooked. Default: 'crooked'.
labelsAllowOverlapbooleanDefault: falseSet as an HTML attribute or JavaScript property. type: boolean.
tooltipFormat(slice: PieChartResolvedSlice) => stringDefault: undefinedPass as a JavaScript property. type: (slice: PieChartResolvedSlice) => string.
enableMouseTrackingbooleanDefault: trueSet as an HTML attribute or JavaScript property. type: boolean.
stickyTrackingbooleanDefault: falseSet as an HTML attribute or JavaScript property. type: boolean.
allowSelectbooleanDefault: trueSet as an HTML attribute or JavaScript property. type: boolean.
inactiveOtherSlicesbooleanDefault: falseSet as an HTML attribute or JavaScript property. type: boolean.
inactiveSliceOpacitynumberDefault: 0.45Set as an HTML attribute or JavaScript property. type: number.
activeSliceIndexnumberDefault: undefinedSet 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.
proThresholdnumberDefault: 50_000Set as an HTML attribute or JavaScript property. type: number.
PieChartUnavailableBehaviourDefault: 'fallback'Allowed values: fallback, error, throw. Default: 'fallback'.
streamSourcePieChartStreamSourceDefault: undefinedA stream source for live data. Check the contract for the specific type.
streamWindownumberDefault: undefinedThe streaming data range to keep visible.
streamMaxnumberDefault: undefinedThe maximum number of streaming data points to retain.
Events 15
EventsDetail typeDescription
PieChartRenderResult & { tier: PieChartEngineTier }Emits rendering results in detail when chart drawing completes.
PieChartSliceEventDetailCustomEvent.detail type: PieChartSliceEventDetail. Event names are case-sensitive.
PieChartSliceEventDetail | nullCustomEvent.detail type: PieChartSliceEventDetail | null. Event names are case-sensitive.
ChartPointContextMenuEventDetail<PieChartSliceEventDetail>CustomEvent.detail type: ChartPointContextMenuEventDetail<PieChartSliceEventDetail>. Event names are case-sensitive.
PieChartSelectedEventDetailCustomEvent.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.
voidCustomEvent.detail type: void. Event names are case-sensitive.
voidCustomEvent.detail type: void. Event names are case-sensitive.
voidCustomEvent.detail type: void. Event names are case-sensitive.
PieChartTooltipShowEventDetailWhether to display the built-in tooltip.
voidCustomEvent.detail type: void. Event names are case-sensitive.
PieChartTooltipActionEventDetailCustomEvent.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 / ArgumentsReturn typeDescription
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 | numberPromise<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: numberPromise<boolean>An asynchronous method. Check the argument and return types below.
datum: PieChartDatumPromise<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?: numberPromise<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?: booleanPromise<boolean>An asynchronous method. Check the argument and return types below.
idOrIndex: string | numberPromise<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: numberPromise<{ sliceIndex: number; sliceId: string } | null>An asynchronous method. Check the argument and return types below.
idOrIndex: string | numberPromise<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.