JpGraph で for ループを使用して、年次および月次のグラフを作成しようとしています。各グラフは 1 回しかインスタンス化できないことを読み、for ループが始まる前にグラフをインスタンス化することで、これに対応するコードを作成しました。コードは Stroke() 呼び出しの後に 1 つのグラフのみを生成し、それ以上のグラフは作成されません。何か案は?
$graph = new Graph(850,330);
$graph1 = new Graph(850,330);
$graph2 = new Graph(850,330);
$graph->SetScale('datint');
$graph1->SetScale('datint');
$graph2->SetScale('datint');
$graph->SetMargin(70,130,30,100);
$graph1->SetMargin(70,130,30,100);
$graph2->SetMargin(70,130,30,100);
$graph->xaxis->SetLabelFormatString('Y M d',true);
$graph1->xaxis->SetLabelFormatString('Y M d',true);
$graph2->xaxis->SetLabelFormatString('Y M d',true);
$graph->xaxis->SetLabelAngle(90);
$graph1->xaxis->SetLabelAngle(90);
$graph2->xaxis->SetLabelAngle(90);
foreach($dates as $dkey=>$dvalue){
$graph->title->Set("Transfer rate for ".$siteName." in ".$tUnits."/second");
$graph->subtitle->Set("Dates: ".$dvalueL." to ".$dvalueH." for ".$siteName." AND monflag is ".$monFlag.".");
$graph->yscale->ticks->Set(20, 10);
if($maxT < 10) {
$graph->yscale->ticks->Set(1,1);
}
else if(10 < $maxT && $maxT <= 1024) {
$graph->yscale->ticks->Set(10, 2);
} else if(1024 < $maxT && $maxT <= 1048576) {
$graph->yscale->ticks->Set(10, 5);
} else if(1048576 < $maxT && $maxT <= 1073741824) {
$graph->yscale->ticks->Set(20, 10);
}
$graph1->yscale->ticks->Set(20, 10);
if($maxC < 10) {
$graph1->yscale->ticks->Set(1,1);
} else if(10 < $maxC && $maxC <= 1024) {
$graph1->yscale->ticks->Set(10, 2);
} else if(1024 < $maxC && $maxC <= 1048576) {
$graph1->yscale->ticks->Set(10, 5);
} else if(1048576 < $maxC && $maxC <= 1073741824) {
$graph1->yscale->ticks->Set(20, 10);
}
$graph->SetMarginColor("#F0F0F0");
$graph->SetColor("#FFFFFF");
$graph1->title->Set("Compression ratio for ".$siteName);
$graph1->subtitle->Set("Dates: ".$dvalueL." to ".$dvalueH." for ".$siteName." AND monflag is ".$monFlag.".");
$graph1->SetMarginColor("#F0F0F0");
$graph1->SetColor("#FFFFFF");
$graph2->yscale->ticks->Set(20, 10);
if($maxL < 10) {
$graph2->yscale->ticks->Set(1,1);
} else if(10 < $maxL && $maxL <= 1000) {
$graph2->yscale->ticks->Set(10, 2);
} else if(1000 < $maxL && $maxL <= 10000) {
$graph2->yscale->ticks->Set(10, 5);
} else if(10000 < $maxL && $maxL <= 1000000) {
$graph2->yscale->ticks->Set(20, 10);
}
$graph2->title->Set("Lag time for ".$siteName);
$graph2->subtitle->Set("Dates: ".$dvalueL." to ".$dvalueH." for ".$siteName." AND monflag is ".$monFlag.".");
$graph2->SetMarginColor("#F0F0F0");
$graph2->SetColor("#FFFFFF");
$lineplot=new LinePlot($transferDataCad,$transerDate);
$lineplotT=new LinePlot($transferDataTech,$transferDate);
$lineplotT2=new LinePlot($transferDataLocal,$transferDate);
$lineplot->SetColor('red');
$lineplotT->SetColor('green');
$lineplotT2->SetColor('black');
$lineplot->SetLegend('Volume: CAD');
$lineplotT->SetLegend('Volume: TECH');
$lineplotT2->SetLegend('Volume: LOCAL');
$graph->img->SetImgFormat("jpeg");
$lineplot->SetWeight(2);
$lineplotT->SetWeight(2);
$lineplotT2->SetWeight(2);
$lineplot->mark->SetType(MARK_X);
$lineplotT->mark->SetType(MARK_X);
$lineplotT2->mark->SetType(MARK_X);
$graph->Add($lineplot);
$graph->Add($lineplotT);
$graph->Add($lineplotT2);
$graph->xaxis->SetTitleSide(SIDE_TOP);
$graph->yaxis->SetColor('blue','blue');
$graph->xaxis->SetColor('purple','purple');
$graph->xaxis->title->Set("Date");
$graph->yaxis->SetTitleSide(SIDE_RIGHT);
$graph->yaxis->title->Set($tUnits."/second");
$lineplot1=new LinePlot($compDataCad,$compDate);
$lineplot1C=new LinePlot($compDataTech,$compDate);
$lineplot1C2=new LinePlot($compDataLocal,$compDate);
$lineplot1->SetColor('blue');
$lineplot1C->SetColor('orange');
$lineplot1C2->SetColor('purple');
$lineplot1->SetWeight(2);
$lineplot1C->SetWeight(2);
$lineplot1C2->SetWeight(2);
$lineplot1->mark->SetType(MARK_X);
$lineplot1C->mark->SetType(MARK_X);
$lineplot1C2->mark->SetType(MARK_X);
$lineplot1->SetLegend('Volume: CAD');
$lineplot1C->SetLegend('Volume: TECH');
$lineplot1C2->SetLegend('Volume: LOCAL');
$graph->legend->Pos(0.01,0.1,"right" ,"center");
$graph1->legend->Pos(0.01,0.1,"right" ,"center");
$graph1->img->SetImgFormat("jpeg");
$graph1->Add($lineplot1);
$graph1->Add($lineplot1C);
$graph1->Add($lineplot1C2);
$graph1->xaxis->SetTitleSide(SIDE_TOP);
$graph1->yaxis->SetColor('blue','blue');
$graph1->xaxis->SetColor('red','red');
$graph1->xaxis->title->Set("Date");
$graph1->yaxis->SetTitleSide(SIDE_RIGHT);
$graph1->yaxis->title->Set("Ratio");
$lineplot2=new LinePlot($lagDataCad,$lagDate);
$lineplot2C=new LinePlot($lagDataTech,$lagDate);
$lineplot2C2=new LinePlot($lagDataLocal,$lagDate);
$lineplot2->SetColor('blue');
$lineplot2C->SetColor('orange');
$lineplot2C2->SetColor('purple');
$lineplot2->SetWeight(2);
$lineplot2C->SetWeight(2);
$lineplot2C2->SetWeight(2);
$lineplot2->mark->SetType(MARK_X);
$lineplot2C->mark->SetType(MARK_X);
$lineplot2C2->mark->SetType(MARK_X);
$lineplot2->SetLegend('Volume: CAD');
$lineplot2C->SetLegend('Volume: TECH');
$lineplot2C2->SetLegend('Volume: LOCAL');
$graph2->legend->Pos(0.01,0.1,"right" ,"center");
$graph2->img->SetImgFormat("jpeg");
$graph2->Add($lineplot2);
$graph2->Add($lineplot2C);
$graph2->Add($lineplot2C2);
$graph2->xaxis->SetTitleSide(SIDE_TOP);
$graph2->yaxis->SetColor('blue','blue');
$graph2->xaxis->SetColor('green','green');
$graph2->xaxis->title->Set("Date");
$graph2->yaxis->SetTitleSide(SIDE_RIGHT);
$graph2->yaxis->title->Set("Seconds");
// Display the graphs
if($monFlag == 0){
$graph->Stroke('/var/apps/asc/web/images/'.$siteName.$dTemp1.'tgraph.jpg');
$graph1->Stroke('/var/apps/asc/web/images/'.$siteName.$dTemp1.'cgraph.jpg');
$graph2->Stroke('/var/apps/asc/web/images/'.$siteName.$dTemp1.'lgraph.jpg');
}
if($monFlag == 1){
$graph->Stroke('/var/apps/asc/web/images/'.$siteName.$dTemp1.$dTemp2.'tgraph.jpg');
$graph1->Stroke('/var/apps/asc/web/images'.$siteName.$dTemp1.$dTemp2.'cgraph.jpg');
$graph2->Stroke('/var/apps/asc/web/images'.$siteName.$dTemp1.$dTemp2.'lgraph.jpg');
}