It is obvious that a “half decent” application to generate reports has to include a tool for the creation of charts and graphs on the fly, so PHPDOCX could not do less than that.
In fact PHPDOCX is a pretty sophisticated tool to that regard and as we show below is very simple to generate a nice chart from some data that could be extracted from a database, a spreadsheet or elsewhere.

In this example we will concentrate in creating a pie chart that plots the following sample data:

Do you like “paella”?
Like paella: 50%
Don´t like paella: 10%
What the f*** is a paella? : 40%
Notice: paella is a typical Spanish rice dish.


require_once('../classes/cCreateDocx.inc');
$objDocx = new cCreateDocx();
$arrDatos = array( 'like paella' => array(50), 'do not like paella' => array(10), 'what the f***…?' => array(40) );
$arrArgs = array('data' => $arrDatos, 'type' => 'pieChart', 'title' => 'Do you like paella?', 'showPercent' => 1 );
$objDocx->fAddGraphic($arrArgs);
$objDocx->fCreateDocx('simple_piechart');



That generates this pie chart.

If you prefer a 3D version of this pie chart you need the Pro version but the required code is not much different:


require_once('../classes/cCreateDocx.inc');
$objDocx = new cCreateDocx();
$arrDatos = array( 'like paella' => array(50), 'do not like paella' => array(10), 'what the f***…?' => array(40) );
$arrArgs = array('data' => $arrDatos, 'type' => 'pie3DChart', 'title' => 'Do you like paella?', 'showPercent' => 1 );
$objDocx->fAddGraphic($arrArgs);
$objDocx->fCreateDocx('simple_piechart');