Skip to main content

Data to inline SVG charts in pure Python. Line, bar, pie, area, sparkline. No matplotlib. Zero dependencies.

Project description

larzchart

Data to inline SVG charts, in pure Python. Zero dependencies.

No matplotlib, no numpy, no browser, no fonts to bundle. Give it numbers, get back a self-contained <svg> string you can drop straight into an HTML page, an email, a README, a dashboard, or a larzmark site — rendered on the server, in a few kilobytes.

from larzchart import LineChart, BarChart, PieChart, Sparkline, Series

svg = LineChart(
    {"revenue": [10, 14, 12, 20, 25], "cost": [8, 9, 11, 12, 15]},
    labels=["Jan", "Feb", "Mar", "Apr", "May"],
    title="Q1 performance", theme="dark",
).render()                       # -> '<svg ...>...</svg>'

Sparkline([3, 5, 2, 8, 6, 9]).render()      # a tiny inline trend line

Why

  • Zero dependencies. Pure standard library. Nothing to compile, no native wheels, works anywhere Python does — including tiny/serverless environments where matplotlib won't fit.
  • Server-side & inline. Output is a self-contained SVG string (inline styles, no external fonts or scripts), so it renders in an email or a static page with no JavaScript and no image files to host.
  • Just numbers in. Accepts a bare list, a dict of name -> values, or Series objects. Multi-series, titles, axes, gridlines, legends handled for you.
  • Themed. Light and dark themes and a ten-colour categorical palette out of the box; set per-series colours when you want.
  • Deterministic. The same data always produces the same SVG — great for snapshot tests and reproducible reports.

Install

pip install larzchart

Chart types

from larzchart import LineChart, AreaChart, BarChart, PieChart, Sparkline

LineChart([1, 4, 2, 8, 5]).render()                       # line
AreaChart([1, 4, 2, 8, 5]).render()                       # filled area
BarChart({"a": [3, 5, 2], "b": [4, 1, 6]}).render()       # grouped bars
PieChart([30, 50, 20], labels=["A", "B", "C"]).render()   # pie
PieChart([30, 50, 20], donut=True).render()               # donut
Sparkline([3, 5, 2, 8, 6, 9]).render()                    # inline mini-line

Common options: title, labels, width, height, theme="light"|"dark", legend=True/False, and per-Series color.

Save to a file

LineChart([1, 2, 3, 4]).to_html("chart.html")     # minimal standalone HTML page

Great with the rest of the stack

Feed it query results from larzdb, embed the SVG in a page built by larzmark, or drop a Sparkline into a report — no image pipeline required.

Tests

python -m unittest discover -s tests -v      # 25 tests, valid-XML checks, zero deps

The Larz stack

Pure-Python, zero-dependency building blocks:

  • larz — money-native web framework
  • larzchain — from-scratch PoW blockchain
  • larzmoney — exact, penny-perfect money
  • larzcrypt — pure-Python cryptography toolkit
  • larzdb — crash-safe embedded database
  • larzagent — zero-dep AI agent framework
  • larzchart — this library

License

MIT © larz-scripter

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

larzchart-0.1.0.tar.gz (11.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

larzchart-0.1.0-py3-none-any.whl (10.4 kB view details)

Uploaded Python 3

File details

Details for the file larzchart-0.1.0.tar.gz.

File metadata

  • Download URL: larzchart-0.1.0.tar.gz
  • Upload date:
  • Size: 11.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.3

File hashes

Hashes for larzchart-0.1.0.tar.gz
Algorithm Hash digest
SHA256 3cc54427f5ce15329a5d93482e2196a40d6d6f7ed6cdf9c501c551f141f9c2c3
MD5 7a2df39a9e203e1f23d6d6e2d42dad47
BLAKE2b-256 20f0c564e405e4d257fbd7b9ef2d474183602993eef74725e9141a541b27a478

See more details on using hashes here.

File details

Details for the file larzchart-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: larzchart-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 10.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.3

File hashes

Hashes for larzchart-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 09b0172df915e8919f1dc490206f04187323d49859a856bdaadb63a3bf63177d
MD5 67c43002989e792da00902c29ba31331
BLAKE2b-256 669920cce0814d7d471da37a1e7310e2acbe24038a7ae9c752f6f986540ae73d

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page