sparklinekit/theme
Named colour schemes for the SVG and PNG renderers.
import sparklinekit/line
import sparklinekit/theme
pub fn ocean_chart() -> String {
line.new([1.0, 5.0, 3.0, 8.0, 4.0])
|> line.with_theme(theme.ocean())
|> line.with_area_fill(True)
|> line.to_svg
}
Each theme is a small bundle of four CSS colour strings:
foreground— the stroke or main fill colour.background— the colour for the chart’s background rectangle.area— the fill colour used under the line whenwith_area_fill(True)is set.negative— the colour used for negative bars inbarcharts; line charts ignore it.
Pass a theme to line.with_theme / bar.with_theme to set all
four slots at once. The individual with_color,
with_background_color, with_area_color, and
with_negative_color helpers override one slot at a time and can
be chained after with_theme to tweak it.
Types
Values
pub fn amber() -> Theme
Golden amber on white — popular for finance and “warning” indicators where red would be too strong.
pub fn area(theme: Theme) -> String
Area-fill colour used under the line in line charts when
with_area_fill(True) is set.
pub fn background(theme: Theme) -> String
Background rectangle colour. The string "none" disables the
background rectangle entirely (the renderer omits it from the
SVG / leaves PNG pixels transparent).
pub fn crimson() -> Theme
Saturated red on white — useful for losses, alerts, or “attention required” KPIs.
pub fn default() -> Theme
Default theme used when no with_theme call is made: CSS
currentColor for the foreground, no background fill, an
auto-derived area tint, and a fallback negative bar colour.
pub fn forest() -> Theme
Emerald green paired with a red negative — the canonical “finance up / down” palette.
pub fn midnight() -> Theme
Off-white foreground on deep navy — a dark-mode companion to
mono(), for embedding into dark dashboards.
pub fn mono() -> Theme
Near-black on pure white — print-friendly and embeds cleanly in monochrome dashboards.
pub fn negative(theme: Theme) -> String
Colour applied to negative bars in bar charts. Ignored by
line charts.
pub fn ocean() -> Theme
Classic vivid blue on white — a sensible default for product
dashboards. Foreground is Tailwind blue-600.
pub fn slate() -> Theme
Neutral slate grey on white — corporate, low-saturation, works alongside any brand colour without competing with it.