PHP code example of sportlog / google-charts

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

    

sportlog / google-charts example snippets

 php
$chartService = new ChartService();
 php
$data = new DataTable();
$data->addColumn(new Column(ColumnType::String, 'Task'));
$data->addColumn(new Column(ColumnType::Number, 'Hours per Day'));

// add the rows: you can also use addRows to add an array of rows
$data->addRow(['Work',     11]);
$data->addRow(['Eat',      2]);
$data->addRow(['Commute',  2]);
$data->addRow(['Watch TV', 2]);
$data->addRow(['Sleep',    7]);
 php
$data = DataTable::fromArray(
    [
        ['Task', 'Hours per Day'],
        ['Work',     11],
        ['Eat',      2],
        ['Commute',  2],
        ['Watch TV', 2],
        ['Sleep',    7]
    ]
);
 php
// draw the chart; you can omit the id if you want to draw all charts
echo $chartService->render('dailyActivities');