iyi language ↗

ccharts.

String charts for financials with C

v3.1.0

Get 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

LanguagePackage / TargetRegistryInstallation Command
PythoncchartsPyPIpip install ccharts (or pip install ccharts[pandas])
Rustcchartscrates.iocargo add ccharts
GocchartsGitHubgo get github.com/dethrandir/ccharts/bindings/go/ccharts
JavaScript / WASM@dethrandir/cchartsnpmnpm install @dethrandir/ccharts
.NET / C#CchartsNuGetdotnet add package Ccharts
Java (JDK 22+)io.github.dethrandir:cchartsMaven CentralMaven / Gradle dependency
RubycchartsRubyGemsgem install ccharts
LuacchartsLuaRocksluarocks install ccharts
JuliaCchartsGeneralusing Pkg; Pkg.add("Ccharts")
iyigithub.com/dethrandir/ccharts/v3Gitiyi 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     
  1. Line (line): High-resolution curves using 8 vertical sub-pixel levels (▁▂▃▄▅▆▇█). Supports area fills, single or directional color
  2. Candlestick (candle): Open, High, Low, Close (OHLC) financial charts with solid bodies (▀▄█), thin vertical wicks (│), and automatic downsampling (`c
  3. Pie & Donut (pie): Proportional charts with terminal aspect ratio compensation, custom hole sizes (donut=True), slice gaps, center text, and customizable legends.
  4. Histogram (histogram / hist): Frequency distributions across continuous sample data with automatic or custom binning and outlier clamping.
  5. Sparkline (sparkline / spark): Compact, axis-less micro trend lines (height 1 to 3) for inline dashboards and log lines.
  6. Bar (bar): Categorical bar charts scaled from a shared zero baseline with 8 sub-pixel tops and categorical label footers.
  7. Stacked Bar (stacked_bar / stack): Multi-series part-to-whole categorical breakdowns showing total sums and series segments.
  8. Heatmap (heatmap / heat): 2-D matrix density visualization using a 10-step deterministic colormap ladder and 2-D block-average downsampling.
  9. 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

FieldMeaningDefault
rise_colorColor for rising segments / bars / boxesGreen (\x1b[32m)
fall_colorColor for falling segments / candlesRed (\x1b[31m)
bg_colorBackground of empty cellsNone (terminal default)
area_colorLine fill color / Whiskers colorNone
single_color1 = one uniform line color; 0 = per-segment direction0
show_pricesPrepend 8-column price/count value axis0
show_timesAppend first/last timestamp footer0
plainStrip all ANSI escape sequences0

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 algorithm
  • abi/ — Flat C ABI (ccharts_abi.h/.c) exporting opaque handles and error codes for FFI
  • bindings/ — Idiomatic binding
  • bindings/rust/ — Rust crate (ccharts
  • bindings/go/ — Go module (ccharts
  • bindings/js/ — Standalone WebAssembly npm package (@dethrandir/ccharts
  • bindings/dotnet/ — .NET 8+ P/Invoke package (Ccharts
  • bindings/java/ — Java 22+ FFM API library (io.github.dethrandir:ccharts
  • bindings/ruby/ — Ruby gem (ccharts
  • bindings/lua/ — LuaRocks package (ccharts
  • bindings/julia/ — Julia package (Ccharts
  • bindings/iyi/ — iyi FFI binding, native build helper, tests and financial JSON CL
  • iyi.mod / ccharts.iyi — iyi package identity and public entry poin
  • ccharts/ — Python package (ccharts) wrapping C core + pandas integratio
  • docs/ — Modular documentation guide
  • conformance/ — 70 cross-language test cases (cases.json) and byte-for-byte golden files (golden/*.txt
  • scripts/ — Version consistency checks, source sync tools, and golden generator

License

ccharts is released under the MIT License.

THE FIRST PACKAGES. YOURS COULD BE NEXT.

Build something iyi.

Meet the language ↗