How to add charts in Laravel 5 using Highcharts ?

By Hardik Savani | March 16, 2016 | | 8662 Viewer | Category : Laravel Highcharts

Share this post:

Laravel 5's Blade template engine is awesome. you can easyly use PHP variable, js and js library in laravel view. i will create chart using Highcharts in my laravel application. Highcharts is a js library, this library through we can use bar chart, line chart, area chart, column chart etc, Highcharts also provide sevral theme and graph that way you can use more chart from here : HighCharts Site.

whenever you need to add charts in laravel server side. then you can easily use following example you have to fetch data from database and then set in Highcharts function, so let's see how to use Highcharts in larave with proper example.


So, first add bellow method like this way in your controller :

Controller Method

public function highchart()


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




$viewer = array_column($viewer, 'count');

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




$click = array_column($click, 'count');

return view('highchart')




And Put bellow code in highchart view file.




<script src=""></script>

<script type="text/javascript">

$(function () {

var data_click = <?php echo $click; ?>;

var data_viewer = <?php echo $viewer; ?>;


chart: {

type: 'column'


title: {

text: 'Yearly Website Ratio'


xAxis: {

categories: ['2013','2014','2015', '2016']


yAxis: {

title: {

text: 'Rate'



series: [{

name: 'Click',

data: data_click

}, {

name: 'View',

data: data_viewer





<div class="container">

<div class="row">

<div class="col-md-10 col-md-offset-1">

<div class="panel panel-default">

<div class="panel-heading">Dashboard</div>

<div class="panel-body">

<div id="container"></div>







We are Recommending you: