avinash shows us how to use highcharts in Laravel to turn our data into a story.

highcharts

Visualization of data using highcharts in laravel

Here we ‘ll look at visualization of data using highcharts. Generally data visualization presents the data in graphical or pictorial format so it helps the readers to easily understand the data.

Highcharts.com provides with a lot of different types of charts – line, area, bar, column, pie and many more. Here we ‘ll implement line chart with required data fetched from database.

In this example we show yearly sales of 10 different companies, the database table can be found [here].

The model file will look like,

<?php
namespace App;
use Illuminate\Database\Eloquent\Model;
class CompanyDetails extends Model {
    protected $table = 'companydetails';
    public $timestamps = false;
}
 First we get all the data from database and then convert the highcharts javascript code to php and pass the data to the view so the

visualization of data can be seen.

We get data of each company seperately,

    $y2006Details = CompanyDetails::where ( 'year', '2006' )->get ();
    $y2007Details = CompanyDetails::where ( 'year', '2007' )->get ();
    $y2008Details = CompanyDetails::where ( 'year', '2008' )->get ();
    $y2009Details = CompanyDetails::where ( 'year', '2009' )->get ();
    $y2010Details = CompanyDetails::where ( 'year', '2010' )->get ();
    $y2011Details = CompanyDetails::where ( 'year', '2011' )->get ();
    $y2012Details = CompanyDetails::where ( 'year&#03