ASE Home Page Products Download Purchase Support About ASE
ChartDirector Support
Forum HomeForum Home   SearchSearch

Message ListMessage List     Post MessagePost Message

  Using Chart Director with PHP
Posted by RogerWilco on Apr-23-2011 02:41
I was asked to build a PHP front-end for displaying reports built with Chart Director. In short, I was wondering how this was accomplished?

If a user clicks on a submit button on a web page, can PHP then be used to provide data to Chart Director and then ultimately display the reports on the web?

I have a lot to learn in a very short time. Thank you for any responses.

  Re: Using Chart Director with PHP
Posted by Peter Kwan on Apr-25-2011 15:39
Hi RogerWilco,

I assume you are creating a "report" that may contain some HTML (like some text, tables), as well as charts.

ChartDirector can be used to generate the charts.

There are many methods to achieve what you need. For example, when the user press the submit button, a PHP script can be used to generate the HTML report. An example is like:

<html><body>
<H1>My First Report</H1>
<?php
$user_data_1 = $_REQUEST["aaa"];
$user_data_2 = $_REQUEST["bbb"];
echo "Hi, user has submitted $user_data_1 and $user_data_2<br>";
echo "... some more HTML content here ...<br>";
?>
<!-- chart generated by ChartDirector - the user data is passed to the script as query parameters-->
<img src="createMyChart.php?aaa=<?php echo $user_data_1>&bbb=<?php echo $user_data_2?>">
</body></html>

In "createMyChart.php", you can then create the chart. As a test, you can just put the "Simple Bar Chart" sample code ("simplebar.php") in "createMyChart.php". After this works, you can modify the code to use your real data.

Hope this can help.

Regards
Peter Kwan

  Re: Using Chart Director with PHP
Posted by RogerWilco on Apr-25-2011 21:49
Thanks Peter. This is what I was looking for. :-)