I know how to add charts on PHPExcel, but I also need to insert charts on a docx file. Is it possible to manipulate charts with phpoffice/phpword?
If it's not possible, do you know a good library for the job?
I know how to add charts on PHPExcel, but I also need to insert charts on a docx file. Is it possible to manipulate charts with phpoffice/phpword?
If it's not possible, do you know a good library for the job?
Yes it is possible to add charts in phpoffice. The problem is the documentation hasn't been completed yet.
It's not actually possible to add chart in a PHPWord Document. But the feature is in the pipe (follow this ticket #123).
But you can use of one of some libraries used (actually and in the future) by PHPExcel : PHP Charting Libraries . Actually, PHPExcel just use JpGraph for rendering some graphs.
Some example from official github, hope this could answer your question :)
PHPWord : https://github.com/PHPOffice/PHPWord/blob/master/samples/Sample_32_Chart.php
PHPExcel : https://github.com/PHPOffice/PHPExcel/tree/master/Examples
I don't know the library, but you can probably generate image in php (use PHP GD or imagemagick for example) and insert generated image into docx file.
You can add a chart, but its a bit limited and there are some hard codings in what's been created so far.
Example of what you can do: http://elumina.co/libs/PHPWord-master/samples/Sample_32_Chart.php
Source Code:https://github.com/PHPOffice/PHPWord/blob/master/samples/Sample_32_Chart.php
Some modification is needed to the classes to get certain graph options to work as these options were hard coded https://github.com/PHPOffice/PHPWord/issues/957
Can't edit the data https://github.com/PHPOffice/PHPWord/issues/956