Weiß nicht ob lediglich daran liegt, aber ganz unten in deiner While-Schleife packst du das stroke rein, somit willst du jedes mal ein Diagramm ausgeben.
Bei JPGraph wird erst das gesamte Diagramm mit allen Werten zusammengebaut und dann zum Schluss ausgegeben. versuch das mal.
Sieht mir auch ehrlich gesagt zu wenig Code aus, als ich mit JPGraph gearbeitet hab, hab ich immer deutlich mehr Code gebraucht...
Du kannst dem new Lineplot auch ein ganzes Array übergeben, musst du also nicht in der Schleife machen.
Weiß nicht ob dir das hilft, hier mal ein Script wo ich ein Line-Diagramm erstellt hab, komplett konfigurierbar:
PHP-Code:
<?php
include ("jpgraph.php");
include ("jpgraph_line.php");
include ("jpgraph_canvas.php");
//Zeitstempel
include ("time.php");
//Variablendeklaration_Extern
include ("varLine.php");
// Create the graph. These two calls are always required
$graph = new Graph($GraphHoehe, $GraphBreite, "auto");
$graph->SetScale( "textlin");
$lineplot =new LinePlot($ydata);
//Graph Options
$graph->img-> SetMargin($MarginLeft,$MarginRight ,$MarginTop, $MarginBottom);
$graph->img->SetQuality(100);
$graph->img->SetAntiAliasing();
$graph->SetShadow(false);
$graph->ygrid->Show ($StateYAxis, false);
$graph->xgrid->Show ($StateXAxis, false);
$graph->SetFrame($StateFrame);
$graph->setMarginColor($MarginColor);
//TitleOptions
$graph->title->Set($Title);
$graph->subtitle->Set($SubTitle);
$graph->subsubtitle->Set($SubSubTitle);
$graph->title->setAlign("left");
$graph->subtitle->setAlign("left");
$graph->subsubtitle->setAlign("left");
$graph->title->SetFont(FF_ARIAL ,FS_NORMAL, $TitleSize);
$graph->subtitle->SetFont(FF_ARIAL ,FS_NORMAL, $SubTitleSize);
$graph->subsubtitle->SetFont(FF_ARIAL ,FS_NORMAL, $SubSubTitleSize);
//Axis Options
$graph->xaxis->SetTickLabels($xdata);
$graph->yaxis->scale->SetAutoMin($AutoMin);
$graph->xaxis->SetFont(FF_ARIAL, FS_NORMAL, $XTitleSize);
$graph->yaxis->SetFont(FF_ARIAL, FS_NORMAL, $YTitleSize);
$graph->yaxis->SetLabelFormat($Dezimalstellen);
$graph->xaxis->SetLabelAlign('center');
$graph->yaxis->SetTextLabelInterval($IntervalStep, $IntervalStart);
$graph->yaxis->HideZeroLabel();
$graph->yaxis->HideTicks(true,true);
$graph->xaxis->HideTicks(true,true);
$graph->xaxis->SetLabelMargin(5);
$graph->yaxis->title->SetFont(FF_FONT1 ,FS_BOLD);
$graph->xaxis->title->SetFont(FF_FONT1 ,FS_BOLD);
$graph->xaxis->SetColor($XAxisColor);
$graph->yaxis->SetColor($YAxisColor);
$graph->xaxis->HideFirstTickLabel();
$graph->xaxis-> title->Set("");
$graph->yaxis-> title->Set("");
//Legendoptions
$graph->legend->SetShadow(false);
$graph->legend->SetFrameWeight(0);
$graph->legend->SetFillColor($LegendColor);
$graph->legend->SetFont(FF_ARIAL, FS_NORMAL, $LegendSize);
$graph->legend->SetLineSpacing(0);
$graph->legend->SetHColMargin(20);
$graph->legend->SetLineWeight(2);
$graph->legend->SetAbsPos($LegendX, $LegendY);
$graph->legend->SetLayout(LEGEND_HOR);
//Lineplot1
$lineplot->value-> Show(true);
$lineplot->value->SetMargin(-12.5);
$lineplot->value ->SetColor($ValueColor);
$lineplot ->value->SetFont( FF_ARIAL, FS_BOLD, $ValueSize);
$lineplot ->value->SetFormat($Dezimalstellen);
$lineplot ->SetWeight(2);
$lineplot ->SetColor($LineColor1);
$lineplot->SetLegend ("Stammaktie");
/*
//lineplot2
$lineplot2 = new LinePlot($ydata2);
$lineplot2 ->SetColor("#D4E0F0");
$lineplot2 ->SetWeight(2);
$lineplot2->value-> Show();
$lineplot2->value->SetMargin(10);
$lineplot2->value ->SetColor("#BBD0E7");
$lineplot2 ->value->SetFont( FF_ARIAL, FS_BOLD, 7);
$lineplot2 ->value->SetFormat( "%0.2f");
$lineplot2 ->SetLegend("Vorzugsaktie");
$graph->Add( $lineplot2);
*/
$graph->SetImgFormat($Format);
$graph->Add( $lineplot);
// Save the graph
$graph->Stroke($filename);
echo $filename;
?>
Nur beachten, ich gebe das Diagramm direkt in eine datei aus, du musst dann entsprechend nur Stroke() verwenden.