tra le mani ho un file che mi permette la visualizzazione di alcuni parametri , rappresentandoli con più serie sullo stesso grafico.
L'unica pecca è che vorrei creare più Assi ordinarie X con ognuna la sua serie, leggendo in internet ho visto che mi può aiutare la funzione setSerieOnAxis($Series,$AxisID);
codice:
<?php /* pChart library inclusions */ include("../pChart210/class/pData.class.php"); include("../pChart210/class/pDraw.class.php"); include("../pChart210/class/pImage.class.php"); /* Create and populate the pData object */ $MyData = new pData(); $MyData->setAxisName(0,"VARIABILE"); //$MyData->setAxisUnit(0,"%"); $db = mysql_connect("localhost", "root", "GotO1964"); mysql_select_db("eliosenergheia_13i1s",$db); $Requeste = 'SELECT id,namestrum FROM tbl_strum WHERE namestrum LIKE "%Inverter%"'; $Result = mysql_query($Requeste,$db); $IDInv=""; $NomeInv=""; while($row = mysql_fetch_array($Result)) { $IDInv[] = $row["id"]; $NomeInv[] = $row["namestrum"]; } $NumeroInv=count($IDInv); $Requeste = 'SELECT id,ora FROM tbl_96val WHERE id>20 AND id<89'; $Result = mysql_query($Requeste,$db); $ora=""; $valore=""; while($row = mysql_fetch_array($Result)) { $ora[] = substr($row["ora"],0,5); $valore[] = 0; } $Requeste = 'SELECT id,namestrum FROM tbl_strum WHERE namestrum LIKE "%Solarimetro%"'; $Result = mysql_query($Requeste,$db); $IDSolar=""; $NomeSolar=""; $row = mysql_fetch_array($Result); $IDSolar = $row["id"]; $NomeSolar = $row["namestrum"]; if(isset($_POST['Day_1'])) { $Fatto=false; $NumPenne=0; $DatoAttuale=array(); $ParInput=array(array(1,2,3,4,5,6), array()); // Salvataggio parametri per query $ParOrario=$_POST["Orario"]; for ($i=1; $i<7;$i++) { $QueryPreamb=""; $QueryText=""; $QueryPost=""; $Canale="Pac"; $ParInput[$i][1]=$_POST["Day_".$i]; $ParInput[$i][2]=$_POST["Month_".$i]; $ParInput[$i][3]=$_POST["Year_".$i]; $ParInput[$i][4]=$_POST["Strumento_".$i]; $ParInput[$i][5]=$_POST["Parametro_".$i]; $Cambiacanale=false; if ($ParInput[$i][1]!="0" && $ParInput[$i][2]!="0" && $ParInput[$i][3]!="0") { $NumPenne++; $Canale=$ParInput[$i][5]; $Strum=$ParInput[$i][4]; $PotenzaT=false; if ($Canale=="Potenza Totale") { $QueryRow="totalPow"; $QueryPreamb="SELECT tbl_96val.ora, SUM(tbl_misure.valore) AS totalPow FROM "; $QueryText=""; $QueryPost=" GROUP BY tbl_96val.ora"; $Canale="Pac"; $PotenzaT=true; } else { if ($Canale=="Rendimento") { $QueryRow="Rendiment"; $QueryPreamb=" SELECT ora,TRUNCATE((SUM(TotalPow)/(SUM(RadSol)*metriquadri))*100,2) as Rendiment FROM ( SELECT tbl_96val.ora ,tbl_impianto.mqPannelli AS metriquadri, SUM(tbl_misure.valore) AS TotalPow, 0 as RadSol FROM tbl_impianto, "; $QueryText=""; $QueryPost=" GROUP BY tbl_96val.ora UNION ALL SELECT tbl_96val.ora , 0 AS metriquadri, 0 as TotalPow,SUM(tbl_misure.valore) AS RadSol FROM tbl_misure INNER JOIN tbl_archivio ON (tbl_misure.id_archivio=tbl_archivio.id) INNER JOIN tbl_storicogiorno ON (tbl_archivio.id_giorno=tbl_storicogiorno.id) INNER JOIN tbl_96val ON (tbl_archivio.id_ora=tbl_96val.id) INNER JOIN tbl_canale ON (tbl_misure.id_canale=tbl_canale.id) INNER JOIN tbl_strum ON (tbl_canale.id_strum=tbl_strum.id) WHERE year(giorno)=" . $ParInput[$i][3] . " AND month(giorno)=" . $ParInput[$i][2] . " AND day(giorno)=" . $ParInput[$i][1] . " AND tbl_canale.canale='IntSolIrr' AND tbl_archivio.id_ora > 20 AND tbl_archivio.id_ora < 89 GROUP BY tbl_96val.ora ) TMP GROUP BY TMP.ora"; $Canale="Pac"; $Cambiacanale=true; } else { $QueryRow="valore"; $QueryPreamb="SELECT tbl_96val.ora, tbl_misure.valore FROM "; if ($ParInput[$i][5]=="IntSolIrr" || $ParInput[$i][5]=="TmpMdul C") $Strum=$IDSolar; else $QueryText="AND tbl_strum.id='" . $Strum . "' "; $QueryPost=""; }} /* Build the query that will returns the data to graph */ $Requeste = $QueryPreamb . "tbl_misure INNER JOIN tbl_archivio ON (tbl_misure.id_archivio=tbl_archivio.id) INNER JOIN tbl_storicogiorno ON (tbl_archivio.id_giorno=tbl_storicogiorno.id) INNER JOIN tbl_96val ON (tbl_archivio.id_ora=tbl_96val.id) INNER JOIN tbl_canale ON (tbl_misure.id_canale=tbl_canale.id) INNER JOIN tbl_strum ON (tbl_canale.id_strum=tbl_strum.id) WHERE year(giorno)=" . $ParInput[$i][3] . " AND month(giorno)=" . $ParInput[$i][2] . " AND day(giorno)=" . $ParInput[$i][1] . " AND tbl_canale.canale='" . $Canale . "' " . $QueryText . "AND tbl_archivio.id_ora > 20 AND tbl_archivio.id_ora < 89" . $QueryPost; $Result = mysql_query($Requeste,$db); $valore=""; //$ora=""; if ($Cambiacanale) $Canale="Rendimento"; $CalPercento=1; switch ($Canale) { case "IntSolIrr": $UnitaMis="W/m²"; $CalPercento=1; //0-1100 break; case "TmpMdul C": $UnitaMis="°C"; //0-100 break; case "Upv-Ist": $UnitaMis="V"; $CalPercento=1; //0-500 break; case "Ipv": $UnitaMis="A"; //0-100 break; case "Iac-Ist": $UnitaMis="A"; //0-100 break; case "Uac": $UnitaMis="V"; $CalPercento=1; //0-500 break; case "Pac": $UnitaMis="W"; $CalPercento=1; //0-10000 break; case "Rendimento": $UnitaMis="%"; //0-100 break; } //$x=0; if ((!$Result || mysql_num_rows($Result)==0)) { } else { for ($j=1;$j<69;$j++) $valore[] = 0; while($row = mysql_fetch_array($Result)) { //$x++; /* Push the results of the query in an array */ //if ($ParOrario==($x+20)) $DatoAttuale[$i]=$row[$QueryRow]." ".$UnitaMis; $calOra=substr($row["ora"],0,2); $calMinuti=substr($row["ora"],3,2); $Indice=$calOra*4+$calMinuti/15-20; //echo $Indice; //$valore[] = round($row[$QueryRow],2); //$ora[] = substr($row["ora"],0,5); $valore[$Indice] = round(($row[$QueryRow]/$CalPercento),2); //$valore[$Indice] = round(($row[$QueryRow]),2); $ora[$Indice] = substr($row["ora"],0,5); $calOra=intval((15*($ParOrario-1))/60); $calMinuti=((15*($ParOrario-1))-(60*$calOra)); $calTempo=sprintf("%02s",$calOra).":".sprintf("%02s",$calMinuti); if ($ora[$Indice]==$calTempo) $DatoAttuale[$i]=round(($row[$QueryRow]),2)." ".$UnitaMis; } } $tacche=intval(count($ora)/18); $Penna="Penna" . $i; /* Save the data in the pData array */ $MyData->addPoints($valore,$Penna); if ($Fatto==false) {$MyData->addPoints($ora,"ora"); $Fatto=true;} //$MyData->addPoints($prova2,"ora"); switch ($Penna) { case "Penna1": $MyData->setPalette($Penna,array("R"=>255,"G"=>0,"B"=>0)); break; case "Penna2": $MyData->setPalette($Penna,array("R"=>0,"G"=>255,"B"=>0)); break; case "Penna3": $MyData->setPalette($Penna,array("R"=>0,"G"=>0,"B"=>255)); break; case "Penna4": $MyData->setPalette($Penna,array("R"=>255,"G"=>255,"B"=>0)); break; case "Penna5": $MyData->setPalette($Penna,array("R"=>0,"G"=>255,"B"=>255)); break; case "Penna6": $MyData->setPalette($Penna,array("R"=>255,"G"=>0,"B"=>255)); break; } } /* Render the picture (choose the best way) */ //$myPicture->autoOutput("pictures/example.drawFilledSplineChart.png"); if (($NumPenne>0) && ($i==6)) { /* Put the timestamp column on the abscissa axis */ $MyData->setAbscissa("ora"); //$MyData->setAxisDisplay(1,AXIS_FORMAT_TIME,"H"); /* Create the pChart object */ $myPicture = new pImage(900,351,$MyData); $myPicture->drawGradientArea(0,0,773,350,DIRECTION_VERTICAL,array("StartR"=>47,"StartG"=>47,"StartB"=>47,"EndR"=>17,"EndG"=>17,"EndB"=>17,"Alpha"=>0)); /*$myPicture->drawGradientArea(0,250,773,400,DIRECTION_VERTICAL,array("StartR"=>47,"StartG"=>47,"StartB"=>47,"EndR"=>27,"EndG"=>27,"EndB"=>27,"Alpha"=>100));*/ //$myPicture->drawLine(0,249,773,349,array("R"=>0,"G"=>0,"B"=>0)); //$myPicture->drawLine(0,250,773,350,array("R"=>70,"G"=>70,"B"=>70)); /* Add a border to the picture */ //$myPicture->drawRectangle(0,0,772,349,array("R"=>204,"G"=>204,"B"=>204)); /* Write the picture title */ $myPicture->setFontProperties(array("FontName"=>"../pChart210/fonts/pf_arma_five.ttf","FontSize"=>7)); $myPicture->drawText(387,14,"STORICO",array("R"=>0,"G"=>0,"B"=>0,"Align"=>TEXT_ALIGN_MIDDLEMIDDLE)); /* Define the chart area */ $myPicture->setGraphArea(140,27,880,328); /* Draw a rectangle */ $myPicture->drawFilledRectangle(140,27,880,328,array("R"=>255,"G"=>255,"B"=>255,"Dash"=>TRUE,"DashR"=>255, "DashG"=>255,"DashB"=>255,"BorderR"=>0,"BorderG"=>0,"BorderB"=>0)); /* Turn on shadow computing */ //$myPicture->setShadow(TRUE,array("X"=>1,"Y"=>1,"R"=>0,"G"=>0,"B"=>0,"Alpha"=>20)); $myPicture->setShadow(FALSE); /* Draw the scale */ $myPicture->setFontProperties(array("R"=>0,"G"=>0,"B"=>0)); $ScaleSettings = array("XMargin"=>4,"DrawSubTicks"=>TRUE,"GridR"=>0, "GridG"=>0,"GridB"=>0,"AxisR"=>0,"AxisG"=>0,"AxisB"=>0,"GridAlpha"=>30,"CycleBackground"=>TRUE,"LabelSkip"=>$tacche,"SkippedAxisR"=>0,"SkippedAxisG"=>0,"SkippedAxisB"=>0,"SkippedAxisAlpha"=>10,"Mode"=>SCALE_MODE_START0); $myPicture->drawScale($ScaleSettings); /* Draw the spline chart */ //$myPicture->drawFilledSplineChart(); $myPicture->drawSplineChart(); /* Write the chart boundaries */ $BoundsSettings = array("MaxDisplayR"=>237,"MaxDisplayG"=>23,"MaxDisplayB"=>48, "MinDisplayR"=>23,"MinDisplayG"=>144,"MinDisplayB"=>237); $myPicture->writeBounds(BOUND_BOTH,$BoundsSettings); /* Write the 0 line */ $myPicture->drawThreshold(0,array("WriteCaption"=>TRUE)); /* Write the chart legend $myPicture->setFontProperties(array("R"=>255,"G"=>255,"B"=>255)); $myPicture->drawLegend(360,265,array("Style"=>LEGEND_NOBORDER)); */ /* Write the 1st data series statistics $Settings = array("R"=>188,"G"=>224,"B"=>46,"Align"=>TEXT_ALIGN_BOTTOMLEFT); $myPicture->drawText(420,270,"Max : ".ceil($MyData->getMax("Penna1")),$Settings); $myPicture->drawText(490,270,"Min : ".ceil($MyData->getMin("Penna1")),$Settings); $myPicture->drawText(560,270,"Avg : ".ceil($MyData->getSerieAverage("Penna1")),$Settings); */ $myPicture->render("MyPicChart.png"); $StringaGrap=' <p align="center">[img]MyPicChart.png?V='.(rand()%1000).'[/img]</p>'; } else { $StringaGrap='
<font color="black">Selezione non valida!</font></p>'; } } $Colore=array("F00","0F0","00F","FF0","0FF","F0F");