PHP code example of wdmg / yii2-chartjs

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

    

wdmg / yii2-chartjs example snippets


    
    use wdmg\widgets\chartjs;
    ...
    
    echo ChartJS::widget([
        'type' => 'line',
        'options' => [
            'width' => 640,
            'height' => 260
        ],
        'data' => [
            'labels' => ["Red", "Blue", "Yellow", "Green", "Purple", "Orange"],
            'datasets' => [
                [
                    'label'=> 'Bob',
                    'data' => [5, 8, 12, 10, 7, 13],
                    'backgroundColor' => [
                        'rgba(54, 162, 235, 0.2)'
                    ],
                    'borderColor' => [
                        'rgba(54, 162, 235, 1)'
                    ],
                    'borderWidth' => 1
                ],
                [
                    'label'=> 'Alice',
                    'data' => [6, 8, 10, 6, 4, 12],
                    'backgroundColor' => [
                        'rgba(255, 99, 132, 0.2)'
                    ],
                    'borderColor' => [
                        'rgba(255,99,132,1)'
                    ],
                    'borderWidth' => 1
                ]
            ]
        ]
    ]);