โ† All libraries

SugarCharts

๐Ÿ“Š SugarCharts

Terminal charts for SugarCraft

port of ntcharts charts sparkline heatmap sixel kitty iterm2

Sparkline, Bar, Line, Heatmap, Scatter, TimeSeries, Streamline, Waveline, OHLC, plus inline image rendering via Sixel / Kitty / iTerm2 protocols. Auto-detects terminal capability.

Install

composer require sugarcraft/sugar-charts

Quickstart

use SugarCraft\Charts\Sparkline\Sparkline;
use SugarCraft\Charts\BarChart\BarChart;
use SugarCraft\Charts\LineChart\LineChart;

echo Sparkline::new([1, 3, 2, 8, 5, 4, 7, 6], 8)->view() . PHP_EOL;
// โ–โ–ƒโ–‚โ–ˆโ–…โ–„โ–‡โ–†

echo BarChart::new(
    [['cpu', 0.7], ['mem', 0.4], ['disk', 0.9]], 20, 5
)->view() . PHP_EOL;

echo LineChart::new([1, 4, 2, 8, 6, 3, 7], 30, 6)->view();

What's in the box

CanvasFixed cell grid with rune + Sprinkles Style per cell. Foundation under every chart type.
SparklineSingle-row series via 8 Unicode bar glyphs. Perfect for log dashboards.
Bar / LineAuto-scaling y-axis, configurable axis labels, optional grid.
HeatmapDensity visualisation with palette gradients.
OHLCCandlestick chart for financial time-series.
TimeSeriesStreaming series with bucket aggregation.
Picture (Sixel/Kitty/iTerm2)Inline raster image rendering. Auto-detects via terminal-version query.

Source & demos

Try the quickstart โ†’

API

ClassMethodDescription
Sparklinenew(data, width)Create sparkline chart
Sparklineview()Render sparkline
BarChartnew(data, width, height)Create bar chart
BarChartview()Render bar chart
LineChartnew(data, width, height)Create line chart
LineChartview()Render line chart
Heatmapnew(data, width, height)Create heatmap
Canvasnew(width, height)Create chart canvas

Demos.

VHS-recorded GIFs of every example shipped with the library. Regenerated automatically on every push that touches the source.

Sparkline

Sparkline

Single-row series โ€” eight Unicode glyphs.
Bar chart

Bar chart

Auto-scaling labelled vertical bars.
Line chart

Line chart

Single-series ASCII plot with axes.
Heatmap

Heatmap

Density visualisation with palette gradient.
Scatter

Scatter

Cell-quantised XY plot.
TimeSeries

TimeSeries

Streaming series with bucket aggregation.
OHLC

OHLC

Candlestick chart for financial data.
Picture

Picture

Inline image via Sixel / Kitty / iTerm2.