Skip to main content

term-sparkline 📈

Adaptive high-definition (1px Retina) and Unicode-based inline sparklines for modern terminals.

Designed specifically for CLI tables, financial monitoring dashboards, and real-time metric trackers.


✨ Features

  • Adaptive Terminal Detection: Automatically selects the best rendering protocol:
    • iTerm2 / WezTerm / Ghostty: Renders ultra-fine, anti-aliased 1-pixel inline graphics directly in a single text row.
    • Kitty: Uses Kitty graphics protocol.
    • Sixel: Pure Python Sixel encoding for Linux servers, Foot, and classic terminals.
    • Fallback / Standard Terminals: Gracefully degrades to smooth Unicode Braille vector curves (⡠⠤⠒⠊⠉) or classic Block bars ( ▂▃▅▇).
  • Financial Visualization Extras:
    • Multi-Series / Benchmark Comparison: Overlay dual curves (e.g. Stock vs Benchmark Index).
    • Split-Color across Baseline: Automatically colors segments above baseline as Red and below as Green.
    • Mini Candlesticks (OHLC): Renders miniature inline candlestick charts.
    • Mini Volume Bars: Single-line volume histogram bars.
    • Extremum Highlighting: Accent markers on highest (peak) and lowest (trough) values.
    • Area Gradient Fill: Semi-transparent smooth gradient area beneath the curve.
    • Reference Baseline: Subtle dotted baseline for previous close / zero level.
    • End-point Highlight Dot: Prominently marks the latest live price tick.
    • Auto Color & Market Palettes: Automatic color calculation (palette="cn" for Red Up/Green Down, palette="us" for Green Up/Red Down).
  • Streaming & Export Tools:
    • LiveSparkline: High-performance circular buffer for streaming real-time live tickers.
    • SVG / PNG Export: Easily export sparklines to standalone SVG strings or files.
  • Ecosystem Ready:
    • Rich & Textual: Pass Sparkline directly into Table.add_row().
    • Pandas Series Extension: Direct series.sparkline() accessor support.
  • Zero-Friction & Lightweight: Zero required dependencies (optional Pillow for inline images).
  • CLI Utility: Ready to use as a standalone command-line tool.

📦 Installation

pip install "term-sparkline[image]"

(Without [image], it functions in pure-text Unicode Braille/Block mode with zero dependencies).


🚀 Quick Start

Python API

from term_sparkline import sparkline

prices = [10.2, 10.3, 10.1, 10.5, 10.8, 10.7, 11.2, 11.0, 11.5]

# Auto-detects terminal, applies area fill, reference baseline and end-point dot
chart = sparkline(
    prices,
    fill=True,
    baseline=10.5,
    show_dot=True,
    palette="cn"  # Red for rise, Green for fall
)

print(f"600519 贵州茅台  1680.50  +2.15%  {chart}")

Integration with rich

from rich.table import Table
from rich.console import Console
from term_sparkline import Sparkline

console = Console()
table = Table(title="Live Stock Watcher")

table.add_column("Symbol", justify="center")
table.add_column("Price", justify="right")
table.add_column("Change", justify="right")
table.add_column("Trend (Sparkline)", justify="left")

table.add_row("600519", "1680.50", "+2.15%", Sparkline([10, 12, 11, 15, 18], fill=True, show_dot=True))
table.add_row("000001", "11.20", "-1.32%", Sparkline([18, 16, 14, 12, 11], fill=True, show_dot=True))

console.print(table)

CLI Usage

# Pass numbers with baseline and area fill
sparkline 10 12 11 15 18 22 --baseline 12 --fill --dot

# Or pipe from other tools
echo "10,12,11,15,18,22" | sparkline --palette us

📄 License

MIT

Metadata

Release files for term-sparkline 0.4.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for term-sparkline 0.4.0
File Size Uploaded Provenance
term_sparkline-0.4.0.tar.gz 12.0 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for term-sparkline 0.4.0
File Interpreter ABI Platform
term_sparkline-0.4.0-py3-none-any.whl Python 3 none any Details

Total release size: 25.8 kB

Release files / term_sparkline-0.4.0.tar.gz

Download URL term_sparkline-0.4.0.tar.gz
Size 12.0 kB
Tags Source
SHA-256 checksum
How to use checksums
28410adb49f1c397b8fee664d233fe030979b316c098e640ebca68905c65a04b
BLAKE2b-256 checksum
How to use checksums
8e702ef477250e51d1def926f74e3ac0f38f72cf94cdc966bf27bd04ee239a3c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.15.0

Release files / term_sparkline-0.4.0-py3-none-any.whl

Download URL term_sparkline-0.4.0-py3-none-any.whl
Size 13.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
a613fa5ff2da3352b1e8eb1252ac1510a5622ad39248195b3ef40a4399ff2ad3
BLAKE2b-256 checksum
How to use checksums
865cad30ebc7b67c405db0126f698fcfc26fac81ce41a6a916a9941467c7a0a8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.15.0

Security for term-sparkline 0.4.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page