我一直在尝试使用 jpgraph php 代码在一个屏幕上显示两个图形。根据 jpgraph,这可以通过以下两种方法之一完成,请参见此处。虽然我可以使用 $graph->Stroke(); 单独显示四个图表中的任何一个;我一生都无法弄清楚如何使用 jpgraph 示例中规定的任何一种方法将它们一起显示。附件文档中的 mgraph 代码对我来说看起来是正确的,但什么都不会出现。任何帮助,将不胜感激。干杯
<?php require("sess_start.php");?><?php if ($_GET[sessid] > 0) { //show page if user has a valid session ?><?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->SetScale("textlin");
//$graph->xaxis-> SetTickLabels($datax);
//$graph->xaxis->SetFont(FF_FONT2);
//$graph->yaxis->SetFont(FF_FONT2);
// Create the linear plot
//$lineplot=new LinePlot($ydata);
// Add the plot to the graph
//$graph->Add($lineplot);
//$lineplot->SetColor('#DC143C'); //set the colour of the line this case dark red
//$lineplot->SetWeight(1.5); // set the thickness of the line
//$lineplot->SetLegend('Total group effort'); // add a description to the legend
//$lineplot->mark->SetType(MARK_FILLEDCIRCLE,'',1.0); // determine what type of marker is used
//$lineplot->mark->SetType(MARK_SQUARE,'',2.0); // determine what type of marker is used
//$lineplot->mark->SetSize(6);
//$lineplot->mark->SetColor('#000000'); // determine the colour of the outer line surrounding the marker
//$lineplot->mark->SetFillColor('#DC143C'); // set the fill for the marker
//$graph->img->SetMargin(60,60,50,80);
//$graph->xaxis->SetTitle('Round', 'center');
//$graph->yaxis->SetTitle('Total group effort', 'center');
//$graph->xaxis->SetTitleMargin(12);
//$graph->yaxis->SetTitleMargin(32);
// Setup a nice title with a striped bevel background
//$graph->title->Set("State of Area 1 (Inshore)"); // alter the title heading
//$graph->title->SetFont(FF_ARIAL,FS_BOLD,16); // alter the font of the title and size
//$graph->title->SetColor('#FFFFFF'); // alter the colour of the title
//$graph->SetTitleBackground('#4682B4',TITLEBKG_STYLE1,TITLEBKG_FRAME_BEVEL); // insert 3d bevel for title
//$graph->SetTitleBackgroundFillStyle(TITLEBKG_FILLSTYLE_HSTRIPED,'blue','darkgreen'); // insert alternating horizontal lines across title fill box;
//$graph->tabtitle->SetColor('navy','lightyellow','navy');
//$graph->yaxis->SetColor('#000000'); //set the colour of the y axis
//$graph->xaxis->SetColor('#000000'); // set the colour of the x axis
// Change the fonts of the axis and title
//$graph->title->SetFont(FF_FONT1,FS_BOLD);
//$graph->yaxis->title->SetFont(FF_FONT1,FS_BOLD);
//$graph->xaxis->title->SetFont(FF_FONT1,FS_BOLD);
//$graph->xaxis->SetTickSide(SIDE_DOWN);
//$graph->xaxis->SetLabelMargin(6);
//$graph->yaxis->SetTickSide(SIDE_LEFT);
//$graph->yaxis->SetLabelMargin(8);
//$lineplot->SetColor("#DC143C");
// Add a second axis displaying the maximum effort allowed for inshore area
//$p1 = new LinePlot($max_inshore_effort);
//$graph->Add($p1);
//$p1->SetColor("#2E8B57");
//$p1->SetLegend('Max effort inshore to stay abundant');
//$p1->SetWeight(3); // set the thickness of the line
//$p1->SetCenter();
//$p1->SetStyle('longdashed');
//$graph->SetShadow();
// Adjust the legend position
//$graph->legend->SetLayout(LEGEND_HOR);
//$graph->legend->Pos(0.15,0.94,"bottom","center"); //adjust the position of the legend on the graph
//$graph->legend->SetFillColor('#D3D3D3');
//--------------------------------------------------------------------------------------------------------------------------------
//GRAPH 2
// Create the graph. These two calls are always required
$graph2 = new Graph(550,400,"auto");
$graph2->SetScale("textlin");
$graph2->xaxis-> SetTickLabels($datax);
$graph2->xaxis->SetFont(FF_FONT2);
$graph2->yaxis->SetFont(FF_FONT2);
// Create the linear plot
$lineplot2=new LinePlot($ydata);
// Add the plot to the graph
$graph2->Add($lineplot2);
$lineplot2->SetColor('#DC143C'); //set the colour of the line this case dark red
$lineplot2->SetWeight(1.5); // set the thickness of the line
$lineplot2->SetLegend('Total group effort'); // add a description to the legend
//$lineplot->mark->SetType(MARK_FILLEDCIRCLE,'',1.0); // determine what type of marker is used
$lineplot2->mark->SetType(MARK_SQUARE,'',2.0); // determine what type of marker is used
$lineplot2->mark->SetSize(6);
$lineplot2->mark->SetColor('#000000'); // determine the colour of the outer line surrounding the marker
$lineplot2->mark->SetFillColor('#DC143C'); // set the fill for the marker
$graph2->img->SetMargin(60,60,50,80);
$graph2->xaxis->SetTitle('Round', 'center');
$graph2->yaxis->SetTitle('Total group effort', 'center');
$graph2->xaxis->SetTitleMargin(12);
$graph2->yaxis->SetTitleMargin(32);
// Setup a nice title with a striped bevel background
$graph2->title->Set("State of Area 1 (Offshore)"); // alter the title heading
$graph2->title->SetFont(FF_ARIAL,FS_BOLD,16); // alter the font of the title and size
$graph2->title->SetColor('#FFFFFF'); // alter the colour of the title
$graph2->SetTitleBackground('#4682B4',TITLEBKG_STYLE1,TITLEBKG_FRAME_BEVEL); // insert 3d bevel for title
//$graph->SetTitleBackgroundFillStyle(TITLEBKG_FILLSTYLE_HSTRIPED,'blue','darkgreen'); // insert alternating horizontal lines across title fill box;
$graph2->tabtitle->SetColor('navy','lightyellow','navy');
$graph2->yaxis->SetColor('#000000'); //set the colour of the y axis
$graph2->xaxis->SetColor('#000000'); // set the colour of the x axis
// Change the fonts of the axis and title
$graph2->title->SetFont(FF_FONT1,FS_BOLD);
$graph2->yaxis->title->SetFont(FF_FONT1,FS_BOLD);
$graph2->xaxis->title->SetFont(FF_FONT1,FS_BOLD);
$graph2->xaxis->SetTickSide(SIDE_DOWN);
$graph2->xaxis->SetLabelMargin(6);
$graph2->yaxis->SetTickSide(SIDE_LEFT);
$graph2->yaxis->SetLabelMargin(8);
$lineplot2->SetColor("#DC143C");
// Add a second axis displaying the maximum effort allowed for inshore area
$p12 = new LinePlot($max_offshore_effort);
$graph2->Add($p12);
$p12->SetColor("#0000CD");
$p12->SetLegend('Max effort offshore to stay abundant');
$p12->SetWeight(3); // set the thickness of the line
$p12->SetCenter();
$p12->SetStyle('longdashed');
$graph2->SetShadow();
// Adjust the legend position
$graph2->legend->SetLayout(LEGEND_HOR);
$graph2->legend->Pos(0.15,0.94,"bottom","center"); //adjust the position of the legend on the graph
$graph2->legend->SetFillColor('#D3D3D3');
//$handle2 = $graph2->Stroke( _IMG_HANDLER);
// Display the individual graph
$graph->Stroke();
?>
?>
// Create a combined graph
//$mgraph = new MGraph();
//$xpos1=3;$ypos1=3;
//$xpos2=3;$ypos2=200;
//$mgraph->Add($graph);
//$mgraph->Add($graph2,$xpos2,$ypos2);
//$mgraph->Stroke();
?>
<?php } //show page if user has a valid session ?>