adecks / chartjs
PHP Model Abstraction of ChartJs Objects
v1.0.1
2021-03-30 13:35 UTC
Requires
- php: ^7.1
Requires (Dev)
- codedungeon/phpunit-result-printer: ^0.30.1
- phpunit/phpunit: ^7.0
README
I made this package, since most of my PHP projects make use of graphs, my go to graphing library
if you require more information about chartjs please go Offical Docs.
Installation
You can install the package via composer:
composer require adecks/chartjs -vvv
Creating a chart
Creating a Line chart
use Adecks\ChartJs\Types\Line; use Adecks\ChartJs\Options; use Adecks\ChartJs\Datasets\Dataset; class ExampleController extends Controller { public function index() { $xAxisLabels = ['Jan','Feb','Mar']; $chartOptions = new Options; $lineChart = new Line($xAxisLabels,$chartOptions); $lineChart->addDataset((new Dataset('MyFirstData',[10,12,13])); return response()->json($lineChart); } }
Creating a chart with a (x,y) value
(new Bubble(['Jan','Feb','Mar']))->addData(new Dataset('MyfirsData', ['x' => 123 , 'y' => 321 , 'r' => 10 );
The JSON structure from result
{ "type": "line", "data": { "labels": ["Jan","Feb","Mar"], "datasets": [{"label": "MyFirstData", "backgroundColor": "red", "borderColor": "red", "data": [10,12,13]}] } }
Types of Charts.
use Adecks\ChartJs\Types\Bar; use Adecks\ChartJs\Types\Bubble; use Adecks\ChartJs\Types\Doughnut; use Adecks\ChartJs\Types\Line; use Adecks\ChartJs\Types\Pie; use Adecks\ChartJs\Types\PolarArea; use Adecks\ChartJs\Types\Radar; use Adecks\ChartJs\Types\Scatter;
Testing
php vendor/bin/phpunit
Changelog
Please see CHANGELOG for more information what has changed recently.
Contributing
Please see CONTRIBUTING for details.
Security
If you discover any security related issues, please email andrekendeck@gmail.com instead of using the issue tracker.
Credits
License
The MIT License (MIT). Please see License File for more information.Ï