Implementing multiple graph in a single page is easier than you think.
You can achieve it in two ways,
First way would be combining two graphs and displaying in a page, this is a normal/usual way.
Here you can you go to see how to use it.
Second way is using the image tag here i will explain how to use it
first you decide which graph you want to use. here i take the bar graph but it doesn't matter what graph you are going to draw/implement.
here you can find the sample bargraph and save it as bargraph.php
Now we are going to draw multiple graph, here we are going to draw two graphs.
first create a image tag were the source path refers to the bargraph.php like this
<html>
<head></head>
<body>
<img src="bargraph.php">
<img src="bargraph.php">
</body>
</html>
and save it as multipleGraph.php
thats it we have created a page containing two graphs in it.
Creating dynamic graph is also easier
simply pass the values for the variable "$data" in bargraph.php as below
( here we are using "-" to differentiate between values)
<img src="bargraph.php?data=1-2-3">
and change the variable "$data" in bargraph.php page as this
$part = explode("-",$_GET['data']);
$data = array();
for($i=0;$i<count($part);$i++)
{
$data[] = $part[$i];
}
thats it you have created dynamic graph.
Hope this is useful.
Thanks, this really helped me to get multiple graphs on page with second options, more people need to see it!
ReplyDelete