Note that there are some explanatory texts on larger screens.

plurals
  1. POPHP jpgraph won't display multiple graphs
    primarykey
    data
    text
    <p>I've been trying to display two graphs on the one screen using jpgraph php code. According to jpgraph this can be completed by following one of two methods see <a href="http://jpgraph.net/doc/howto1.php" rel="nofollow" title="JpGraph">here</a>. While I can get any one of the four graphs to appear individually using $graph->Stroke(); I can't for the life of me work out how to display them together using either of the methods prescribed in the jpgraph example. The code for mgraph in the attached document looks correct to me but nothing will appear. Any help would be appreciated. Cheers </p> <pre><code> &lt;?php require("sess_start.php");?&gt;&lt;?php if ($_GET[sessid] &gt; 0) { //show page if user has a valid session ?&gt;&lt;?php // AppServerType:PHP4 require("./../adodb/adodb.inc.php"); require("./../Connections/m_water.php"); include ("./../jpgraph/src/jpgraph.php"); include ("./../jpgraph/src/jpgraph_line.php"); $ydata = array(2,4,6,8,10,12,14,16,18,20,22,24,26,28,30,32); $datax = array("1","2","3","4","5","6","7","8","9","10","11","12"); $max_inshore_effort = array("8", "8", "8", "8", "8", "8", "8", "8", "8", "8", "8", "8", "8", "8", "8", "8"); $max_offshore_effort = array("12", "12", "12", "12", "12", "12", "12", "12", "12", "12", "12", "12", "12", "12", "12", "12"); //-------------------------------------------------------------------------------------------------------------------------------- //GRAPH 1 // Create the graph. These two calls are always required //$graph = new Graph(550,400,"auto"); //$graph-&gt;SetScale("textlin"); //$graph-&gt;xaxis-&gt; SetTickLabels($datax); //$graph-&gt;xaxis-&gt;SetFont(FF_FONT2); //$graph-&gt;yaxis-&gt;SetFont(FF_FONT2); // Create the linear plot //$lineplot=new LinePlot($ydata); // Add the plot to the graph //$graph-&gt;Add($lineplot); //$lineplot-&gt;SetColor('#DC143C'); //set the colour of the line this case dark red //$lineplot-&gt;SetWeight(1.5); // set the thickness of the line //$lineplot-&gt;SetLegend('Total group effort'); // add a description to the legend //$lineplot-&gt;mark-&gt;SetType(MARK_FILLEDCIRCLE,'',1.0); // determine what type of marker is used //$lineplot-&gt;mark-&gt;SetType(MARK_SQUARE,'',2.0); // determine what type of marker is used //$lineplot-&gt;mark-&gt;SetSize(6); //$lineplot-&gt;mark-&gt;SetColor('#000000'); // determine the colour of the outer line surrounding the marker //$lineplot-&gt;mark-&gt;SetFillColor('#DC143C'); // set the fill for the marker //$graph-&gt;img-&gt;SetMargin(60,60,50,80); //$graph-&gt;xaxis-&gt;SetTitle('Round', 'center'); //$graph-&gt;yaxis-&gt;SetTitle('Total group effort', 'center'); //$graph-&gt;xaxis-&gt;SetTitleMargin(12); //$graph-&gt;yaxis-&gt;SetTitleMargin(32); // Setup a nice title with a striped bevel background //$graph-&gt;title-&gt;Set("State of Area 1 (Inshore)"); // alter the title heading //$graph-&gt;title-&gt;SetFont(FF_ARIAL,FS_BOLD,16); // alter the font of the title and size //$graph-&gt;title-&gt;SetColor('#FFFFFF'); // alter the colour of the title //$graph-&gt;SetTitleBackground('#4682B4',TITLEBKG_STYLE1,TITLEBKG_FRAME_BEVEL); // insert 3d bevel for title //$graph-&gt;SetTitleBackgroundFillStyle(TITLEBKG_FILLSTYLE_HSTRIPED,'blue','darkgreen'); // insert alternating horizontal lines across title fill box; //$graph-&gt;tabtitle-&gt;SetColor('navy','lightyellow','navy'); //$graph-&gt;yaxis-&gt;SetColor('#000000'); //set the colour of the y axis //$graph-&gt;xaxis-&gt;SetColor('#000000'); // set the colour of the x axis // Change the fonts of the axis and title //$graph-&gt;title-&gt;SetFont(FF_FONT1,FS_BOLD); //$graph-&gt;yaxis-&gt;title-&gt;SetFont(FF_FONT1,FS_BOLD); //$graph-&gt;xaxis-&gt;title-&gt;SetFont(FF_FONT1,FS_BOLD); //$graph-&gt;xaxis-&gt;SetTickSide(SIDE_DOWN); //$graph-&gt;xaxis-&gt;SetLabelMargin(6); //$graph-&gt;yaxis-&gt;SetTickSide(SIDE_LEFT); //$graph-&gt;yaxis-&gt;SetLabelMargin(8); //$lineplot-&gt;SetColor("#DC143C"); // Add a second axis displaying the maximum effort allowed for inshore area //$p1 = new LinePlot($max_inshore_effort); //$graph-&gt;Add($p1); //$p1-&gt;SetColor("#2E8B57"); //$p1-&gt;SetLegend('Max effort inshore to stay abundant'); //$p1-&gt;SetWeight(3); // set the thickness of the line //$p1-&gt;SetCenter(); //$p1-&gt;SetStyle('longdashed'); //$graph-&gt;SetShadow(); // Adjust the legend position //$graph-&gt;legend-&gt;SetLayout(LEGEND_HOR); //$graph-&gt;legend-&gt;Pos(0.15,0.94,"bottom","center"); //adjust the position of the legend on the graph //$graph-&gt;legend-&gt;SetFillColor('#D3D3D3'); //-------------------------------------------------------------------------------------------------------------------------------- //GRAPH 2 // Create the graph. These two calls are always required $graph2 = new Graph(550,400,"auto"); $graph2-&gt;SetScale("textlin"); $graph2-&gt;xaxis-&gt; SetTickLabels($datax); $graph2-&gt;xaxis-&gt;SetFont(FF_FONT2); $graph2-&gt;yaxis-&gt;SetFont(FF_FONT2); // Create the linear plot $lineplot2=new LinePlot($ydata); // Add the plot to the graph $graph2-&gt;Add($lineplot2); $lineplot2-&gt;SetColor('#DC143C'); //set the colour of the line this case dark red $lineplot2-&gt;SetWeight(1.5); // set the thickness of the line $lineplot2-&gt;SetLegend('Total group effort'); // add a description to the legend //$lineplot-&gt;mark-&gt;SetType(MARK_FILLEDCIRCLE,'',1.0); // determine what type of marker is used $lineplot2-&gt;mark-&gt;SetType(MARK_SQUARE,'',2.0); // determine what type of marker is used $lineplot2-&gt;mark-&gt;SetSize(6); $lineplot2-&gt;mark-&gt;SetColor('#000000'); // determine the colour of the outer line surrounding the marker $lineplot2-&gt;mark-&gt;SetFillColor('#DC143C'); // set the fill for the marker $graph2-&gt;img-&gt;SetMargin(60,60,50,80); $graph2-&gt;xaxis-&gt;SetTitle('Round', 'center'); $graph2-&gt;yaxis-&gt;SetTitle('Total group effort', 'center'); $graph2-&gt;xaxis-&gt;SetTitleMargin(12); $graph2-&gt;yaxis-&gt;SetTitleMargin(32); // Setup a nice title with a striped bevel background $graph2-&gt;title-&gt;Set("State of Area 1 (Offshore)"); // alter the title heading $graph2-&gt;title-&gt;SetFont(FF_ARIAL,FS_BOLD,16); // alter the font of the title and size $graph2-&gt;title-&gt;SetColor('#FFFFFF'); // alter the colour of the title $graph2-&gt;SetTitleBackground('#4682B4',TITLEBKG_STYLE1,TITLEBKG_FRAME_BEVEL); // insert 3d bevel for title //$graph-&gt;SetTitleBackgroundFillStyle(TITLEBKG_FILLSTYLE_HSTRIPED,'blue','darkgreen'); // insert alternating horizontal lines across title fill box; $graph2-&gt;tabtitle-&gt;SetColor('navy','lightyellow','navy'); $graph2-&gt;yaxis-&gt;SetColor('#000000'); //set the colour of the y axis $graph2-&gt;xaxis-&gt;SetColor('#000000'); // set the colour of the x axis // Change the fonts of the axis and title $graph2-&gt;title-&gt;SetFont(FF_FONT1,FS_BOLD); $graph2-&gt;yaxis-&gt;title-&gt;SetFont(FF_FONT1,FS_BOLD); $graph2-&gt;xaxis-&gt;title-&gt;SetFont(FF_FONT1,FS_BOLD); $graph2-&gt;xaxis-&gt;SetTickSide(SIDE_DOWN); $graph2-&gt;xaxis-&gt;SetLabelMargin(6); $graph2-&gt;yaxis-&gt;SetTickSide(SIDE_LEFT); $graph2-&gt;yaxis-&gt;SetLabelMargin(8); $lineplot2-&gt;SetColor("#DC143C"); // Add a second axis displaying the maximum effort allowed for inshore area $p12 = new LinePlot($max_offshore_effort); $graph2-&gt;Add($p12); $p12-&gt;SetColor("#0000CD"); $p12-&gt;SetLegend('Max effort offshore to stay abundant'); $p12-&gt;SetWeight(3); // set the thickness of the line $p12-&gt;SetCenter(); $p12-&gt;SetStyle('longdashed'); $graph2-&gt;SetShadow(); // Adjust the legend position $graph2-&gt;legend-&gt;SetLayout(LEGEND_HOR); $graph2-&gt;legend-&gt;Pos(0.15,0.94,"bottom","center"); //adjust the position of the legend on the graph $graph2-&gt;legend-&gt;SetFillColor('#D3D3D3'); //$handle2 = $graph2-&gt;Stroke( _IMG_HANDLER); // Display the individual graph $graph-&gt;Stroke(); ?&gt; ?&gt; // Create a combined graph //$mgraph = new MGraph(); //$xpos1=3;$ypos1=3; //$xpos2=3;$ypos2=200; //$mgraph-&gt;Add($graph); //$mgraph-&gt;Add($graph2,$xpos2,$ypos2); //$mgraph-&gt;Stroke(); ?&gt; &lt;?php } //show page if user has a valid session ?&gt; </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload