calvient / arbol
A simple data visualization tool for Laravel apps.
Installs: 3 724
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 0
Forks: 0
Open Issues: 0
Language:TypeScript
Requires
- php: ^8.2
- illuminate/contracts: ^10.0||^11.0
- inertiajs/inertia-laravel: ^1.2
- spatie/laravel-package-tools: ^1.16
Requires (Dev)
- larastan/larastan: ^2.9
- laravel/pint: ^1.14
- nunomaduro/collision: ^8.1.1||^7.10.0
- orchestra/testbench: ^9.1
- pestphp/pest: ^2.34
- pestphp/pest-plugin-arch: ^2.7
- pestphp/pest-plugin-laravel: ^2.3
- phpstan/extension-installer: ^1.3
- phpstan/phpstan-deprecation-rules: ^1.1
- phpstan/phpstan-phpunit: ^1.3
- spatie/laravel-ray: ^1.35
README
Arbol is a simple data visualization tool for Laravel applications built using
It allows customers to create their own reports, extracts, and simple dashboards.
This is a simple tool that solves 80% of a complex problem! So you may still want a paid data visualization tool. But if you need something simple, this might just be for you.
Installation
You can install the package via composer:
composer require calvient/arbol
Publish all the assets with:
php artisan vendor:publish --provider="Calvient\Arbol\ArbolServiceProvider"
Run migrations with:
php artisan migrate
Core concepts
Arbol works by using these 4 concepts:
- Series
- Slices
- Filters
- Formats
Series
A series is the raw data set that a user can interact with. For example, you might have a series for "Podcast Streams" -- which contains data from one or more sources. The only catch is it must return the data in a 2-dimensional table.
Slices
A slice is a way to group data. You might want to view "Podcast Streams" by state, for instance.
Filters
A filter is set of filters applied to your data that you define. For example, a user may only care to see "Podcast Streams" for the last week.
Quick Start
Install the package
composer require calvient/arbol
Publish the package assets and run migrations
php artisan vendor:publish --provider='Calvient\Arbol\ArbolServiceProvider'
php artisan migrate
Publish the package assets after each update
Add the following to composer.json under the "scripts" -> "post-update-cmd" key:
@php artisan vendor:publish --tag=arbol-assets --ansi --force
Make configurations
We assume your User model is App\Models\User
. If not, you can override it in the arbol.php config file.
Because Arbol can assign reports to users, you may also want to further limit which users Arbol can see. You can add a scope like the following to User.php.
public function scopeArbol($query) { return $query->where('is_admin', true); }
Create a New Series
php artisan make:arbol-series PodcastStreams
Add Data and Configuration
Example:
<?php namespace App\Arbol\Series; use Calvient\Arbol\DataObjects\ArbolBag; class PodcastStreams { public function data(ArbolBag $arbolBag) { // You should apply the filters here, which are in the variable $arbolBag. return PodcastStream::all(); } public function slices() { return [ 'States' => fn($row) => $row['state'], ]; } public function filters() { return [ 'Best State Ever' => fn($row) => $row['state'] === 'OK' ? 'Oklahoma' : 'Everyone else', 'Length Listened' => [ '< 15 minutes' => fn($row) => $row['listen_length'] < 15, '>= 15 minutes' => fn($row) => $row['listen_length'] >= 15, ] ]; } }
Testing
composer test
Changelog
Please see CHANGELOG for more information on what has changed recently.
Credits
License
The MIT License (MIT). Please see License File for more information.