Forum


Replies: 2   Views: 2743
Is it possible to change names od categories on chart - function replace_data?
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 andrzej.morun  · 19-12-2016 - 20:50

How can I change names od Series and Categories?

In advanced version phpdocx I use bellow code, but only values changes.

I need to change names od X axis. Is it possible?

require_once 'classes/DocxUtilities.inc';

$docx = new DocxUtilities();

$source = 'example_area_chart.docx';
$target = 'example_area_chart_replace_data.docx';

$completedData = array(
    'legend' => array('Seria 1', 'Seria 2', 'Temp'),
    'Marzec' => array(11, 10, 12),
    'Luty' => array(12, 6, 32),
    'Maj' => array(10, 3, 20),
    'Czerwiec' => array(25, 70, 20)
);

$data = array(
0 => $completedData,    
);

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

 

Posted by andrzej.morun  · 19-12-2016 - 21:05

Additional, can I control the number of data points in chart dynamically?

 It would be great to be able to replace the data in the chart, including the x-axis labels, and also be able to add additional data points to a table. Is this possible at this time? I have Advanced version phpdocx.

Posted by admin  · 20-12-2016 - 07:23

Hello,

The next version of phpdocx will add support to change titles, categories, series... (the current version only allows to replace existing data values) using the replaceChartData method; but not to add new data points.

Just as a workaround, if you use placeholders (or unique strings) as categories and other values, this method:

http://www.phpdocx.com/api-documentation/docxutilities/raw-search-and-replace-docx

allows to replace strings in any XML of the DOCX.

Regards.