Repository navigation
v0.1.0
Initial public release. Pure Gleam, zero runtime dependencies
beyond gleam_stdlib, runs on both the Erlang and JavaScript
targets, MIT licensed.
Added
Unicode renderer
sparklinekit/unicode— terminal sparklines built from the eight
Unicode block characters▁▂▃▄▅▆▇█. Empty input renders as"";
single-value and all-equal inputs render as the middle block.unicode.render/unicode.render_intsforList(Float)and
List(Int)inputs respectively.
SVG / PNG line renderer
sparklinekit/line— opaque builder that renders to either SVG
strings (line.to_svg) or 8-bit RGBA PNG byte arrays
(line.to_png). PNG strokes use Xiaolin Wu anti-aliasing; SVG
output carriespreserveAspectRatio="none"so charts scale into
any container.- Constructors
line.newandline.new_ints; in-place value
replacement vialine.with_values/line.with_int_values. - Styling helpers:
line.with_color,line.with_background_color,
line.with_size,line.with_stroke_width,line.with_theme. line.with_smoothing(factor)— cubic Bézier smoothing
(0.0–0.5factor, matchingreact-sparklines).line.with_area_fill(enabled)/line.with_area_color(colour)/
line.with_gradient_area(enabled)— tinted area under the line,
rendered as a top-to-baseline gradient by default.line.with_spot(radius)/line.with_spot_color(colour)—
filled circle on the last data point as a "today" marker.- Default viewBox of
240x60, default stroke width2.0,
stroke-width-aware padding so thick strokes are not clipped at
the canvas edge.
SVG / PNG bar renderer
sparklinekit/bar— opaque builder that renders to SVG
(bar.to_svg) or PNG (bar.to_png). Rounded corners are
preserved in the raster output.- Constructors
bar.newandbar.new_ints; in-place value
replacement viabar.with_values/bar.with_int_values. - Styling helpers:
bar.with_color,bar.with_background_color,
bar.with_size,bar.with_bar_gap,bar.with_theme. bar.with_corner_radius(radius)— radius is clamped to half the
smaller side of each bar so the shape stays a rectangle or
capsule rather than collapsing to a circle.bar.with_negative_color(colour)— distinct fill for bars below
the zero baseline; positives and negatives share that baseline.
Themes
sparklinekit/theme— ten bundled colour schemes covering the
common dashboard styles:ocean,forest,sunset,mono,
neon,pastel,crimson,slate,amber,midnight.
Plustheme.default()which inherits the surrounding CSS
currentColor.- Each theme bundles four slots —
foreground,background,
area,negative— exposed viatheme.foreground/1,
theme.background/1,theme.area/1,theme.negative/1. - Apply a theme with
line.with_theme/bar.with_theme; chain
with_color/with_background_color/with_area_color/
with_negative_colorto override individual slots.
Internals
sparklinekit/internal/color— hex colour parsing for#rgb,
#rgba,#rrggbb,#rrggbbaa, plus alpha blending and
channel-wise compositing helpers.sparklinekit/internal/png— PNG encoder using CRC32 +
Adler32 + DEFLATE "store" blocks. Pure Gleam, no FFI.sparklinekit/internal/raster— sparse canvas withdraw_line
(Wu anti-aliased),fill_circle,fill_rounded_rect, and
fill_vertical_gradientprimitives.
Documentation
- README written around runnable samples, each pinned to a test
intest/sparklinekit/readme_test.gleamso the published
snippets cannot drift from the library. - Sample images in
docs/images/covering the SVG / PNG hero
shots, every theme preview, and the edge-case visuals
(single-value, all-equal, negative input).
Install
gleam add sparklinekitSee HexDocs for the API
reference.