News
Creating a 3D pie chart with PHPDocX
- Jun 06, 2011
Creating a Pie Chart is easy: you just have to pass as parameters a data array, the type (pie3DChart for this particular example) and some additional formatting info (like size, alignment, ...).
Sample code:
require_once '../../classes/CreateDocx.inc';
$docx = new CreateDocx();
// Legends of the Pie Chart
$legends = array(
'legend1' => array(10),
'legend2' => array(0),
'legend3' => array(40)
);
// Custom the Pie Chart
$paramsChart = array(
'data' => $legends,
// If you don't need a 3D Pie Chart, you can use 'pieChart' instead
'type' => 'pie3DChart',
'title' => 'Title',
'cornerX' => 20,
'cornerY' => 20,
'cornerP' => 30,
'color' => 2,
'textWrap' => 0,
'sizeX' => 10,
'sizeY' => 10,
'jc' => 'right',
'showPercent' => 1,
'font' => 'Times New Roman'
);
$docx->addGraphic($paramsChart);
$docx->createDocx('example_chart');