Jump to content

Recommended Posts

Not sure if I'm posting in the correct area, but does anyone know how to put two graphs (2 different files) and display them on one page? 

 

I have a file called "graph1.php" and another called "graph2.php"

and I want them both displaying on "graphs.php"

 

I'm using jpgraphs to create the graphs.

Link to comment
https://forums.phpfreaks.com/topic/176763-display-graphs-on-1-page/
Share on other sites

Not sure if I'm posting in the correct area, but does anyone know how to put two graphs (2 different files) and display them on one page? 

 

I have a file called "graph1.php" and another called "graph2.php"

and I want them both displaying on "graphs.php"

 

I'm using jpgraphs to create the graphs.

 

 

 

just use include function and call em

Not sure if I'm posting in the correct area, but does anyone know how to put two graphs (2 different files) and display them on one page? 

 

I have a file called "graph1.php" and another called "graph2.php"

and I want them both displaying on "graphs.php"

 

I'm using jpgraphs to create the graphs.

 

 

 

just use include function and call em

 

Tried that but it will only display the first graph and not the second, both graphs use the same code but different SQL statements so I'm not sure if they are interfering with each other.

without looking at your code, my first guess is that those files are producing a raw image output.  You can do any number of things to have them on the same page.

 

- modify the output of the files to create an image file, and then include them with html image tags

- include them as iframe sources

- create code to take the images and create a new, merged image.

without looking at your code, my first guess is that those files are producing a raw image output.  You can do any number of things to have them on the same page.

 

- modify the output of the files to create an image file, and then include them with html image tags

- include them as iframe sources

- create code to take the images and create a new, merged image.

 

Here's the code I'm using for both Graphs,  how do I create the code to modify it to an image file?

 

<?php

include ("jpgraph.php" );

include ("jpgraph_pie.php");

 

mysql_connect("192.168.0.184","","");

// Select the database

$db_select=mysql_select_db("DB");

if (!$db_select)

{

  die ("Could not select the database:

<br />". mysql_error());

}

 

$query = "SELECT Job.name, COUNT(*) as count FROM JobMediaFile Left Join Job On Job.id = JobMediaFile.job_id GROUP BY job_id ORDER BY count desc LIMIT 10";

 

$result = mysql_query($query) or die (mysql_error());

 

while ($record = mysql_fetch_assoc($result)) {

 

$data[] = $record['count'];

$data_names[]=$record['name'];

//$job_id[] = $record['job_id'];

 

}

 

$graph  = new PieGraph (700,300);

$graph->SetShadow();

 

$graph->title-> Set("Top 10 Providers by Asset Volume");

 

$p1  = new PiePlot($data);

$p1->SetLegends($data_names);

$graph->Add( $p1);

$graph->Stroke();

?>

Well I don't know. 

 

You didn't post the relevant code.  You are using a 3rd party script.  The relevant code would be inside one of these files:

 

include ("jpgraph.php" );

include ("jpgraph_pie.php");

 

Your last line there is $graph->Stroke(); so I would start by looking for the Stroke() method in one of those files. 

 

Please do not post the files.  We aren't here to trudge through 3rd party scripts for people.  I suggest you try going to that script's support site for that sort of thing.

Well I don't know. 

 

You didn't post the relevant code.  You are using a 3rd party script.  The relevant code would be inside one of these files:

 

include ("jpgraph.php" );

include ("jpgraph_pie.php");

 

Your last line there is $graph->Stroke(); so I would start by looking for the Stroke() method in one of those files. 

 

Please do not post the files.  We aren't here to trudge through 3rd party scripts for people.  I suggest you try going to that script's support site for that sort of thing.

 

thx, I think you pointed me in the right direction....

Still having issues... I have two png files and still only one is showing up, what's the deal, is there's alernative code that I should use instead?

 

<?php

$im1 = imagecreatefrompng("/tmp/provbyvol.png");

$im2 = imagecreatefrompng("/tmp/failedassets.png");

header('Content-type: image/png');

imagepng($im1);

imagepng($im2);

?>

Still having issues... I have two png files and still only one is showing up, what's the deal, is there's alernative code that I should use instead?

 

<?php

$im1 = imagecreatefrompng("/tmp/provbyvol.png");

$im2 = imagecreatefrompng("/tmp/failedassets.png");

header('Content-type: image/png');

imagepng($im1);

imagepng($im2);

?>

 

If the images are being saved as files, why not just display them with regular html img tags?

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.