calvient/arbol

A simple data visualization tool for Laravel apps.

Installs: 385

Dependents: 0

Suggesters: 0

Security: 0

Stars: 0

Watchers: 0

Forks: 0

Open Issues: 0

Language:TypeScript

0.0.7 2024-06-03 23:42 UTC

This package is auto-updated.

Last update: 2024-06-03 23:42:33 UTC


README

Latest Version on Packagist GitHub Tests Action Status GitHub Code Style Action Status Total Downloads

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.