Line Chart
Signature
sp.build_line_chart(
title: str,
labels: list[str],
values: list[float],
*,
color_hex: int = 0x6366F1,
show_points: bool = True,
width: int = 900,
height: int = 480,
x_label: str = "",
y_label: str = "",
gridlines: bool = False,
sort_order: str = "none",
hover_json: str = "",
legend_position: str = "right",
palette: list[int] | None = None,
background: str | None = None,
no_x_axis: bool = False,
no_y_axis: bool = False,
) -> Chart
Aliases: sp.line, sp.line_chart
Description
Single-series line chart with optional data points.
For multiple series, use build_multiline_chart.
Parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
title | str | required | Chart title |
labels | list[str] | required | X-axis labels |
values | list[float] | required | Y values |
color_hex | int | 0x6366F1 | Line color as hex int (indigo by default) |
show_points | bool | True | Draw circles at data points |
gridlines | bool | False | Horizontal gridlines |
sort_order | str | "none" | "asc", "desc", "none" |
width | int | 900 | Width in pixels |
height | int | 480 | Height in pixels |
Returns
Chart
Examples
Time series
import seraplot as sp
months = ["Jan", "Feb", "Mar", "Apr", "May", "Jun",
"Jul", "Aug", "Sep", "Oct", "Nov", "Dec"]
revenue = [1200.0, 1350.0, 1100.0, 1600.0, 1800.0, 2100.0,
1950.0, 2300.0, 2000.0, 2500.0, 2200.0, 2800.0]
logo = "https://raw.githubusercontent.com/feur25/seraplot-documentation/main/logo.png"
hover = sp.build_hover_json(months, images=[logo] * len(months))
chart = (
sp.build_line_chart(
"Annual Revenue",
labels=months,
values=revenue,
x_label="Month",
y_label="Revenue (€)",
gridlines=True,
color_hex=0x22d3ee,
hover_json=hover,
)
.set_bg(None)
.show_grid()
)const sp = require('seraplot');
const months = ["Jan", "Feb", "Mar", "Apr", "May", "Jun",
"Jul", "Aug", "Sep", "Oct", "Nov", "Dec"]
const revenue = [1200.0, 1350.0, 1100.0, 1600.0, 1800.0, 2100.0,
1950.0, 2300.0, 2000.0, 2500.0, 2200.0, 2800.0]
const logo = "https://raw.githubusercontent.com/feur25/seraplot-documentation/main/logo.png"
const hover = sp.build_hover_json(months,
[logo])
const chart = (
sp.build_line_chart("Annual Revenue",
months,
{
values: revenue,
x_label: "Month",
y_label: "Revenue (€)",
gridlines: true,
color_hex: 0x22d3ee,
hover_json: hover
})
.set_bg(null)
.show_grid()
)import * as sp from 'seraplot';
const months: string[] = ["Jan", "Feb", "Mar", "Apr", "May", "Jun",
"Jul", "Aug", "Sep", "Oct", "Nov", "Dec"]
const revenue: number[] = [1200.0, 1350.0, 1100.0, 1600.0, 1800.0, 2100.0,
1950.0, 2300.0, 2000.0, 2500.0, 2200.0, 2800.0]
const logo: string = "https://raw.githubusercontent.com/feur25/seraplot-documentation/main/logo.png"
const hover = sp.build_hover_json(months,
[logo])
const chart = (
sp.build_line_chart("Annual Revenue",
months,
{
values: revenue,
x_label: "Month",
y_label: "Revenue (€)",
gridlines: true,
color_hex: 0x22d3ee,
hover_json: hover
})
.set_bg(null)
.show_grid()
)▶ Live Preview
See also
- Multi-line —
sp.build_multiline_chart()for multiple series - Area Chart —
sp.build_area_chart()
Signature
sp.build_line_chart(
title: str,
labels: list[str],
values: list[float],
*,
color_hex: int = 0x6366F1,
show_points: bool = True,
width: int = 900,
height: int = 480,
x_label: str = "",
y_label: str = "",
gridlines: bool = False,
sort_order: str = "none",
hover_json: str = "",
legend_position: str = "right",
palette: list[int] | None = None,
background: str | None = None,
no_x_axis: bool = False,
no_y_axis: bool = False,
) -> Chart
Aliases: sp.line, sp.line_chart
Description
Graphique en courbe simple avec points de données optionnels.
Pour plusieurs séries, utilisez build_multiline_chart.
Paramètres
| Paramètre | Type | Défaut | Description |
|---|---|---|---|
title | str | requis | Titre du graphique |
labels | list[str] | requis | Étiquettes de l'axe X |
values | list[float] | requis | Valeurs Y |
color_hex | int | 0x6366F1 | Couleur de la courbe (hex int) |
show_points | bool | True | Dessiner des cercles aux points de données |
gridlines | bool | False | Lignes de grille horizontales |
sort_order | str | "none" | "asc", "desc" ou "none" |
width | int | 900 | Largeur en pixels |
height | int | 480 | Hauteur en pixels |
Retourne
Chart
Exemples
import seraplot as sp
mois = ["Jan", "Fév", "Mar", "Avr", "Mai", "Jun",
"Jul", "Aoû", "Sep", "Oct", "Nov", "Déc"]
revenu = [1200.0, 1350.0, 1100.0, 1600.0, 1800.0, 2100.0,
1950.0, 2300.0, 2000.0, 2500.0, 2200.0, 2800.0]
chart = (
sp.build_line_chart(
"Chiffre d'affaires annuel",
labels=mois,
values=revenu,
x_label="Mois",
y_label="Chiffre d'affaires (€)",
gridlines=True,
color_hex=0x22d3ee,
)
.set_bg(None)
)
Voir aussi
- Multi-courbes —
sp.build_multiline_chart()pour plusieurs séries - Graphique en aires —
sp.build_area_chart()