Pie Chart
Signature
sp.build_pie_chart(
title: str,
labels: list[str],
values: list[float],
*,
show_pct: bool = True,
width: int = 700,
height: int = 480,
palette: list[int] | None = None,
background: str | None = None,
hover_json: str | None = None,
legend_position: str = "right",
) -> Chart
Aliases: sp.pie, sp.pie_chart
Description
Standard pie chart with optional percentage labels.
Parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
title | str | required | Chart title |
labels | list[str] | required | Slice labels |
values | list[float] | required | Slice values (auto-normalized to 100 %) |
show_pct | bool | True | Show percentage text inside slices |
width | int | 700 | Canvas width in pixels |
height | int | 480 | Canvas height in pixels |
palette | list[int] | None | None | Custom hex color palette |
background | str | None | None | Chart background color |
hover_json | str | None | None | Custom hover tooltip JSON |
legend_position | str | "right" | "right", "bottom", "top" |
Returns
Chart
Examples
Market share
Custom palette
import seraplot as sp
chart = sp.build_pie_chart(
"Revenue by Region",
labels=["North", "South", "East", "West"],
values=[30, 25, 20, 25],
palette=[0x6366f1, 0x22d3ee, 0xf43f5e, 0xf59e0b],
legend_position="bottom",
)const sp = require('seraplot');
const chart = sp.build_pie_chart("Revenue by Region",
["North", "South", "East", "West"],
{
values: [30, 25, 20, 25],
palette: [0x6366f1, 0x22d3ee, 0xf43f5e, 0xf59e0b],
legend_position: "bottom"
})import * as sp from 'seraplot';
const chart = sp.build_pie_chart("Revenue by Region",
["North", "South", "East", "West"],
{
values: [30, 25, 20, 25],
palette: [0x6366f1, 0x22d3ee, 0xf43f5e, 0xf59e0b],
legend_position: "bottom"
})▶ Live Preview
See also
Signature
sp.build_pie_chart(
title: str,
labels: list[str],
values: list[float],
*,
show_pct: bool = True,
width: int = 700,
height: int = 480,
palette: list[int] | None = None,
background: str | None = None,
hover_json: str | None = None,
legend_position: str = "right",
) -> Chart
Aliases: sp.pie, sp.pie_chart
Description
Camembert standard avec étiquettes de pourcentage optionnelles.
Paramètres
| Paramètre | Type | Défaut | Description |
|---|---|---|---|
title | str | requis | Titre du graphique |
labels | list[str] | requis | Étiquettes des tranches |
values | list[float] | requis | Valeurs des tranches (normalisées automatiquement à 100 %) |
show_pct | bool | True | Afficher les pourcentages dans les tranches |
width | int | 700 | Largeur du canvas en pixels |
height | int | 480 | Hauteur du canvas en pixels |
palette | list[int] | None | None | Palette de couleurs hex |
background | str | None | None | Couleur de fond |
hover_json | str | None | None | JSON d'infobulle personnalisée |
legend_position | str | "right" | "right", "bottom", "top" |
Retourne
Chart
Exemples
import seraplot as sp
chart = sp.build_pie_chart(
"Chiffre d'affaires par région",
labels=["Nord", "Sud", "Est", "Ouest"],
values=[30, 25, 20, 25],
palette=[0x6366f1, 0x22d3ee, 0xf43f5e, 0xf59e0b],
legend_position="bottom",
)