Search by

benmacha / laravel-nervure

BenMacha

This package is abandoned and no longer maintained. The author suggests using the nervure/laravel package instead.

Laravel integration for nervure: animated SVG charts, maps and dashboards in Blade and Livewire.

v0.13.1 2026-12-02 22:41 UTC

This package is auto-updated.

Last update: 2026-12-02 23:22:04 UTC


README

Animated SVG charts, maps and dashboards of nervure in Blade and Livewire: a Blade component, a @nervureScripts directive and a chart builder.

Documentation: https://nervurejs.github.io/guide/symfony-laravel

Install

composer require benmacha/laravel-nervure
php artisan vendor:publish --tag=nervure-config   # optional

PHP 8.2+, Laravel 11 or 12. The service provider and the Nervure facade are discovered.

Configure

// config/nervure.php
return [
    'theme' => env('NERVURE_THEME', 'auto'), // light, dark or auto
    'locale' => null,       // the language of the page by default
    'animation' => true,    // true, false, or 'visible': plays when the chart comes into view
    'toolbar' => false,     // export button (SVG, PNG, CSV)
    'zoom' => false,
    'height' => 300,        // pixels, or any CSS length
    'assets' => env('NERVURE_ASSETS', 'cdn'), // cdn or vite
    'version' => '0.13.1',   // nervure version loaded from the CDN
    'cdn' => 'https://cdn.jsdelivr.net/npm/nervure@{version}/cdn/nervure.min.js',
];

Load nervure

With the CDN (default), once in your layout:

@nervureScripts

@nervureScripts('nonce') adds a CSP nonce; with Vite's Vite::useCspNonce() the nonce is added by itself.

With Vite, set NERVURE_ASSETS=vite, then:

npm install nervure
// resources/js/app.js
import 'nervure/element';
import '../../vendor/benmacha/laravel-nervure/resources/js/nervure-blade.js';

Use

use BenMacha\LaravelNervure\Facades\Nervure;

$spec = Nervure::xy()
    ->categories(['Jan', 'Feb', 'Mar'])
    ->series('Orders', [120, 180, 150], kind: 'bar')
    ->format(currency: 'EUR');
<x-nervure-chart :spec="$spec" height="300" theme="dark" toolbar />

A spec is a PHP array or a builder. The builder knows xy, pie, gauge, kpi, map and timeline; Nervure::of('sankey', [...]) and ->with('field', $value) reach every other type and field. The specs of the 89 chart types: https://nervurejs.github.io/charts/

Other attributes (class, id, wire:key) go on the wrapper of the chart.

Livewire 3

Nothing to add: the drawing sits in a wire:ignore element, and its spec on the wrapper. When the component renders again, Livewire updates the spec and the chart draws the new data.

final class Sales extends Component
{
    public string $year = '2026';

    public function render()
    {
        return view('livewire.sales', [
            'spec' => Nervure::xy()->categories($this->months())->series('Sales', $this->sales()),
        ]);
    }
}
<div>
    <select wire:model.live="year">…</select>
    <x-nervure-chart :spec="$spec" wire:key="sales-chart" />
</div>

Events

The chart element fires ready with the chart:

document.querySelector('nervure-chart').addEventListener('ready', (event) => event.detail.toPNG());

License

MIT, Ali Ben Macha.