PHP code example of sally / dashboard

1. Go to this page and download the library: Download sally/dashboard 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/ */

    

sally / dashboard example snippets


\Sally\Dashboard\DashboardServiceProvider::class,
 
Route::get('dashboard', '\Sally\Dashboard\Controller\DashboardController@index');



namespace App;

use Sally\Dashboard\Domain\Statistic\AbstractStatisticFiller;

class StatisticFiller extends AbstractStatisticFiller
{
    public function fill(): void
    {
        
    }
}

    /**
     * Bootstrap any application services.
     *
     * @return void
     */
    public function boot()
    {
        $this->app->bind(
            AbstractStatisticFiller::class,
            StatisticFiller::class
        );
    }



namespace App;

use Sally\Dashboard\Domain\Statistic\AbstractStatisticFiller;
use Sally\Dashboard\Domain\Statistic\StatisticCreator;

class StatisticFiller extends AbstractStatisticFiller
{
    public function fill(): void
    {
        $this->addStatistic(
            StatisticCreator::createText('Test Card 1', 100)
        );

        $this->addStatistic(
            StatisticCreator::createText('Test Card 2', 200)
        );

        $this->addStatistic(
            StatisticCreator::createText('Test Card 3', 'You also can pass string')
        );

        $this->addStatistic(
            StatisticCreator::createDiagramPie('Demo Pie', [
                'Test Value 1' => 200,
                'Test Value 2' => 200,
                'Test Value 3' => 200,
            ])
        );

        $this->addStatistic(
            StatisticCreator::createDiagramDoughnut('Demo Doughnut', [
                'Test Value 1' => 200,
                'Test Value 2' => 200,
                'Test Value 3' => 200,
            ])
        );

        $this->addStatistic(
            StatisticCreator::createDiagramLine('Demo Line', [
                '25.04.2020' => [
                    'Test Value 1' => 100,
                    'Test Value 2' => 200,
                    'Test Value 3' => 300,
                ],
                '26.04.2020' => [
                    'Test Value 1' => 400,
                    'Test Value 2' => 500,
                    'Test Value 3' => 600,
                ],
                '27.04.2020' => [
                    'Test Value 1' => 240,
                    'Test Value 2' => 350,
                    'Test Value 3' => 450,
                ],
            ])
        );
    }

}



namespace App;

use Sally\Dashboard\Domain\Statistic\AbstractStatisticFiller;

class StatisticFiller extends AbstractStatisticFiller
{
    public function fill(): void
    {
        $this->addStatistic(
            $this->getFactory()->getCommonFactory()->text('Test Card 1', 100)
        );

        $this->addStatistic(
            $this->getFactory()->getCommonFactory()->text('Test Card 2', 200)
        );

        $this->addStatistic(
            $this->getFactory()->getCommonFactory()->text('Test Card 3', 'You also can pass string')
        );

        $pie = $this->getFactory()->getDiagramFactory()->pie('Demo Pie');
        $pie->addItem('Test Value 1', 200);
        $pie->addItem('Test Value 2', 200);
        $pie->addItem('Test Value 3', 200);
        $this->addStatistic($pie);

        $dougnut = $this->getFactory()->getDiagramFactory()->doughnut('Demo Doughnut');
        $dougnut->addItem('Test Value 1', 200);
        $dougnut->addItem('Test Value 2', 200);
        $dougnut->addItem('Test Value 3', 200);
        $this->addStatistic($dougnut);

        $line = $this->getFactory()->getDiagramFactory()->line('Demo Line');
        
        $line->addItem('Test Value 1', 100, '25.04.2020');
        $line->addItem('Test Value 2', 200, '25.04.2020');
        $line->addItem('Test Value 3', 300, '25.04.2020');

        $line->addItem('Test Value 1', 400, '26.04.2020');
        $line->addItem('Test Value 2', 500, '26.04.2020');
        $line->addItem('Test Value 3', 600, '26.04.2020');

        $line->addItem('Test Value 1', 240, '27.04.2020');
        $line->addItem('Test Value 2', 350, '27.04.2020');
        $line->addItem('Test Value 3', 450, '27.04.2020');
        
        $this->addStatistic($line);
    }

}

bash
$ php artisan vendor:publish --provider="Sally\Dashboard\DashboardServiceProvider"