Skip to content
Apexify.jsDocs
Apexify.js version v5.4.5

Node / Charts · guide

Pie & donut

Current Apexify.js 6.0.0 documentation for Pie & donut.

apexify.jsRuntime: nodeCURRENTSince 6.0.0
SOURCEtypescript
typescript
Studio
await painter.createChart('pie', slices, options);

PieSlice (required fields label, value)

FieldPurpose
color, gradientFill (gradient wins via createGradientFill).
opacitySlice fill multiplier.
showValue, showLabelPer-slice overrides (defaults bubble from options.labels).
valueLabelCustom text instead of raw value.
shadow, strokePer-slice effects.

PieChartOptions highlights

BlockKeys
typepie (default) or donut.
donutInnerRadiusInner hole radius when type: 'donut'.
dimensionswidth/height/padding.
appearanceShared.
labels.titleChart title.
labels.sliceLabels, valueLabelsfontSize, color, gradient, textStyle.
labels.showValues, showLabels, valueFormat(value, percentage)Global toggles / formatter.
legends.standardshow, position, box styling, wrapText, maxWidth, …
legends.connectedPie-specific leader-line legend — lineColor, lineGradient, lineWidth.
slicesGlobal opacity, shadow, stroke defaults for all arcs.

Example — simple pie

SOURCEtypescript
typescript
Studio
const buf = await painter.createChart(  'pie',  [    { label: 'Desktop', value: 58, color: '#6366f1' },    { label: 'Mobile', value: 32, color: '#22c55e' },    { label: 'Tablet', value: 10, color: '#f97316' },  ],  {    dimensions: { width: 640, height: 480 },    labels: {      title: { text: 'Traffic share', fontSize: 22 },      showValues: true,      valueFormat: (v, pct) => `${pct.toFixed(1)}%`,    },    legends: {      standard: { position: 'right', fontSize: 14 },    },  });

Example — donut + gradients + appearance

SOURCEtypescript
typescript
Studio
const donut = await painter.createChart(  'pie',  [    {      label: 'A',      value: 40,      gradient: {        type: 'linear',        startX: 0,        startY: 0,        endX: 200,        endY: 200,        colors: [          { stop: 0, color: '#a855f7' },          { stop: 1, color: '#ec4899' },        ],      },    },    { label: 'B', value: 35, color: '#38bdf8' },    { label: 'C', value: 25, color: '#34d399' },  ],  {    type: 'donut',    donutInnerRadius: 70,    appearance: {      backgroundColor: '#0f172a',      noiseBg: { intensity: 0.04 },    },    labels: {      title: { text: 'Mix', fontSize: 20, color: '#f8fafc' },      sliceLabels: { fontSize: 11, color: '#e2e8f0' },    },    legends: {      standard: {        position: 'bottom',        textColor: '#f1f5f9',        backgroundColor: 'rgba(30,41,59,0.6)',      },    },  });

Next steps