PHP code example of avninc / chartjs-wrapper

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

    

avninc / chartjs-wrapper example snippets


$data = new Data(['label' => '# of Votes', 'data' => [12, 19, 3, 5, 2, 3]], ["Red", "Blue", "Yellow", "Green", "Purple", "Orange"]);
$options = new Options(['responsive' => true]);
$chart = new Chart('mycharts', (new Bar), $data, $options);
$code = $chart->render();

// $code will look something like this:

var chartElement = document.getElementById("mycharts");
var chart = new Chart(chartElement, {
    type: "bar",
    data: {"datasets":{"label":"# of Votes","data":[12,19,3,5,2,3]},"labels":["Red","Blue","Yellow","Green","Purple","Orange"],"xLabels":[],"yLabels":[]},
    options: {"responsive":true}
});