Skip to content
This is the alpha v4 version website. Looking for the v3 documentation?

layerPiechart

layerPiechart(options?): FragmentLayer

Defined in: packages/node-piechart/src/layer.ts:187

Creates a piechart layer that renders slices around a shape. The piechart follows the contour of whatever SDF shape is used.

Parameters

options?

FactoryOptionsFromSchema<{ defaultColor: PropertySchema<string, "color", false>; offset: PropertySchema<number, "number", true>; slices: ArrayPropertySchema<{ color: PropertySchema<string, "color", true>; value: PropertySchema<number, "number", true>; }>; }>

Piechart configuration options

Returns

FragmentLayer

FragmentLayer definition

Example

// Simple piechart with fixed colors
const piechartLayer = layerPiechart({
slices: [
{ color: "#ff0000", value: { attribute: "value1" } },
{ color: "#00ff00", value: { attribute: "value2" } },
{ color: "#0000ff", value: { attribute: "value3" } },
],
});
// Use with createNodeProgram
const program = createNodeProgram({
shapes: [sdfCircle()],
layers: [piechartLayer],
});