PHP code for Pie Charts

Asked By 0 points N/A Posted on -
qa-featured

Hello Techyv Friends,

I would like to have a few samples of PHP code for Pie Charts.

I am new to PHP coding, so please do the needful for providing me the coding along with a description, so that I can understand the same.

Please Help.

Thanks & Regards,

Jolie Angeliname

SHARE
Answered By 0 points N/A #169328

PHP code for Pie Charts

qa-featured
These are two samples you can see which are all you need to produce charts;
 
This one is a pie chart with multiple customizations
 
<? 
  include( 'chartlogix.inc.php' ); 
 
  $pie = new PieChart(); 
 
  //—- THE STYLE 
 
  $pie->setBackground( 'EEEEFF', 'DDDDEE' ); 
  $pie->setPadding( 20 ); 
 
  $pie->setTitleStyle( 'arial.ttf', 15, '000000' ); 
  $pie->setTitlePosition( 0, 0 ); 
 
  $pie->setLegendWidth( 40.00 ); 
  $pie->setLegendTextStyle( 'arial.ttf', 12, 'FFFFFF', 10 ); 
  $pie->setLegendKeyStyle( 12, 5 ); 
  $pie->setLegendBoxStyle( '333366', '000000', 10 ); 
  $pie->setLegendPosition( 1, 0 ); 
 
  $pie->set3DEdgeStyle( 20, 50, false ); 
 
  $pie->setHoleSize( 40 ); 
 
  //—- THE DATA 
 
  $pie->setTitle( 'ChartLogix Pie Chart' ); 
 
  $pie->addData( 'Apples', 593, '99FF00' ); 
  $pie->addData( 'Strawberries', 581, 'FF6600' ); 
  $pie->addData( 'Plums', 395, '9900CC' ); 
  $pie->addData( 'Bananas', 332, 'FFCC00' ); 
  $pie->addData( 'Grapes', 176, '009900' ); 
  $pie->addData( 'Others', 300, 'AAAAAA' ); 
 
  //—- DRAW PNG
 
  $pie->drawPNG( 500, 400 ); 
?>
 
 
This is for pie charts which use default style
 
 
<? 
  include( 'chartlogix.inc.php' ); 
    
  $pie = new PieChart(); 
    
  $pie->setTitle( "ChartLogix Pie Chart" ); 
    
  $pie->addData( 'Bananas', 420, 'FFCC00' ); 
  $pie->addData( 'Apples', 400, '99FF00' ); 
  $pie->addData( 'Strawberries', 210, 'FF6666' ); 
  $pie->addData( 'Grapes', 350, '009900' ); 
  $pie->addData( 'Plums', 100, '9900CC' ); 
  $pie->addData( 'Others', 190, 'AAAAAA' ); 
    
  $pie->drawPNG( 500, 400 ); 
?>

Related Questions