|
Problem plotting variables with Chartdirector PHP |
Posted by Teo Mezger on Mar-30-2009 16:13 |
|
Hi everyone,
Im having problems with this chartdirector tool.
I have an page where some calculations in php are done. (user entrys and Mysql querrys)
In The second page I would like to have a graphik of the results, but the results are variables.
How can I do something like that?
Sorry about my english!
Thanx! |
Re: Problem plotting variables with Chartdirector PHP |
Posted by Peter Kwan on Mar-31-2009 02:24 |
|
Hi Teo,
You can pass your data to your second page. In the second page, you can create the chart with the data.
You can use any method you like to pass data. Common methods to pass data in web applications are using query parameters, session variables, cookies, etc.....
For example, in your first page, you may have a structure like:
$user_data_list = .....(a comma separated list of data, created from data entered by your user, or from data in mySQL, ....);
<!-- pass data as query parameter -->
<img src="createChart.php?xxxx=<?php echo $user_data_list ?>" >
Then in your second page "createChart.php", you can get the data as:
#get data from query parameter
$data = split(",", $_GET["xxxx"]);
.... plot the chart using $data .....
Hope this can help.
Regards
Peter Kwan |
Re: Problem plotting variables with Chartdirector PHP |
Posted by Teo Mezger on Mar-31-2009 17:35 |
|
Hi Peter, thank you very much for your time and help!
I tried what you said but unfortunately without success.
Ill post you a couple of lines of my code so you can follow me better.
#####index.php####
$B2009 = ($Preis1 + $Jahrkost1);
$B2010 = ($B2009 + $Jahrkost1);
$B2011 = ($B2010 + $Jahrkost1);
$E2009 = ($Preis2 - $Refundprogram + $Jahrkost2) ;
$E2010 = ($E2009 + $Jahrkost2) ;
$E2011 = ($E2010 + $Jahrkost2) ;
###############
Those variables come from calulations.
########## #####
<IMG SRC="http://localhost/elektroautos/graph.php?Benpack=<?php echo $BENpack?>&EVpack=<?php echo $EVpack?>">
###### so and my idea was to put those variables in an array like this:####
$BENpack = array("B2009", "B2010", "B2011", "B2012", "B2013", "B2014");
$EVpack = array("E2009", "E2010", "E2011", "E2012", "E2013", "E2014");
$BEN = compact ($BENpack);
$EV = compact ($EVpack);
###### graph.php#######
# The data for the line chart
$data1 = split(",", $_GET["BEN"]);
$data2 = split(",", $_GET["EV"]);
$labels = array("2009", "2010", "2011", "2012", "2013", "2014");
################
Could you please point me to the right direction whit this script?
Im still learning how to manage with php, but Im learning fast!
Thanks! |
Re: Problem plotting variables with Chartdirector PHP |
Posted by Peter Kwan on Apr-01-2009 01:26 |
|
Hi Teo,
First, you need to create a comma delimited list of your data. A comma delimted list is a text string containing your data values, separated by commas.
$BENpack = "$B2009, $B2010, $B2011, $B2012, $B2013, $B2014";
$EVpack = "$E2009, $E2010, $E2011, $E2012, $E2013, $E2014";
Then you may pass the list as query parameters:
<IMG SRC="http://localhost/elektroautos/graph.php?Benpack=<?php echo $BENpack ?>&EVpack=<?php echo $EVpack ?>">
In the "graph.php", please extract the query parameter back to arrays.
$data1 = split(",", $_GET["Benpack"]);
$data2 = split(",", $_GET["EVpack"]);
Hope this can help.
Regards
Peter Kwan |
Re: Problem plotting variables with Chartdirector PHP |
Posted by Teo Mezger on Apr-02-2009 21:33 |
|
Hey Peter, It worked as I wanted! I thank you very much for your time and help, and hope this formun helps tons of people!
best regards! |
|