PHP code example of rockyangs / php-chart

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

    

rockyangs / php-chart example snippets




$data = array(
    '2005'  => '60',
    '2006' 	=> '90',
    '2007'  => '120',
    '2008'  => '160',
    '2009'  => '240',
    '2010'  => '300',
    '2011'  => '320',
    '2012'  => '400',
    '2013'	=> '540'
);
//Y坐标抽参数 步长 => 点数
$axisy = array(100, 6);			
$config = array(
    'data' 	=> $data,
    'axisy' => $axisy,
    'title' => 'Sample Broken Line Chart',
    'unit' => 'IP/次',
    't_fsize' => 18,
    't_font' => 0,
    'bg_size' => array(800, 600)
);

$chart = ChartFactory::create(BrokenChart::class, $config);
// show image in browser
$chart->showChart();
// save image to file
$chart->saveChart("{$dir}/broken-chart.png", 'png');
bash
composer install rockyangs/php-chart