dpodsiadlo / svg-charts by Daniel Podsiadło

SVG Charts Generator for Laravel & DOMPDF
2,296
7
3
Package Data
Maintainer Username: Daniel Podsiadło
Package Create Date: 2016-07-27
Package Last Update: 2022-03-08
Language: PHP
License: MIT
Last Refreshed: 2024-04-19 15:05:17
Package Statistics
Total Downloads: 2,296
Monthly Downloads: 18
Daily Downloads: 2
Total Stars: 7
Total Watchers: 3
Total Forks: 3
Total Open Issues: 1

SVG Charts

A package for Laraver to generate SVG charts compatible with DOMPDF.

Installation

Via Composer

$ composer require dpodsiadlo/svg-charts

Configuration

Once installed, register Laravel service provider, in your config/app.php:

'providers' => [
	...
    DPodsiadlo\SvgCharts\Providers\SvgChartsProvider::class,
]

Basic Usage

Line chart

Line chart example

Blade template implementation:

@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
        '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()}}"/>

License

The MIT License (MIT). Please see License File for more information.