PHP Classes

File: example/public/pie.php

Recommend this page to a friend!
  Packages of Lucas de Oliveira   FusionCharts PHP Class API   example/public/pie.php   Download  
File: example/public/pie.php
Role: Example script
Content type: text/plain
Description: Example script
Class: FusionCharts PHP Class API
Generate graphical charts using FusionCharts API
Author: By
Last change: refactor code and add namespaces
Initial commit
Date: 10 years ago
Size: 625 bytes
 

 

Contents

Class file image Download
<?php

use FusionCharts\Chart\Pie;
use FusionCharts\Tag\Set;

// Data from db
$values = array(
    'Jan' => 100,
    'Feb' => 200,
    'Mar' => 150,
    'Apr' => 210
);

$chart = new Pie('chart-container');

$chart
    ->setName('Chart Pie Example')
    ->setWidth(800)
    ->setHeight(400)
    ->setAttribute('showlegend', '1')
    ->setAttribute('showlabels', '0');

$slice = new Set();
foreach ($values as $name => $value){
    $slice
        ->setAttribute('issliced', '1')
        ->setAttribute('label', $name)
        ->setAttribute('value', $value);

    $chart->addSlice($slice);
}

// render chart in the index.php