Register Lost your password?
Full api documentation: full api documentation FREE version full api documentation PRO version

public function addChart(array paramsChart)

This method allows for the insertion of dynamical charts and graphs in your Word document. One may choose different types of graphs: pie charts, bar charts, etcetera in 2D or 3D (only PRO version).

Parameters

$paramsChart

  • ‘data’ (array)
  • ‘type’ (chart type): pieChart, pie3DChart, barChart, colChart, bar3DChart, col3DChart
  • ‘title’ (chart title) : ‘title’,
  • ‘cornerX’ (charts 3d, angle with respect to the axis X) : 20, 30, …
  • ‘cornerY’ (charts 3d, angle with respect to the axis Y) : 20, 30, …
  • ‘cornerP’ (charts 3d, angle with respect to the perspective) : 20, 30, …
  • ‘color’ (chart color) : 1,2,3,…
  • ‘textWrap’ (text wrap): 0 (inline), 1 (square), 2 (front), 3 (back), 4 (up and bottom), 5 (clear)
  • ‘groupBar’ (grouping of results): clustered, stacked
  • ’sizeX’ (size width chart, in centimeters)=> 10
  • ’sizeY’ (size height chart, in centimeters)=> 10
  • ‘jc’ (alignment) : right, center
  • ’showPercent’ (show chart percentage): 0, 1
  • ‘font’ (A specific size and style of font type within a type family. Example ‘Times New Roman’, ‘Arial’,…)

Examples

Example 1


require_once 'classes/CreateDocx.inc';

$docx = new CreateDocx();

$legends = array(
    'legend1' => array(10, 11, 12),
    'legend2' => array(0, 1, 2),
    'legend3' => array(40, 41, 42)
);

$paramsChart = array(
    'data' => $legends,
    'type' => 'pieChart',
    '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');


Example 2 Version Pro


require_once 'classes/CreateDocx.inc';

$docx = new CreateDocx();

$legends = array(
    'legend1' => array(10, 11, 12),
    'legend2' => array(0, 1, 2),
    'legend3' => array(40, 41, 42)
);

$paramsChart = array(
    'data' => $legends,
    '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');

    One Response

  • juan

    Please commit some barchart stacked examples!

    Thanks a lot!!!

Your comments