fidum/laravel-dashboard-chart-tile
A Laravel Dashboard tile for adding interactive charts to your dashboard. Configure chart data, labels, colors, and display options, then render responsive visualizations alongside your other tiles with minimal setup.
This tile plugs a server-rendered chart into a laravel/dashboard (dmason30's fork of the spatie dashboard). It is a data-source + cache tile, not a "query the DB in the Blade view" tile — understand that split first, because it dictates almost every design decision you'll make with it.
Minimal path:
composer require fidum/laravel-dashboard-chart-tile--tag values; typically chart-tile-config and chart-tile-views) and, if you haven't already, the host dashboard config.php artisan dashboard:fetch-data (or the package's own fetch command if one is registered; check vendor/fidum/laravel-dashboard-chart-tile/src and php artisan list | grep -i chart). Without a running scheduler the tile renders stale or empty data and you'll waste an hour blaming the chart library.php artisan make:chart-tile / dashboard:make-chart-tile — verify exact signature with php artisan list), or hand-write a class extending the package's base chart tile and a class implementing its data-source contract.config/dashboard.php with a data_position and a refresh_interval_in_seconds./dashboard and verify the payload is cached (check the cache store, not just the browser).First real use case: a "revenue last 30 days" line chart backed by an Eloquent aggregate. It exercises the whole loop — data source → cache → tile → refresh — in about 20 lines, and is the right thing to build before touching anything custom.
Data source owns the query, the tile owns the presentation. Keep every DB::raw, groupBy, and date-boundary decision inside the data-source class. The tile class should be nearly declarative: chart type, labels, dataset mapping, options. This is what makes the tile testable — you can unit-test the data source against a factory-seeded DB without booting Livewire.
Treat the data source as a cache-warmer, not a request handler. Because the payload is produced by the scheduled fetch command, a data source that takes 8 seconds is fine; a data source that takes 8 seconds per browser refresh is not, and that only happens if you bypass the cache. Resist the urge to call the source directly in a Blade partial "just for now".
Pattern: parameterised tiles. If you need the same chart for several entities (per-tenant, per-project, per-currency), don't clone classes. Give the tile constructor/mount() a discriminator, use it in the cache key derivation, and register multiple entries in config/dashboard.php pointing at the same class with different constructor args. This is the single biggest maintainability win in a multi-tenant dashboard.
Pattern: composed chart payloads. When one chart needs several series with different grains (daily bars + 7-day moving average line), compute both in the data source and return a shape the tile maps one-to-one onto the chart series. Do not compute the moving average in Blade or in JS — it drifts from the cached payload and you lose the ability to assert on it.
Integration with the rest of the dashboard: the tile is a Livewire component under the hood, so wire:model-style live filters generally do not work the way people expect — a filter change requires a cache re-fetch, not a reactive re-render. If you need interactive filters, model them as separate registered tiles (or a small non-tile Livewire component) rather than trying to bolt reactivity onto a cached chart.
Local development: set refresh_interval_in_seconds low and run the scheduler in a separate terminal (php artisan schedule:work) while iterating, otherwise every data-source change needs a manual dashboard:fetch-data and a hard refresh.
composer update fidum/laravel-dashboard-chart-tile and, if you pin laravel/framework or illuminate/* in a monorepo, confirming your own constraints allow 13.x. Laravel 11/12 users are unaffected.php artisan optimize:clear only if your cache store is cleared too. If a deploy changes a data-source shape (new key, renamed label), old cached payloads will render broken charts until the next fetch. Clear the relevant cache keys — or bump a version segment in your cache key — as part of the deploy.DATE(), DATE_TRUNC) or in PHP, and be consistent — mixing them produces off-by-one-day series that look like chart bugs.wire:navigate is an asset-init problem, not a data problem.How can I help you explore Laravel packages today?