Stars: 133
Forks: 57
Pull Requests: 110
Issues: 33
Watchers: 22
Last Updated: 2023-03-13 21:41:34
Full blown refactor of JpGraph v3.5. Distant cousin of current official package
License: Other
Languages: PHP, Makefile, Shell
JpGraph Community Edition was created as a Composer friendly port of JpGraph v3.5. With time and through incremental refactorings, it became a whole different library, with PSR-1 and PSR-2 compliant codebase, namespaces and folder hierarchy enabling PSR-4 autoloading, and more.
We are now, at most, distant cousins with the current official release.
Refactoring is an ongoing effort and we ensure editions and additions don't hurt our (already poor) metrics
As can be seen in their releases section, there was a six year pause in JPGraph release cycle, during which some of us had no choice but to code our way out of PHP 5.x. And thus "Community Edition" was born. From then on, this library evolved on its own and completely diverged from the official packages.
In general terms, JPGraph CE relies in PHP's thriving ecosystem. We aim to be a simple dependency you can seamlessly integrate in your app. JPGraph CE aligns with PHP Standards Reccomendations as published by the PHP Framework Interoperability Group, and when presented with the choice, will always pick an agnostic implementation over custom ones that reinvent the wheel. A lot of code has been trimmed and refactored with this purpose and a lot more is waiting to undergo such a change.
require
or include
in your code.Comparing against the original v3.5 codebase, we also stripped examples or incomplete implementation of graph types exclusive to v3.5 pro (e.g. Barcodes).
This version requires PHP v7.2.0+. If you need to install this library package in older PHP environments please try
Install it Using composer
composer require amenadiel/jpgraph:^4
See the examples folder for working samples.
The examples work the same way you should use this library:
run composer install
require vendor/autoload.php
it the top of your script
generate a graph with a snippet like the following
require_once 'PATH/TO/vendor/autoload.php';
use Amenadiel\JpGraph\Graph;
use Amenadiel\JpGraph\Plot;
// Create the Pie Graph.
$graph = new Graph\PieGraph(350, 250);
$graph->title->Set("A Simple Pie Plot");
$graph->SetBox(true);
$data = array(40, 21, 17, 14, 23);
$p1 = new Plot\PiePlot($data);
$p1->ShowBorder();
$p1->SetColor('black');
$p1->SetSliceColors(array('#1E90FF', '#2E8B57', '#ADFF2F', '#DC143C', '#BA55D3'));
$graph->Add($p1);
$graph->Stroke();
See the examples working by performing the following steps:
composer install
make start
or php -S localhost:8000 -t Examples
You can override some configs set on config.inc.php by creating a .env
file in your project root.
See .env.example as a reference.
Thanks goes to these wonderful people (emoji key):
Sean Zhang 💻 |
Shawn McCool 💻 |
Vinicius Dias 💻 |
Paul van der Knaap 💻 |
Florent Morselli 💻 |
Tony Murray 💻 |
Andreas 💻 |
Corey Watts 💻 |
Alexander Rakushin 💻 |
Muhammad Abid 💻 |
WhileTrue 🐛 |
This project follows the all-contributors specification. Contributions of any kind welcome!