Forum


Replies: 11   Views: 3089
Change data chart from xlsx
Topic closed:
Please note this is an old forum thread. Information in this post may be out-to-date and/or erroneous.
Every phpdocx version includes new features and improvements. Previously unsupported features may have been added to newer releases, or past issues may have been corrected.
We encourage you to download the current phpdocx version and check the Documentation available.

Posted by admin  · 28-11-2017 - 07:51

Hello,

You need to use the same data structure than the addChart method for each chart type. For example, for the piechart generated by the included sample Core/addChart/sample_1.php, you can replace the data using this code:

$data = array();
$data[0] = array(
    'title' => 'New title',
    'values' => array(
        array(30),
        array(30),
        array(40),
    ),
);
$data[1] = array(
    'title' => 'Other title',
    'values' => array(
        array(50),
        array(40),
        array(30),
    ),
);

$docx->replaceChartData($source, $target, $data);

Regards.