The Laravel Charts package, specifically the one by ConsoleTVs, has not seen updates since 2020, which might indicate that it is no longer actively maintained. However, the package can still be used if it meets your current requirements and works with your version of Laravel.
If you are looking for an actively maintained alternative, you might consider using other charting libraries that integrate well with Laravel. Here are a few options:
-
Chart.js: A popular JavaScript library for creating charts. You can use it with Laravel by including the library in your frontend and passing data from your Laravel controllers to your views.
-
Highcharts: Another powerful charting library that can be used similarly to Chart.js.
-
Laravel Charts by ConsoleTVs: If you still want to use the Laravel Charts package, you can fork the repository and maintain it yourself or look for community forks that might be more up-to-date.
Here is an example of how you might use Chart.js with Laravel:
-
Install Chart.js via npm:
npm install chart.js
-
Create a route and controller method to pass data to your view:
// routes/web.php
Route::get('/charts', [ChartController::class, 'index']);
// app/Http/Controllers/ChartController.php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
class ChartController extends Controller
{
public function index()
{
$data = [
'labels' => ['January', 'February', 'March', 'April', 'May', 'June', 'July'],
'datasets' => [
[
'label' => 'My First dataset',
'backgroundColor' => 'rgba(255, 99, 132, 0.2)',
'borderColor' => 'rgba(255, 99, 132, 1)',
'data' => [65, 59, 80, 81, 56, 55, 40],
],
],
];
return view('charts.index', compact('data'));
}
}
-
Create a view to render the chart:
<!-- resources/views/charts/index.blade.php -->
<!DOCTYPE html>
<html>
<head>
<title>Laravel Chart.js Example</title>
<script src="https://cdn.jsdelivr.net/npm/chart.js"></script>
</head>
<body>
<div style="width: 75%;">
<canvas id="myChart"></canvas>
</div>
<script>
var ctx = document.getElementById('myChart').getContext('2d');
var chartData = @json($data);
var myChart = new Chart(ctx, {
type: 'bar',
data: chartData,
options: {
scales: {
y: {
beginAtZero: true
}
}
}
});
</script>
</body>
</html>
This example demonstrates how to use Chart.js with Laravel to create a simple bar chart. You can customize the chart type and data as needed.
If you prefer a package that is more integrated with Laravel, you might want to explore other options or community-maintained forks of the Laravel Charts package.