- How do I install LiveCharts in a Laravel project?
- Run `composer require matheusmarnt/livecharts` and ensure Livewire (v3/4) is installed. The package provides a fluent PHP API for chart configuration, with no additional frontend dependencies beyond Livewire’s core requirements.
- Which Laravel versions does LiveCharts support?
- LiveCharts is officially compatible with Laravel 10, 11, 12, and 13. It relies on Livewire 3 or 4, so verify your Livewire version matches the package’s requirements (check the [README](https://github.com/matheusmarnt/livecharts)).
- Can I use Eloquent models directly as chart data sources?
- Yes. The package abstracts data fetching, so you can pass Eloquent collections or query results directly to chart builders (e.g., `LiveCharts::line()->data($model->get())`). For complex transformations, use Laravel’s query builder or collections.
- Does LiveCharts support custom chart themes or CSS styling?
- The package supports ApexCharts and Chart.js engines, which both offer theming options. Customize via the PHP API (e.g., `->options(['theme' => ['dark' => true]])`) or override engine-specific configurations using `LiveCharts::registerEngine()` for advanced control.
- How do I handle real-time updates for large datasets (e.g., 1000+ data points)?
- For performance, pre-aggregate data in Laravel (e.g., using Redis or database views) and limit Livewire updates to critical changes. The package emits events reactively, but frequent updates may require server-side optimizations like queueing or WebSocket throttling.
- Is there a way to use LiveCharts with Vue/React SPAs instead of Blade?
- LiveCharts is designed for Blade + Livewire. For SPAs, expose chart data via Laravel API routes and render charts client-side using the underlying libraries (Chart.js/ApexCharts). The package doesn’t natively support SPA integration but can feed data to frontend frameworks.
- What chart types are available, and can I add more?
- LiveCharts includes 18 types (line, pie, heatmap, etc.) via ApexCharts/Chart.js. To add custom types, extend the `Chart` class or register a new engine with `LiveCharts::registerEngine()`, though this requires familiarity with the underlying libraries’ APIs.
- How do I handle errors if the chart data fetch fails?
- Livewire’s error handling applies here. Wrap data-fetching logic in try-catch blocks and use Livewire’s `$errors` or custom props to display user-friendly messages. The package doesn’t include built-in error UI, so integrate with your existing validation/error systems.
- Are there alternatives to LiveCharts for Laravel charting?
- Yes. For Livewire-based charts, consider `beyondcode/laravel-websockets` + Chart.js or `spatie/laravel-chartjs`. For Laravel Nova, use Nova’s built-in charting. If you need no Livewire dependency, libraries like `chartjs/chart.js` or `apexcharts/react-apexcharts` (for SPAs) are direct alternatives.
- Who maintains LiveCharts, and is it actively updated?
- The package is maintained by [matheusmarnt](https://github.com/matheusmarnt). While it has passing tests and recent commits, its low adoption (2 stars) suggests limited community scrutiny. Check the [GitHub issues](https://github.com/matheusmarnt/livecharts/issues) and [release notes](https://github.com/matheusmarnt/livecharts/releases) for updates, but monitor for Laravel 14 compatibility.