Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Gauge Chart

Signature

sp.build_gauge(
    title: str,
    value: float,
    *,
    min_val: float = 0.0,
    max_val: float = 100.0,
    thresholds: list[float] | None = None,
    threshold_colors: list[int] | None = None,
    color_hex: int = 0x6366F1,
    width: int = 500,
    height: int = 350,
    show_value: bool = True,
    background: str | None = None,
    label: str = "",
) -> Chart

Aliases: sp.gauge


Description

Semicircular gauge (speedometer) chart. Colored arcs can indicate thresholds (danger / warning / ok).


Parameters

ParameterTypeDefaultDescription
titlestrrequiredChart title
valuefloatrequiredCurrent reading
min_valfloat0.0Scale minimum
max_valfloat100.0Scale maximum
thresholdslist[float] | NoneNoneZone boundaries within [min,max]
threshold_colorslist[int] | NoneNoneColors for each threshold zone
color_hexint0x6366F1Needle color
widthint500Canvas width
heightint350Canvas height
show_valueboolTrueDisplay numeric value below needle
labelstr""Unit label under the value

Returns

Chart


Examples

CPU usage gauge

import seraplot as sp
chart = sp.build_gauge(
    "CPU Usage",
    value=73.5,
    min_val=0,
    max_val=100,
    label="%",
)
const sp = require('seraplot');
const chart = sp.build_gauge("CPU Usage",
{
    value: 73.5,
    min_val: 0,
    max_val: 100,
    label: "%"
})
import * as sp from 'seraplot';
const chart = sp.build_gauge("CPU Usage",
{
    value: 73.5,
    min_val: 0,
    max_val: 100,
    label: "%"
})
▶ Live Preview

See also

Signature

sp.build_gauge(
    title: str,
    value: float,
    *,
    min_val: float = 0.0,
    max_val: float = 100.0,
    thresholds: list[float] | None = None,
    threshold_colors: list[int] | None = None,
    color_hex: int = 0x6366F1,
    width: int = 500,
    height: int = 350,
    show_value: bool = True,
    background: str | None = None,
    label: str = "",
) -> Chart

Aliases: sp.gauge


Description

Jauge semicirculaire (tachymètre). Les arcs colorés indiquent les seuils (danger / avertissement / ok).


Paramètres

ParamètreTypeDéfautDescription
titlestrrequisTitre du graphique
valuefloatrequisValeur actuelle
min_valfloat0.0Minimum de l'échelle
max_valfloat100.0Maximum de l'échelle
thresholdslist[float] | NoneNoneLimites de zones dans [min,max]
threshold_colorslist[int] | NoneNoneCouleurs par zone de seuil
color_hexint0x6366F1Couleur de l'aiguille
widthint500Largeur du canvas
heightint350Hauteur du canvas
show_valueboolTrueAfficher la valeur numérique sous l'aiguille
labelstr""Étiquette d'unité sous la valeur

Retourne

Chart


Exemples

import seraplot as sp

chart = sp.build_gauge(
    "Utilisation CPU",
    value=73.5,
    min_val=0,
    max_val=100,
    label="%",
)

Voir aussi