dobron / data-grid-visualizer
With Laravel Data Visualizer you can render data from a database as svg (or save as png).
1.0.0
2021-12-31 22:15 UTC
Requires
- php: >=7.4
- ext-imagick: *
- laravel/framework: ^8.0
Requires (Dev)
- brainmaestro/composer-git-hooks: ^2.7
- friendsofphp/php-cs-fixer: ^3.0
- mockery/mockery: ^1.2
- orchestra/testbench: ^6.0
- phpunit/phpunit: ^9.0
This package is auto-updated.
Last update: 2025-03-05 06:41:58 UTC
README
With Laravel Data Visualizer you can render data from a database as svg (or save as png). One advantage is a better view of the stored data than a normal COUNT usage.
Installing
$ composer require dobron/data-grid-visualizer
Usage
Model
echo Patient::query()->dataGridVisualizer([ 'visualize' => [ 'birth_year', function ($birthYear) { if ($birthYear < 1930) { return '#0e4429'; } if ($birthYear < 1960) { return '#006d32'; } if ($birthYear < 1990) { return '#26a641'; } return '#39d353'; } ], ])
Without Model
DB::table('patients')->whereIn('birth_year', [1996, 2000])->dataGridVisualizer([ 'visualize' => [ 'birth_year', [ 1996 => '#800000' 2000 => '#ffc800' ], ], ]);
Render as PNG
$query->dataGridVisualizer([...])->image();
Save as PNG
$query->dataGridVisualizer([...])->image('graph.png');
Options
Option | Description | Default |
---|---|---|
defaultColor | Default grid color if none is defined. | #2d333b |
gap | Gap size in px. | 13 |
size | Size of grid in px. | 10 |
radius | Radius of the grid. | 2 |
outline | Outline color of the grid (optional). | rgba(255, 255, 255, 0.05) |
perspective | Data view perspective (horizontal/vertical). | horizontal |
visualize | Visualization conditions as array [column name, condition]. | none |
Examples
Change log
Please see CHANGELOG for more information on what has changed recently.
Testing
$ composer test
Contributing
Please see CONTRIBUTING for details.
Credits
License
The MIT License (MIT). Please see License File for more information.