ccharts.
String charts for financials with C
v3.1.0Get started
iyi get github.com/dethrandir/ccharts/v3
iyi get adds it to iyi.mod and fetches its newest version tag. Import it as github.com/dethrandir/ccharts/v3::*.
README
ccharts
Financial and statistical data in, a string out. High-density terminal charts drawn with Unicode block characters and returned as plain text strings â so the chart goes wherever text goes: a terminal, a log line, a chat message, an HTML <pre>, a commit comment, or a printf
328.00████████████
█
█ █████████████▁▁▁▁▁▁▁▁▁▁▁▁
█████████████ █
█
█
█
301.00 █▁▁▁▁▁▁▁▁▁▁▁▁
2026-07-20 2026-07-24
There is no canvas, no image buffer, no GUI, and no terminal detection hooks â one function call returns a string, and what you do with it is your busines
Written as a single-header C89 library with a flat C ABI and idiomatic bindings for Python, Rust, Go, JavaScript/WASM, .NET/C#, Java, Ruby, Lua, Julia, and iyi. All bindings target the same byte-for-byte conformance corpus; see each bindingâs validation notes for tested platform
Language Ecosystem
| Language | Package / Target | Registry | Installation Command |
|---|---|---|---|
| Python | ccharts | PyPI | pip install ccharts (or pip install ccharts[pandas]) |
| Rust | ccharts | crates.io | cargo add ccharts |
| Go | ccharts | GitHub | go get github.com/dethrandir/ccharts/bindings/go/ccharts |
| JavaScript / WASM | @dethrandir/ccharts | npm | npm install @dethrandir/ccharts |
| .NET / C# | Ccharts | NuGet | dotnet add package Ccharts |
| Java (JDK 22+) | io.github.dethrandir:ccharts | Maven Central | Maven / Gradle dependency |
| Ruby | ccharts | RubyGems | gem install ccharts |
| Lua | ccharts | LuaRocks | luarocks install ccharts |
| Julia | Ccharts | General | using Pkg; Pkg.add("Ccharts") |
| iyi | github.com/dethrandir/ccharts/v3 | Git | iyi get github.com/dethrandir/ccharts/v3@main + native build |
iyi binding
The iyi binding supports all nine chart types through the same C ABI, with typed errors and a small JSON-to-chart CLI. Run python3 bindings/iyi/scripts/dev.py test from this checkout. It requires iyi 0.20.1 and an explicit native build. Install from @main; existing release tags predate this addition.
python3 bindings/iyi/scripts/dev.py cli
fl market history THYAO 1m 1d --json | bindings/iyi/build/ccharts-market
Supported Chart Types
ccharts supports 9 visual chart types, each optimized with fractional Unicode glyphs:
1. Line Chart 2. Candlestick 3. Pie / Donut
328.00██████ 330.25▄▄▄▄▄ █████ ████████
█ │ ████████████
█ ██████ ██████
█▁▁▁▁ █████ ████ ████
300.75 █████ ██████████
2026-07-20 Kira 40 (40%)
4. Histogram 5. Sparkline 6. Categorical Bar
8 ████ ▂▃▅▆▇██▇▆▅▄▃ 100.00 ████
████ ████ ████
1 ████████ 0.00 ████ ████ ████
3.10 7.90 Q1 Q2 Q3
7. Stacked Bar 8. Heatmap 9. Box Plot
150.00 ████ Mon █ █ █ █ █ █ 120.00 │
████ Tue █ █ █ █ █ █ ████
0.00 ████ Wed █ █ █ █ █ █ 10.00 ▂ █ │
Prod Thu █ █ █ █ █ █ Cat A Cat B
- Line (
line): High-resolution curves using 8 vertical sub-pixel levels (▁▂▃▄▅▆▇█). Supports area fills, single or directional color - Candlestick (
candle): Open, High, Low, Close (OHLC) financial charts with solid bodies (▀▄█), thin vertical wicks (│), and automatic downsampling (`c - Pie & Donut (
pie): Proportional charts with terminal aspect ratio compensation, custom hole sizes (donut=True), slice gaps, center text, and customizable legends. - Histogram (
histogram/hist): Frequency distributions across continuous sample data with automatic or custom binning and outlier clamping. - Sparkline (
sparkline/spark): Compact, axis-less micro trend lines (height 1 to 3) for inline dashboards and log lines. - Bar (
bar): Categorical bar charts scaled from a shared zero baseline with 8 sub-pixel tops and categorical label footers. - Stacked Bar (
stacked_bar/stack): Multi-series part-to-whole categorical breakdowns showing total sums and series segments. - Heatmap (
heatmap/heat): 2-D matrix density visualization using a 10-step deterministic colormap ladder and 2-D block-average downsampling. - Box Plot (
boxplot/box): Statistical 5-number summaries ($Min, Q_1, Median, Q_3, Max$) computed deterministically via nearest-rank quartiles.
Quickstart Examples
C (Single-Header)
#define CCHARTS_IMPLEMENTATION
#include "ccharts.h"
int main(void) {
const char* json = "[{\"open\":100,\"high\":105,\"low\":98,\"close\":103}]";
cc_ohlc_t* ohlc = NULL;
int size = 0;
cc_json_to_ohlc(json, &ohlc, &size);
cc_settings_t s = { .rise_color = CC_COLOR_BLUE, .show_prices = 1, .show_times = 1 };
char* chart = cc_line_create(ohlc, size, 60, 8, &s);
printf("%s\n", chart);
free(chart);
free(ohlc);
return 0;
}
Python
from ccharts import Chart
# OHLC Chart
chart = Chart.from_arrays(opens, highs, lows, closes, ts=epoch_seconds)
print(chart.candle(width=60, height=8, show_prices=True))
# Standalone Visuals
print(Chart.pie(["Rent", "Food", "Tech"], [45, 30, 25], donut=True))
print(Chart.histogram(samples, bin_count=10, show_bins=True))
print(Chart.sparkline(samples, height=1))
Rust
use ccharts::{Chart, Color, Settings, PieSlice, PieOptions};
let chart = Chart::from_arrays(&opens, &highs, &lows, &closes, Some(&ts))?;
println!("{}", chart.line(60, 8, &Settings::new().rise(Color::Blue))?);
let slices = [PieSlice::new(Some("Rent"), 45.0), PieSlice::new(Some("Food"), 30.0)];
println!("{}", Chart::pie(&slices, 24, 10, &PieOptions::new().donut(true))?);
Go
chart, _ := ccharts.FromArrays(opens, highs, lows, closes, ts)
defer chart.Close()
out, _ := chart.Candle(60, 8, &ccharts.Options{ShowPrices: true})
fmt.Println(out)
JavaScript / WASM
import { Chart, Color } from "@dethrandir/ccharts";
const chart = Chart.fromArrays(opens, highs, lows, closes);
console.log(chart.candle({ width: 60, height: 8, showPrices: true }));
chart.free();
.NET / C
using var chart = Chart.FromArrays(opens, highs, lows, closes);
Console.Write(chart.Line(new ChartOptions { RiseColor = Color.Blue, ShowPrices = true }));
Java (JDK 22+)
try (Chart chart = Chart.fromArrays(opens, highs, lows, closes)) {
System.out.print(chart.candle(ChartOptions.builder().size(60, 8).showPrices(true).build()));
}
Ruby
chart = Ccharts::Chart.from_arrays(open: opens, high: highs, low: lows, close: closes)
puts chart.line(60, 8, Ccharts::Settings::ChartSettings.new.show_prices(true))
Lua
local chart = ccharts.from_arrays(opens, highs, lows, closes)
print(chart:candle(60, 8, { show_prices = true }))
Julia
chart = Chart.from_arrays(opens, highs, lows, closes)
println(chart.candle(60, 8; show_prices=true))
Settings & Colors
| Field | Meaning | Default |
|---|---|---|
rise_color | Color for rising segments / bars / boxes | Green (\x1b[32m) |
fall_color | Color for falling segments / candles | Red (\x1b[31m) |
bg_color | Background of empty cells | None (terminal default) |
area_color | Line fill color / Whiskers color | None |
single_color | 1 = one uniform line color; 0 = per-segment direction | 0 |
show_prices | Prepend 8-column price/count value axis | 0 |
show_times | Append first/last timestamp footer | 0 |
plain | Strip all ANSI escape sequences | 0 |
Setting plain=True (or passing empty strings for color options) completely strips ANSI escape codes, rendering clean plain text ideal for file exports, commit comments, Discord code blocks, and logs.
Detailed Documentation
Comprehensive guides are available in the docs/ directory:
- ð Getting Started â Installation, building from source, and basic usage across all la
- ð Chart Types Guide â In-depth parameters, sub-pixel rendering mechanics, and visual outputs for all 9 char
- ð Language Bindings Guide â Package managers, memory management (RAII/Cleaners/Finalizers), and cross-language API m
- ð ï¸ C API & Flat ABI Reference â Single-header macros, structs, functions, and ABI status cod
- ðï¸ Architecture & Engine Design â Sub-pixel grid pipeline, downsampling math, 32-byte slot memory model, and
Repository Structure
ccharts.hâ Core single-header C library containing all rendering algorithmabi/â Flat C ABI (ccharts_abi.h/.c) exporting opaque handles and error codes for FFIbindings/â Idiomatic bindingbindings/rust/â Rust crate (cchartsbindings/go/â Go module (cchartsbindings/js/â Standalone WebAssembly npm package (@dethrandir/cchartsbindings/dotnet/â .NET 8+ P/Invoke package (Cchartsbindings/java/â Java 22+ FFM API library (io.github.dethrandir:cchartsbindings/ruby/â Ruby gem (cchartsbindings/lua/â LuaRocks package (cchartsbindings/julia/â Julia package (Cchartsbindings/iyi/â iyi FFI binding, native build helper, tests and financial JSON CLiyi.mod/ccharts.iyiâ iyi package identity and public entry poinccharts/â Python package (ccharts) wrapping C core + pandas integratiodocs/â Modular documentation guideconformance/â 70 cross-language test cases (cases.json) and byte-for-byte golden files (golden/*.txtscripts/â Version consistency checks, source sync tools, and golden generator
License
ccharts is released under the MIT License.