1. Go to this page and download the library: Download molbal/smolchart library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
molbal / smolchart example snippets
use Molbal\Smolchart\Charts\ProgressBar;
use Molbal\Smolchart\Rendering\ASCII\AsciiRenderer;
$progress = (new ProgressBar())
->setData(['completed' => 45, 'total' => 100])
->setLabels(['title' => 'Build'])
->setAnnotations(['note' => 'Halfway there']);
echo $progress->render(new AsciiRenderer());
use Molbal\Smolchart\Charts\BarChart;
use Molbal\Smolchart\Rendering\ASCII\AsciiRenderer;
use Molbal\Smolchart\Rendering\HTML\HtmlRenderer;
$chart = (new BarChart())
->setData(['A' => 1, 'B' => 2])
->setLabels(['x' => 'Key', 'y' => 'Value'])
->setAnnotations(['note' => 'Demo']);
$ascii = $chart->render(new AsciiRenderer());
$html = $chart->render(new HtmlRenderer());
use Molbal\Smolchart\Rendering\ASCII\AsciiRenderer;
$renderer = (new AsciiRenderer())
->withCharacter('▓') // custom fill character (default already ▓)
->withBorder(true) // draw a border box around the content
->withTitle('Weekly Sales')
->withWidth(30) // Bar & Progress: total width incl. borders; Line: drawing width. (default 20 for unspecified)
->withLabelWidth(12); // reserve 12 chars for labels; defaults to longest label
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.