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

This package is auto-updated.

Last update: 2024-04-05 04:43:48 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

visualization1.png

visualization2.png

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.