Skip to content

svg

Native SVG renderer for chart specs.

Produces self-contained inline <svg> markup: no images, no external resources, no JavaScript and no element ids (so any number of charts can be inlined in one HTML document). Text uses currentColor so charts follow the surrounding text colour; per-mark <title> elements provide hover tooltips.

Classes

Canvas

Methods:

hit(x, y, w, h, tip)

Invisible hover target, larger than the mark it describes.

Functions:

bar_path(x, y, w, h, end='top')

Bar with a 4px rounded data-end and a square baseline.

legend(c, items, x, y, max_width, size=SMALL)

Draw a wrapping legend; items are (label, colour, shape). Returns height.

x_axis_ticks(lo, hi, plot_w, is_date, size)

Ticks for a horizontal axis, thinned so labels do not collide.

render(spec)

Render a chart spec to inline SVG markup.