Download the PHP package daikazu/cli-charts without Composer
On this page you can find all versions of the php package daikazu/cli-charts. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download daikazu/cli-charts
More information about daikazu/cli-charts
Files in daikazu/cli-charts
Package cli-charts
Short Description This is my package cli-charts
License MIT
Homepage https://github.com/daikazu/cli-charts
Informations about the package cli-charts
PHP CLI Charts
A PHP library for rendering beautiful charts in the command line using Unicode characters, Braille patterns, and ANSI colors.
Features
- 6 chart types: Bar, Vertical Bar, Line, Pie, Stacked Bar, and Percentage Bar
- High-resolution rendering using Braille characters for smooth curves and lines
- ANSI color support with automatic color cycling
- Customizable dimensions, titles, and display options
- Simple factory pattern API
- Requires PHP 8.4+
Installation
Quick Start
Chart Types
Bar Chart
Horizontal bar chart with colored bars proportional to values.
Example:
Output:
Vertical Bar Chart
Vertical bar chart with optional grid lines, value display, and legend.
Options:
| Option | Type | Default | Description |
|---|---|---|---|
showValues |
bool | false |
Display values above bars |
gridLines |
bool | true |
Show horizontal grid lines |
barWidth |
int | 1 |
Width of each bar in characters |
Example:
Output:
Line Chart
Line chart using Braille characters for smooth, high-resolution lines.
Options:
| Option | Type | Default | Description |
|---|---|---|---|
lineColor |
string | 'cyan' |
Color for the line |
pointColor |
string | null |
Color for data points (uses lineColor if null) |
Example:
Output:
Pie Chart
Circular pie chart rendered using Braille characters with a color legend.
Example:
Output:
Stacked Bar Chart
Single horizontal bar divided into colored segments with percentages.
Example:
Output:
Percentage Bar Chart
Vertical list where each item has a horizontal percentage bar.
Example:
Output:
Common Options
All chart types support these base options:
| Option | Type | Default | Description |
|---|---|---|---|
width |
int | 60 |
Total width in characters |
height |
int | 15 |
Chart height in lines |
title |
string | '' |
Title displayed above the chart |
colors |
bool | true |
Enable/disable ANSI colors |
Available Colors
Charts automatically cycle through these ANSI colors:
redgreenyellowbluemagentacyanwhite
Colors are assigned based on a hash of the label, ensuring consistent colors for the same labels across renders.
API Reference
ChartFactory
Parameters:
$type- Chart type:'bar','vbar','line','pie','stacked'/'sbar','percent'/'pbar'$data- Associative array oflabel => valuepairs$options- Configuration options array
Returns: Chart instance
Throws: InvalidArgumentException for unsupported chart types
Chart Classes
All chart classes extend the abstract Chart class and implement:
Returns the complete chart as a string ready to output.
Direct instantiation:
Testing
Run the visual demo:
Changelog
Please see CHANGELOG for more information on what has changed recently.
Contributing
Please see CONTRIBUTING for details.
Security Vulnerabilities
Please review our security policy on how to report security vulnerabilities.
Credits
- Mike Wall
- All Contributors
License
The MIT License (MIT). Please see License File for more information.