Add Charts Using Highcharts In Laravel 6




Add Charts Using Highcharts In Laravel 6

hii guys,

In this example,I will show you how to add charts using highcharts in laravel 6 application.we will use highcharts library for add bar chart in laravel 6 application.

here we will see that how to use chart using highcharts laravel 6.

Highcharts library is used to add bar chart, line chart, area chart, column chart etc.this is useful when you want to add chart in application as per recuirement easily with less code.

Follow below step to use bar chart in your application :

Install Laravel 6

you will create laravel 6 fresh application.

composer create-project --prefer-dist laravel/laravel ChartsUsingHighcharts

Create Table

Here you will create two table click and view like as below :

Click Table

View Table

Create Route

Add highchart route in web.php file :


Route::get('/highchart', 'HighchartController@highchart')->name('highchart');

Create Controller

Type below command to create HighchartController :

php artisan make:controller HighchartController

Update controller file like as below :



namespace App\Http\Controllers;

use Illuminate\Http\Request;

use App\View;

use App\Click;

class HighchartController extends Controller


public function highchart()


$viewer = View::select(\DB::raw("SUM(numberofview) as count"))



$click = Click::select(\DB::raw("SUM(numberofclick) as count"))



return view('highchart',compact('viewer','click'));



Create Blade File

Put below code in highchart blade file :


<!DOCTYPE html>



<title>High Chart Example</title>



<div id="highchart"></div>

<script src=""></script>

<script src=""></script>

<script type="text/javascript">

$(function () {

var dataClick = {{ json_encode($click,JSON_NUMERIC_CHECK) }};

var dataViewer = {{ json_encode($viewer,JSON_NUMERIC_CHECK) }};


chart: {

type: 'column'


title: {

text: 'Yearly Website Ratio'


xAxis: {

categories: ['2016','2017','2018', '2019']


yAxis: {

title: {

text: 'Rate'



series: [{

name: 'Click',

data: dataClick

}, {

name: 'View',

data: dataViewer








It will help you....


#Laravel 6