laraveldaily/laravel-charts
Laravel Charts by Laravel Daily generates interactive charts for your Laravel apps from Eloquent data. Quickly build line, bar, and pie charts with minimal code, support for multiple chart libraries, and configurable options—ideal for dashboards and admin panels.
Install with composer require laraveldaily/laravel-charts. No config publishing needed—defaults work out of the box. The first use case is rendering a simple Eloquent-backed bar chart in a controller:
use LaravelDaily\Charts\Facades\Charts;
$chart = Charts::eloquent(App\Models\User::class, 'bar')
->title('Users by Role')
->group('role')
->values('id');
return view('dashboard', compact('chart'));
Then in Blade: @charts('chart'). For static data (e.g., mocked metrics), use Charts::create('bar', 'chartjs') with labels() and values(). Start with the README examples—they include copy-pasteable snippets for common patterns.
->eloquent(Model::class, 'type') over manual aggregation. Use ->group('column') for automatic grouping (supports relationships like ->group('team.name') as of v0.1.6).->stacked(true) (v0.2.0+), or define conditional datasets via ->conditions([['name' => 'Paid', 'condition' => 'status = \'paid\'', 'color' => '#4CAF50']]) (v0.1.15+).->group('created_at', 'month') with ->format('M Y') and ->timezone('America/New_York') for localized charts. Avoid manual Carbon parsing—the package handles date/datetime casting automatically.class AnalyticsCharts {
public static function weeklyOrders() {
return Charts::eloquent(Order::class, 'line')
->group('created_at', 'week')
->values('total')
->aggregate('sum')
->filter(fn($q) => $q->whereNotNull('paid_at'));
}
}
->options(['tooltips' => [...]]) for Chart.js-level control. Use ->dataset_name('Revenue') to rename auto-generated labels instead of relying on column names.->rawValues() or use ->blank('No data') (v0.1.28+) for graceful fallback.'stacked' in raw $options fails. Always use the builder method ->stacked(true).->withoutGlobalScopes() or pass an array of scopes to skip (e.g., ->withoutGlobalScopes([SoftDeletingScope::class])).->aggregate_transform() callbacks must handle numeric types (not strings). v0.1.14 fixed type coercion—ensure your closure returns float|int, not formatted strings.name in users and teams). Prefix with table: ->group('teams.name') or alias in the query.->toSql() on the internal query to inspect generated SQL.->rawLabels() and ->rawValues() to verify data alignment.->labels([...]) to synchronize.How can I help you explore Laravel packages today?