PHPackages                             noximo/php-colored-ascii-linechart - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. noximo/php-colored-ascii-linechart

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

noximo/php-colored-ascii-linechart
==================================

Pretty line graphs in your console, html or images

v1.1.4(5y ago)1994.1k5[2 issues](https://github.com/noximo/PHP-colored-ascii-linechart/issues)MITPHPPHP &gt;= 7.1

Since Aug 6Pushed 5y ago7 watchersCompare

[ Source](https://github.com/noximo/PHP-colored-ascii-linechart)[ Packagist](https://packagist.org/packages/noximo/php-colored-ascii-linechart)[ RSS](/packages/noximo-php-colored-ascii-linechart/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (5)Dependencies (6)Versions (9)Used By (0)

PHP-colored-ascii-linechart
===========================

[](#php-colored-ascii-linechart)

[![Sinus output](https://camo.githubusercontent.com/f2bf788d91630017154ec738233ba94a38e17d764646d173f05ddd9db14a4ad0/68747470733a2f2f692e696d6775722e636f6d2f5763374f6a764f2e676966)](https://i.imgur.com/Wc7OjvO.gif)

Create beautiful, versatile ASCII line-charts within Terminal, written in `PHP`.

- Create multiple lines in a single chart, each with its own color,
- Use points in your chart ,
- Scale the chart to a desired height or let it grow and shrink freely,
- Have multi-colored lines based on uptrends and downtrends,
- Print charts as ASCII colored text, a HTML snippet or png image,
- Use simple API that helps with animating sequence of charts.

*Built upon [kroitor/asciichart](https://github.com/kroitor/asciichart)*

Installation
------------

[](#installation)

```
$ composer require noximo/php-colored-ascii-linechart

```

Usage
-----

[](#usage)

### Simple Output:

[](#simple-output)

```
$linechart = new Linechart();
echo $linechart->addMarkers([1,2,3,4,5,6])->addPoint(4, 2)->chart();
```

This will print a simple chart with a single point in default colors.

### Advanced Output:

[](#advanced-output)

```
$settings = new Settings();
// Note that any setting can be ommited.
$settings
    ->setColorizer(new AsciiColorizer())  // Colorizer, choose between Ascii, HTML and image colorizers
    ->setFPS(24)  // Control speed of chart::wait method
    ->setHeight(30)  // Set fixed height of chart. chart will scale accordingly. If not set, height will be calculated based on highest and lowest numbers across all sets of markers.
    ->setPadding(5, ' ')  // Set lenght of a padding and character used
    ->setOffset(10)  // Offset left border
    ->setFormat(  // Control how y axis labels will be printed out
        function ($x, Settings $settings) {
            $padding = $settings->getPadding();
            $paddingLength = \strlen($padding);

            return substr($padding . round($x, 2), -$paddingLength);
        }
    );

$linechart = new Linechart();
$linechart->setSettings($settings);

for ($y = 0; $y < 1200; $y++) { // Move sinusoid
    $lineA = [];
    $lineB = [];
    for ($i = $y; $i < $y + 120; $i++) {
        $lineA[] = 10 * sin($i * ((M_PI * 4) / 120));  // Draw sinusoid
        $lineB[] = 20 * sin($i * ((M_PI * 4) / 120));  // Draw sinusoid
    }

    $linechart->addMarkers(
        $lineA,  // Chart data - note that any elements with non-integer keys will be discarded
        [AsciiColorizer::GREEN, AsciiColorizer::BOLD],  // Default color of line. Can be ommited. You can combine mutliple color codes together. If you set up HTML colorizer, you can enter css styles instead of codes. See below
        [AsciiColorizer::RED, AsciiColorizer::BOLD]  // Color of downtrend. Can be ommited, then default color will be used instead.
    );  // Pro-tip - combine color with bold style - it will pop-out nicely

    $linechart->addMarkers($lineB, [AsciiColorizer::CYAN]);  // Add as many datasets as you want

    $linechart->addLine(  // Add a guiding line - a zero line for example
        0,  // Alias y coordinate
        [AsciiColorizer::CYAN],  // You can set color the same way as with markers
        Linechart::FULL_LINE  // Choose between full line and dashed line
    );

    $linechart->addPoint(
        10,
        15,
        [AsciiColorizer::LIGHT_BLUE],
        Linechart::CROSS  // Point can be made more visible with crosslines. Default is Linechart::POINT
    );

    $chart = $linechart->chart();  // Chart is an object with all data drawn. It can be simply echoed or we can leverage its methods for output control

    $chart->clearScreen();  // Clears already outputed charts
    $chart->print();  // Alias of echo $chart with fluent method call
    $chart->wait();  // Naive implementation of animation. It simply sleeps for n microseconds (defined by setFPS earlier). It does not take into account time spent on chart generation or on retrieving data
    $linechart->clearAllMarkers();  // Get rid of already processed chart data so they won't get printed again.
}
```

This will print out the [chart](https://i.imgur.com/Wc7OjvO.gif) shown in the [heading](https://github.com/noximo/PHP-colored-ascii-linechart#php-colored-ascii-linechart).

### HTML Output

[](#html-output)

```
$linechart = new Linechart();
$settings = new Settings();  // Settings are needed in this case
$settings->setColorizer(new HTMLColorizer());  // Here you need to set up HTMLColorizer

$lineA = [];
for ($i = 0; $i < +120; $i++) {
    $lineA[] = 10 * sin($i * ((M_PI * 4) / 120));
}

$linechart->addLine(0, ['color:white'], Linechart::FULL_LINE);  // Use css styles instead of ascii color codes
$linechart->addMarkers($lineA, ['color: green'], ['color: red']);
$linechart->setSettings($settings);

echo $linechart->chart();
```

[![Sinus output](https://camo.githubusercontent.com/e0553882af2a2810dbb1ebf6165d303095019e75d854d78b160ab4e4ade76f9d/68747470733a2f2f692e696d6775722e636f6d2f517737386b396b2e706e67)](https://i.imgur.com/Qw78k9k.png)

### Image Output

[](#image-output)

Images are a work in progress. You can look in `/examples` folder for a *beta* implementation.

Development Pathway / To-Do
---------------------------

[](#development-pathway--to-do)

- Refactoring of colorizers and printers:
    - single colorizer regardles of output type,
    - chart class rewrite so $chart-&gt;toHtml(), $chart-&gt;toPng(), $chart-&gt;toAscii() etc. exists,
- Proper image support. Animated images through gifs,
- Better customization (backgrounds, borders),
- X axis with labels.

###  Health Score

37

—

LowBetter than 83% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity38

Limited adoption so far

Community14

Small or concentrated contributor base

Maturity62

Established project with proven stability

 Bus Factor1

Top contributor holds 96.3% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~129 days

Recently: every ~225 days

Total

8

Last Release

1938d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/993a7364565a51558985231f8b39d132e1b4bd4ec8d33f41c9bfa9889bc056e6?d=identicon)[noximo](/maintainers/noximo)

---

Top Contributors

[![noximo](https://avatars.githubusercontent.com/u/1476387?v=4)](https://github.com/noximo "noximo (26 commits)")[![lexustec](https://avatars.githubusercontent.com/u/4784045?v=4)](https://github.com/lexustec "lexustec (1 commits)")

---

Tags

asciichartgraphmarkerstocklinechartlinegraph

###  Code Quality

Static AnalysisPHPStan

Code StyleECS

Type Coverage Yes

### Embed Badge

![Health badge](/badges/noximo-php-colored-ascii-linechart/health.svg)

```
[![Health](https://phpackages.com/badges/noximo-php-colored-ascii-linechart/health.svg)](https://phpackages.com/packages/noximo-php-colored-ascii-linechart)
```

###  Alternatives

[nnnick/chartjs

Simple HTML5 charts using the canvas element.

67.3k1.1M15](/packages/nnnick-chartjs)[novus/nvd3

A reusable charting library written in d3.js

7.2k207.7k2](/packages/novus-nvd3)[voku/portable-ascii

Portable ASCII library - performance optimized (ascii) string functions for php.

574401.5M117](/packages/voku-portable-ascii)[jbroadway/urlify

A fast PHP slug generator and transliteration library that converts non-ascii characters for use in URLs.

6737.4M62](/packages/jbroadway-urlify)[benpickles/peity

Peity (sounds like deity) is a jQuery plugin that converts an element's content into a mini `&lt;svg&gt;` pie, donut, line or bar chart.

4.2k2.8k](/packages/benpickles-peity)[amenadiel/jpgraph

Composer Friendly, full refactor of JpGraph, library to make graphs and charts

1492.2M7](/packages/amenadiel-jpgraph)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
