By Hardik Savani April 22, 2016 Category : Laravel Chart JSPlayUnmuteLoaded: 1.17%FullscreenIf you need to see example of laravel chartjs. it's simple example of laravel chartjs ajax example. if you have question about how to create chart in laravel then I will give simple example with solution. In this article, we will implement a how to use chartjs in laravel.
you can simply use Line Charts, Bar Charts, Pie Charts, Area Charts, etc using chartjs js. you can use this example with laravel 6, laravel 7, laravel 8 and laravel 9 version as well.
Chartjs is a js library, this library through we can use bar chart, line chart, area chart, column chart, etc. chartjs is a open-source chart library. chartjs also provide several theme and graph that way you can use more chart from here : chartjs Site.
In this example, we will create some dummy users records and then we will display a line chart with all months of current years. so let's follow the below step and add a chart in your laravel app.
Step 1: Install Laravel
This is optional; however, if you have not created the laravel app, then you may go ahead and execute the below command:
first of all we will create simple route for creating simple line chart. so let's add simple routes as like bellow:
routes/web.php
<?php use Illuminate\Support\Facades\Route; use App\Http\Controllers\ChartJSController; /*|--------------------------------------------------------------------------| Web Routes|--------------------------------------------------------------------------|| Here is where you can register web routes for your application. These| routes are loaded by the RouteServiceProvider within a group which| contains the "web" middleware group. Now create something great!|*/ Route::get('chart', [ChartJSController::class, 'index']);