ciao a tutti,
sto cercando di ottimizzare l'uso jpgraph usando delle funzioni
il codice da cui parto è tipo questo:
per creare le colonne del grafico eCodice PHP:$graph->xaxis->SetTickLabels($datax);
// Create the bar plots
$bplot1 = new BarPlot($data1y);
$bplot1->SetFillColor("$color[1]");
$bplot2= new BarPlot($data2y);
$bplot2->SetFillColor("$color[2]");
per impilarlo.Codice PHP:$gbplot = new AccBarPlot(array($bplot1,$bplot2,$bplot3,$bplot4));
non sapendo quanti possono essere i grafici da impilare ho strasformato il codice così
e poiCodice PHP:foreach ($datay as $k => $value) {
$bplot[$k] = new BarPlot($value);
$bplot[$k]->SetFillColor($color[$k]);
if (isset($grafico_tot)) {$grafico_tot.=",".$bplot[$k];}
else {$grafico_tot.=$bplot[$k];}
}
ma non vaCodice PHP:$gbplot = new AccBarPlot(array($grafico_tot));
mentre funge se scrivo
è ok.Codice PHP:$gbplot = new AccBarPlot(array($bplot[1],$bplot[2],$bplot[3],$bplot[4]));
sapete dirmi come posso fare per rendere la generazione dell'ulltima riga dipendente dal array $datay?
in breve, come faccio a fare in modo che inpili gli n. oggetti creati?
eraclito

Rispondi quotando