PHP code example of dpodsiadlo / svg-charts
1. Go to this page and download the library: Download dpodsiadlo/svg-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/ */
dpodsiadlo / svg-charts example snippets
'providers' => [
...
DPodsiadlo\SvgCharts\Providers\SvgChartsProvider::class,
]
bash
php artisan vendor:publish --provider="DPodsiadlo\SvgCharts\Providers\SvgChartsProvider"
blade
@inject('svgCharts', '\DPodsiadlo\SvgCharts\SvgCharts') {{-- Injecting the service --}}
<img style="width: 174mm; height: 80mm"
src="{{$svgCharts->lineChart([
'labels' => [
'Monday',
'Tuesday',
'Wednesday',
'Thursday',
'Friday',
'Saturday',
'Sunday'
],
'data' => [
[4,1,22,3,4,55,1], // First dataset
[1,3,2,4,1,2,6] // Second dataset
]
],[
'colors' => ['#32638e','#f00000'], // Colors for datasets
'fillColor' => ['#32638e','#f00000'],
'stroke' => 1,
'axisColor' => '#4a4a4c',
'axisWidth' => 2,
'gridColor' => '#9c9c9b',
'gridWidth' => 1,
'valueGroups' => 5,
'width' => 1600,
'height' => 900,
'valueFormatter' => function($value){ // Closure for formatting values
return money_format("%.2n", $value); // Used setlocale(LC_MONETARY, 'en_US.UTF-8') for this example
}
])->toImgSrc()}}"/>