_spaz Posted October 6, 2009 Share Posted October 6, 2009 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. Quote Link to comment https://forums.phpfreaks.com/topic/176763-display-graphs-on-1-page/ Share on other sites More sharing options...
Gayner Posted October 6, 2009 Share Posted October 6, 2009 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 Quote Link to comment https://forums.phpfreaks.com/topic/176763-display-graphs-on-1-page/#findComment-931976 Share on other sites More sharing options...
_spaz Posted October 6, 2009 Author Share Posted October 6, 2009 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. Quote Link to comment https://forums.phpfreaks.com/topic/176763-display-graphs-on-1-page/#findComment-932000 Share on other sites More sharing options...
mikesta707 Posted October 6, 2009 Share Posted October 6, 2009 post the code you have? If you have the same exact variable names on both pages that MIGHT interfere, but i would have to see some code to make a judgement Quote Link to comment https://forums.phpfreaks.com/topic/176763-display-graphs-on-1-page/#findComment-932003 Share on other sites More sharing options...
.josh Posted October 6, 2009 Share Posted October 6, 2009 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. Quote Link to comment https://forums.phpfreaks.com/topic/176763-display-graphs-on-1-page/#findComment-932007 Share on other sites More sharing options...
_spaz Posted October 6, 2009 Author Share Posted October 6, 2009 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(); ?> Quote Link to comment https://forums.phpfreaks.com/topic/176763-display-graphs-on-1-page/#findComment-932008 Share on other sites More sharing options...
.josh Posted October 6, 2009 Share Posted October 6, 2009 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. Quote Link to comment https://forums.phpfreaks.com/topic/176763-display-graphs-on-1-page/#findComment-932010 Share on other sites More sharing options...
_spaz Posted October 7, 2009 Author Share Posted October 7, 2009 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.... Quote Link to comment https://forums.phpfreaks.com/topic/176763-display-graphs-on-1-page/#findComment-932535 Share on other sites More sharing options...
_spaz Posted October 7, 2009 Author Share Posted October 7, 2009 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); ?> Quote Link to comment https://forums.phpfreaks.com/topic/176763-display-graphs-on-1-page/#findComment-932570 Share on other sites More sharing options...
.josh Posted October 7, 2009 Share Posted October 7, 2009 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? Quote Link to comment https://forums.phpfreaks.com/topic/176763-display-graphs-on-1-page/#findComment-932595 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.