PHP code example of hilioski / charts

1. Go to this page and download the library: Download hilioski/charts library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

hilioski / charts example snippets


ConsoleTVs\Charts\ChartsServiceProvider::class,

'Charts' => ConsoleTVs\Charts\Charts::class,



namespace App\Http\Controllers;

use Illuminate\Http\Request;

use App\Http\Requests;
use Charts;

class TestController extends Controller
{
    public function index()
    {
		$chart = Charts::create('line', 'highcharts')
			->setTitle('My nice chart')
			->setLabels(['First', 'Second', 'Third'])
			->setValues([5,10,20])
			->setDimensions(1000,500)
			->setResponsive(false);
		return view('test', ['chart' => $chart]);
    }
}

Charts::create('line', 'highcharts')
	->setTitle('My nice chart')
	->setLabels(['First', 'Second', 'Third'])
	->setValues([5,10,20])
	->setDimensions(1000,500)
	->setResponsive(false);

Charts::multi('line', 'highcharts')
	->setColors(['#ff0000', '#00ff00', '#0000ff'])
	->setLabels(['One', 'Two', 'Three'])
	->setDataset('Test 1', [1,2,3])
	->setDataset('Test 2', [0,6,0])
	->setDataset('Test 3', [3,4,1]);

		Charts::multi('bar', 'minimalist')
		            ->setResponsive(false)
		            ->setDimensions(0, 500)
		            ->setColors(['#ff0000', '#00ff00', '#0000ff'])
		            ->setLabels(['One', 'Two', 'Three'])
		            ->setDataset('Test 1', [1,2,3])
		            ->setDataset('Test 2', [0,6,0])
		            ->setDataset('Test 3', [3,4,1]);
	

$chart = Charts::database(User::all(), 'bar', 'highcharts');

	$chart = Charts::database(User::all(), 'bar', 'highcharts')->setData(Role::all());
	

	$chart = Charts::database(User::all(), 'bar', 'highcharts')->setDateColumn('my_date_column');
	

	$chart = Charts::database(User::all(), 'bar', 'highcharts')->setDateFormat('j F y');
	

	$chart = Charts::database(User::all(), 'bar', 'highcharts')->setDateFormat('F Y');
	

	$chart = Charts::database(User::all(), 'bar', 'highcharts')
		->setElementLabel("Total")
		->setDimensions(1000, 500)
		->setResponsive(false)
		->groupBy('game');
	

	$chart = Charts::database(User::all(), 'bar', 'highcharts')
		->setElementLabel("Total")
		->setDimensions(1000, 500)
		->setResponsive(false)
		->groupByYear();

	// to display a number of years behind, pass a int parameter. For example to display the last 10 years:
	$chart = Charts::database(User::all(), 'bar', 'highcharts')
		->setElementLabel("Total")
		->setDimensions(1000, 500)
		->setResponsive(false)
		->groupByYear(10);
	

	$chart = Charts::database(User::all(), 'bar', 'highcharts')
		->setElementLabel("Total")
		->setDimensions(1000, 500)
		->setResponsive(false)
		->groupByMonth();

	// to display a specific year, pass the parameter. For example to display the months of 2016 and display a fancy output label:
	$chart = Charts::database(User::all(), 'bar', 'highcharts')
		->setElementLabel("Total")
		->setDimensions(1000, 500)
		->setResponsive(false)
		->groupByMonth('2016', true);
	

	$chart = Charts::database(User::all(), 'bar', 'highcharts')
		->setElementLabel("Total")
		->setDimensions(1000, 500)
		->setResponsive(false)
		->groupByDay();

	// to display a specific month and/or year, pass the parameters. For example to display the days of september 2016 and display a fancy output label:
	$chart = Charts::database(User::all(), 'bar', 'highcharts')
		->setElementLabel("Total")
		->setDimensions(1000, 500)
		->setResponsive(false)
		->groupByDay('09', '2016', true);
	

	$chart = Charts::database(User::all(), 'bar', 'highcharts')
		->setElementLabel("Total")
		->setDimensions(1000, 500)
		->setResponsive(false)
		->lastByYear();

	// to display a number of years behind, pass a int parameter. For example to display the last 3 years:
	$chart = Charts::database(User::all(), 'bar', 'highcharts')
		->setElementLabel("Total")
		->setDimensions(1000, 500)
		->setResponsive(false)
		->lastByYear(3);
	

	$chart = Charts::database(User::all(), 'bar', 'highcharts')
		->setElementLabel("Total")
		->setDimensions(1000, 500)
		->setResponsive(false)
		->lastByMonth();

	// to display a number of months behind, pass a int parameter. For example to display the last 6 months and use a fancy output:
	$chart = Charts::database(User::all(), 'bar', 'highcharts')
		->setElementLabel("Total")
		->setDimensions(1000, 500)
		->setResponsive(false)
		->lastByMonth(6, true);
	

	$chart = Charts::database(User::all(), 'bar', 'highcharts')
		->setElementLabel("Total")
		->setDimensions(1000, 500)
		->setResponsive(false)
		->lastByDay();

	// to display a number of days behind, pass a int parameter. For example to display the last 14 days and use a fancy output:
	$chart = Charts::database(User::all(), 'bar', 'highcharts')
		->setElementLabel("Total")
		->setDimensions(1000, 500)
		->setResponsive(false)
		->lastByDay(14, true);
	

$chart = Charts::realtime(url('/path/to/json'), 2000, 'gauge', 'google')
            ->setValues([65, 0, 100])
            ->setLabels(['First', 'Second', 'Third'])
            ->setResponsive(false)
            ->setHeight(300)
            ->setWidth(0)
            ->setTitle("Permissions Chart")
			->setValueName('value'); //This determines the json index for the value

	$chart = Charts::realtime(url('/path/to/json'), 2000, 'gauge', 'google')
				->setValues([65, 0, 100])
				->setLabels(['First', 'Second', 'Third'])
				->setResponsive(false)
				->setHeight(300)
				->setWidth(0)
				->setTitle("Permissions Chart")
				->setValueName('value'); //This determines the json index for the value
	

	$chart = Charts::realtime(url('/path/to/json'), 2000, 'gauge', 'google')
				->setValues([65, 0, 100])
				->setLabels(['First', 'Second', 'Third'])
				->setResponsive(false)
				->setHeight(300)
				->setWidth(0)
				->setTitle("Permissions Chart")
				->setUrl(url('/new/json'));
	

	$chart = Charts::realtime(url('/path/to/json'), 2000, 'gauge', 'google')
				->setValues([65, 0, 100])
				->setLabels(['First', 'Second', 'Third'])
				->setResponsive(false)
				->setHeight(300)
				->setWidth(0)
				->setTitle("Permissions Chart")
				->setInterval(3000); // in ms
	

	$chart = Charts::realtime(url('/path/to/json'), 1000, 'area', 'highcharts')
				->setResponsive(false)
				->setHeight(300)
				->setWidth(0)
				->setTitle("Permissions Chart")
				->setMaxValues(10);
	

Charts::math('sin(x)', [0, 10], 0.2, 'line', 'highcharts');

  Charts::math('sin(x)', [0, 10], 0.2, 'line', 'highcharts')->setFunction('x+1');
  

	Charts::math('sin(x)', [0, 10], 0.2, 'line', 'highcharts')->setInterval([2, 8]);
	

	Charts::math('sin(x)', [0, 10], 0.2, 'line', 'highcharts')->setAmplitude(0.5);
	

	Charts::math('sin(x)', [0, 10], 0.2, 'line', 'highcharts')->calculate();
	

  Charts::create('line');
  Charts::create('line', 'highcharts');
  

    Charts::database(User::all());
    Charts::create(User::all(), 'line', 'highcharts');
    

    Charts::realtime(url('/json/data'), 2000, 'gauge', 'google')
    

    Charts::math('sin(x)', [0, 10], 0.2, 'line', 'highcharts');
    

	 echo Charts::assets(); 

  // Return all the libraries available
  print_r(Charts::libraries());

  // Return all the libraries available for the line chart
  print_r(Charts::libraries('line'));
  

  // Return all the chart types available
  print_r(Charts::types());

  // Return all the chart types available for the highcharts library
  print_r(Charts::libraries('highcharts'));
  

	Charts::create('gauge', 'google')->setGaugeStyle('right');
	

  Charts::create('line', 'highcharts')->setType('pie');
  

  Charts::create('line', 'highcharts')->setLibrary('google');
  

  Charts::create('line', 'highcharts')->setLabels(['First', 'Second', 'Third']);
  

  Charts::create('line', 'highcharts')->setValues([10, 50, 100]);
  

  Charts::create('line', 'highcharts')->setElementLabel('Total Views');
  

  Charts::create('line', 'highcharts')->setTitle('My Chart');
  

  Charts::create('line', 'highcharts')->setColors(['#ff0000', '#00ff00', '#0000ff']);
  

  Charts::create('line', 'highcharts')->setWidth(1000);
  

  Charts::create('line', 'highcharts')->setHeight(500);
  

  Charts::create('line', 'highcharts')->setHeight(1000, 500);
  

  Charts::create('line', 'highcharts')->setResponsive(false);
  

  print_r(Charts::create('line', 'highcharts')->settings());
  

  echo Charts::create('line', 'highcharts')->setLabels(['One', 'Two'])->setValues([10, 20])->render();
  

  Charts::create('pie', 'highcharts')
  	->setTitle('My nice chart')
  	->setLabels(['First', 'Second', 'Third'])
  	->setValues([5,10,20])
  	->setDimensions(1000,500)
  	->setResponsive(false);
  

  Charts::create('donut', 'highcharts')
  	->setTitle('My nice chart')
  	->setLabels(['First', 'Second', 'Third'])
  	->setValues([5,10,20])
  	->setDimensions(1000,500)
  	->setResponsive(false);
  

  Charts::create('line', 'highcharts')
  	->setTitle('My nice chart')
  	->setElementLabel('My nice label')
  	->setLabels(['First', 'Second', 'Third'])
  	->setValues([5,10,20])
  	->setDimensions(1000,500)
  	->setResponsive(false);
  

  Charts::create('area', 'highcharts')
  	->setTitle('My nice chart')
  	->setElementLabel('My nice label')
  	->setLabels(['First', 'Second', 'Third'])
  	->setValues([5,10,20])
  	->setDimensions(1000,500)
  	->setResponsive(false);
  

  Charts::create('bar', 'highcharts')
  	->setTitle('My nice chart')
  	->setElementLabel('My nice label')
  	->setLabels(['First', 'Second', 'Third'])
  	->setValues([5,10,20])
  	->setDimensions(1000,500)
  	->setResponsive(false);
  

  Charts::create('colorbar', 'highcharts')
  	->setTitle('My nice colorful chart')
    ->setColors(['#e04f67', '#7cb5ec'])
  	->setLabels(['First', 'Second'])
  	->setValues([5,10])
  	->setDimensions(200,200)
  	->setResponsive(false);
  

  Charts::create('geo', 'highcharts')
  	->setTitle('My nice chart')
  	->setElementLabel('My nice label')
  	->setLabels(['ES', 'FR', 'RU'])
  	->setColors(['#C5CAE9', '#283593'])
  	->setValues([5,10,20])
  	->setDimensions(1000,500)
  	->setResponsive(false);
  

  Charts::create('gauge', 'canvas-gauges')
  	->setTitle('My nice chart')
  	->setElementLabel('My nice label')
  	->setValues([65,0,100])
  	->setResponsive(false)
  	->setHeight(300)
  	->setWidth(0);
  

  Charts::create('temp', 'canvas-gauges')
  	->setTitle('My nice chart')
  	->setElementLabel('My nice label')
  	->setValues([65,0,100])
  	->setResponsive(false)
  	->setHeight(300)
  	->setWidth(0);
  

  Charts::create('percentage', 'justgage')
  	->setTitle('My nice chart')
  	->setElementLabel('My nice label')
  	->setValues([65,0,100])
  	->setResponsive(false)
  	->setHeight(300)
  	->setWidth(0);
  

  Charts::create('progressbar', 'progressbarjs')
  	->setValues([65,0,100])
  	->setResponsive(false)
  	->setHeight(50)
  	->setWidth(0);
  

$chart = Charts::create('line', 'mylib');
config/app.php
config/app.php

php artisan vendor:publish --tag=charts_config
php artisan vendor:publish --tag=charts_assets --force
config/charts.php
$year = 7, $fancy = false
$number = 6, $fancy = false
$number = 7, $fancy = false
setValueName($string)
library.type.php
mylib.line.php