Background Configuration
Functions
set_global_background(color)
Sets a global background color applied to all subsequently created charts.
sp.set_global_background("#1a1a2e")sp.set_global_background("#1a1a2e");sp.set_global_background("#1a1a2e");| Parameter | Type | Description |
|---|---|---|
color | str / string | CSS color string (hex "#rrggbb", "rgb(…)", named color) |
reset_global_background()
Clears the global background, reverting to the per-chart default.
sp.reset_global_background()sp.reset_global_background();sp.reset_global_background();set_bg_fn(html, color)
Applies a background color to an existing HTML chart string. Returns the modified HTML string.
html_str = chart.to_html()
html_with_bg = sp.set_bg_fn(html_str, "#0f172a")| Parameter | Type | Description |
|---|---|---|
html | str | HTML string from Chart.to_html() |
color | str | CSS background color |
Returns: str — Modified HTML string. (Python only)
Examples
Dark theme dashboard
import seraplot as sp
sp.set_global_background("#0f172a")
bar = sp.build_bar_chart("Revenue", labels=["A", "B"], values=[300, 200])
pie = sp.build_pie_chart("Share", labels=["A", "B"], values=[60, 40])
sp.reset_global_background()const sp = require('seraplot');
sp.set_global_background("#0f172a");
const bar = sp.build_bar_chart("Revenue", ["A", "B"], { values: [300, 200] });
const pie = sp.build_pie_chart("Share", ["A", "B"], { values: [60, 40] });
sp.reset_global_background();import * as sp from 'seraplot';
sp.set_global_background("#0f172a");
const bar = sp.build_bar_chart("Revenue", ["A", "B"], { values: [300, 200] });
const pie = sp.build_pie_chart("Share", ["A", "B"], { values: [60, 40] });
sp.reset_global_background();See also
Fonctions
set_global_background(color)
Définit une couleur de fond globale appliquée à tous les graphiques créés après l'appel.
| Paramètre | Type | Description |
|---|---|---|
color | str | Couleur CSS (hex "#rrggbb", "rgb(\u2026)", nom de couleur) |
reset_global_background()
Efface le fond global, revenant à la valeur par défaut de chaque graphique.
set_bg_fn(html, color)
Applique une couleur de fond à une chaîne HTML existante. Retourne la chaîne HTML modifiée.
| Paramètre | Type | Description |
|---|---|---|
html | str | Chaîne HTML de Chart.to_html() |
color | str | Couleur de fond CSS |
Retourne : str — Chaîne HTML modifiée.
Exemples
import seraplot as sp
sp.set_global_background("#0f172a")
barre = sp.build_bar_chart("Revenus", labels=["A", "B"], values=[300, 200])
camembert = sp.build_pie_chart("Parts", labels=["A", "B"], values=[60, 40])
sp.reset_global_background()