Forum


Replies: 17   Views: 5019
Custom graph
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 eyalmarkovich  · 18-04-2013 - 21:57

Hi



I am new to phpdocx so hopefully this is not a trivial question.



Assume I have a graph template that I want to duplicate.



Is there a way to use a Graph in a template (as opposite to a place holder) and just replace the data (caption, titles, values etc)?



If not, how can I create a grpah similar to the one below?



Example: http://www.totalapm.com/tmp/graph1.png





The problems that I have duplicating this graph:



1. I can't seems to have an option for just one color



2. I can't find how to display the text (Item 1, Item 2 etc) next to the bar



3. I don't need legend



4. I can't control the space. etc



This is actually, the default bar in excel



Thanks in advance



Eyal


Posted by jorgelj1980  · 19-04-2013 - 09:02

Hello,



That function, replace values in a existing graph, is only availabe on PHPDocX Pro + and PHPDocX Corporate.



Regards.


Posted by eyalmarkovich  · 19-04-2013 - 16:07

I purchased PHPDocX Pro - do you have an example I can use for replace values in graph?


Posted by jorgelj  · 22-04-2013 - 09:53

Hello,



That method is only available on PHPDocX Pro+ and PHPDocX Corporate.



Regards.


Posted by eyalmarkovich  · 22-04-2013 - 15:27

Thanks.



Before I upgrade to Pro +, can you please confirm that I will be able to create the example graph that I provided an example above?



I will need the ability to change the number of bars and the text associate with each bar.



Thanks



Eyal


Posted by jorgelj  · 23-04-2013 - 09:17

Hello,



This is a simple example to replace values in a chart using PHPDocX Pro+ or PHPDocX Corporate:



-------------------------------------



require_once '../../classes/CreateDocx.inc';



$completedData = array(

    'legend' => array('Completed', 'Data', 'Example'),

    'data 1' => array('1', 10, 51),

    'data 2' => array('2', 6, 3),

    'data 3' => array('10', 3, 17),

    'data 4' => array('25', 70, 20)

);



$docx = new DocxUtilities();

$source = "../files/example_line_Chart.docx";

$target = '../docx/example_line_Chart_replace_data.docx';

$data = array(

    0 => $completedData,

    1 => $completedData,

);

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



-------------------------------------



Regards.


Posted by eyalmarkovich  · 23-04-2013 - 17:53

Great, this looks good.



Can you also confirm that there is a similar functinality for graph within a template?


Posted by eyalmarkovich  · 25-04-2013 - 15:37

Can you confirm Jorge?


Posted by jorgelj  · 26-04-2013 - 08:57

Hello,



Yes, you can use this function within a template.



Regards.


Posted by erainferno  · 17-05-2013 - 17:24

I am about to upgrade to Pro + for this feature, but first, how does this work with multiple charts?



Say, for example, I have 5 pie charts in a template. Using the function above, can I change each individually, or will it change all the charts to have the same data?


Posted by erainferno  · 17-05-2013 - 22:42

So I decided to get it anyway, and it does support multiple charts per page. However, I get an error.



Warning: unlink(datos81038513.xlsx) [<a href='function.unlink'>function.unlink</a>]: No such file or directory in C:\wamp\www\report\phpdocx\classes\DocxUtilities.inc on line 3320



Any experience with this? Research around the internet didn't wield much results.


Posted by jorgelj  · 20-05-2013 - 08:59

Hello,



DocxUtilites is included only in PHPDocX Pro+ and PHPDocX Corporate.



Regards.


Posted by erainferno  · 20-05-2013 - 15:13

I am well aware, that is why the error is with the creation of the datos.xlsx, and not with DocxUtilities.inc.



 


Posted by jorgelj  · 21-05-2013 - 09:06

Hello,



We've checked it and it's an error related to some versions of PHP about how they manage unlink and close on ZIP files. It's fixed on dev version, but you can contact us to get a quick fix (two classes have been changed to fix it http://www.phpdocx.com/contact).



Regards.


Posted by eyalmarkovich  · 08-02-2014 - 00:37

Hi



I am trying to use the example code you provided to create the following graph



http://www.totalapm.com/tmp/graph1.png:



require_once '../../classes/CreateDocx.inc';



$completedData = array(

    'legend' => array('Completed', 'Data', 'Example'),

    'data 1' => array('1', 10, 51),

    'data 2' => array('2', 6, 3),

    'data 3' => array('10', 3, 17),

    'data 4' => array('25', 70, 20)

);



$docx = new DocxUtilities();

$source = "../files/example_line_Chart.docx";

$target = '../docx/example_line_Chart_replace_data.docx';

$data = array(

    0 => $completedData,

    1 => $completedData,

);

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



However, while I see the data being replaced in the graph, the labels are not changed (for example, 'data 1', 'data 2' in your code )



I am also unable to dynamicly control the number of points in the graph.



Please help



Thanks



Eyal



 



 


Posted by jorgelj  · 10-02-2014 - 09:32

Hello,



We're checking the issue to be solved.



Regards.


Posted by trafficmaxx  · 20-05-2014 - 11:41

Hi,



I have the same problem. I am unable to replace the legend labels and I am unable to control the number of data points in the chart dynamically.



are there any news here?



Greetings,

trafficmaxx


Posted by tech@hurdman.ca  · 07-07-2015 - 20:18

Is there any update on this subject? 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 planned to be added at some point?