Моя среда разработки выполняется на apache (php7.0) под windows, я разрабатываю диаграмму с помощью "PCHART (2.1.4)" с помощью скрипта php, она работает хорошо, путь моего php_script => "C:\ wamp64 \ www \ lora_app \ paclido \ pchart \ php_generator \ temp_moy_chart.php "
вот мой код и результат:
<?php
/* CAT:Labels */
/* pChart library inclusions */
include("../class/pData.class.php");
include("../class/pDraw.class.php");
include("../class/pImage.class.php");
try
{
$bdd = new PDO('mysql:host=localhost;dbname=*****;charset=utf8',
'*******', '********$*');
}
catch(Exception $e)
{
die('Erreur : '.$e->getMessage());
}
$Result = $bdd->prepare('
SELECT DAY(time) AS jour,MONTH(time) AS mois,
YEAR(time) AS annee, AVG(data) AS moy
FROM PACLIDO
WHERE YEAR(time) = YEAR(NOW())
AND MONTH(time) = MONTH(NOW())
GROUP BY annee,mois,jour;
');
$Result->execute( ) ;
while ($row = $Result->fetch())
{
$jour[] = $row["jour"];
$mois = $row["mois"];
$annee = $row["annee"];
$temperature[] = number_format($row["moy"], 2, ',', '') ;
}
$Result->closeCursor();
if($mois == 1){$n_mois = "Janvier";}
else if($mois == 2){$n_mois = "Février";}
else if($mois == 3){$n_mois = "Mars";}
else if($mois == 4){$n_mois = "Avril";}
else if($mois == 5){$n_mois = "Mai";}
else if($mois == 6){$n_mois = "Juin";}
else if($mois == 7){$n_mois = "Juillet";}
else if($mois == 8){$n_mois = "Août";}
else if($mois == 9){$n_mois = "Septembre";}
else if($mois == 10){$n_mois = "Octobre";}
else if($mois == 11){$n_mois = "Novembre";}
else if($mois == 12){$n_mois = "Décembre";}
else{}
$size_tab = sizeof($temperature);
$max_temp = array_keys($temperature, max($temperature));
$min_temp = array_keys($temperature, min($temperature));
/* Create and populate the pData object */
$MyData = new pData();
$MyData->addPoints($temperature,"Probe 1");
$MyData->setAxisName(0,"Temperatures");
$MyData->setAxisUnit(0,"°C");
$MyData->addPoints($jour,"Labels");
$MyData->setSerieDescription("Labels","Months");
$MyData->setAbscissa("Labels",2);
$serieSettings = array("R"=>229,"G"=>0,"B"=>0); /* COULEUR COURBE */
$MyData->setPalette("Probe 1",$serieSettings);
$MyData->setPalette("Labels",$serieSettings);
$MyData->setSerieWeight("Probe 1",2);
/* Associate a color to each axis */
$MyData->setAxisColor(0,array("R"=>255,"G"=>255,"B"=>255));
/* Create the pChart object */
$myPicture = new pImage(770,400,$MyData,TRUE);
/* Draw the background */
$Settings = array("R"=>0, "G"=>0, "B"=>0, "Dash"=>1,"Alpha"=>10);
$myPicture->drawFilledRectangle(0,0,700,230,$Settings);
/* Overlay with a gradient */
/* Add a border to the picture bordur*/
$myPicture->drawRectangle(0,0,705,280,array("R"=>0,"G"=>0,"B"=>0));
/* Write the picture title
$myPicture>setFontProperties(array("FontName"=>"../fonts/Silkscreen.ttf",
"FontSize"=>6));
$myPicture->drawText(10,13,"drawLabel() - Write labels over your
charts",array("R"=>255,"G"=>255,"B"=>255)); /* COULEUR FONT TEXT TOUT EN
HAUT */
/* Write the chart title */
$myPicture>setFontProperties(array("FontName"=>"../fonts/Forgotte.ttf",
"FontSize"=>11,"R"=>255,"G"=>255,"B"=>255));
$myPicture->drawText(380,30,"Temperature moyenne en
".$n_mois,array("FontSize"=>20,"Align"=>TEXT_ALIGN_BOTTOMMIDDLE));
/* Draw the scale and the 1st chart */
$myPicture->setGraphArea(75,35,700,250);/* ettendre les axe */
$myPicture>drawFilledRectangle(75,35,700,250,
array("R"=>255,"G"=>255,"B"=>255,"Surrounding"=>-200,"Alpha"=>10));/*
ettendre le font derriere les axe */
$myPicture>setFontProperties(array("FontName"=>"../fonts/pf_arma_five.ttf"
,"FontSize"=>11,"R"=>255,"G"=>255,"B"=>255));
$Settings = array("AxisR"=>255,"AxisG"=>255,"AxisB"=>255,
"DrawYLines"=>array(0),"Pos"=>SCALE_POS_LEFTRIGHT);
$myPicture->drawScale($Settings);
$myPicture->setShadow(TRUE,array("X"=>1,"Y"=>1,"R"=>0,"G"=>0,"B"=>0,
"Alpha"=>10));
$myPicture->drawSplineChart();
$myPicture->setShadow(FALSE);
/* Write the chart legend
$myPicture->drawLegend(600,20,array("Style"=>LEGEND_NOBORDER,
"Mode"=>LEGEND_HORIZONTAL)); /* LEGENDE */
$myPicture->setShadow(TRUE,array("X"=>1,"Y"=>1,"R"=>0,
"G"=>0,"B"=>0,"Alpha"=>10));
$myPicture->setFontProperties(array("FontName"=>"../fonts/Forgotte.ttf",
"FontSize"=>11));
/* FENETRE POP PU */
$myPicture->setFontProperties(array("FontName"=>"../fonts/pf_arma_five.ttf",
"FontSize"=>11,"R"=>0,"G"=>0,"B"=>0));
$LabelSettings = array("OverrideTitle"=>"Max
Temp","DrawVerticalLine"=>TRUE,"TitleMode"=>
LABEL_TITLE_BACKGROUND,"TitleR"=>255,"TitleG"=>255,"TitleB"=>255);
$myPicture->writeLabel(array("Probe 1"),$max_temp,$LabelSettings);
/* Write a label over the chart */
$LabelSettings = array("OverrideTitle"=>"Min Temp","DrawVerticalLine"=>TRUE,"TitleMode"=>LABEL_TITLE_BACKGROUND,"TitleR"=>255,"TitleG"=>255,"TitleB"=>255);
$myPicture->writeLabel(array("Probe 1"),$min_temp,$LabelSettings);
/* Render the picture (choose the best way) */
/* $myPicture->autoOutput("pictures/example.drawLabel.png");*/
$myPicture->render("pictures/temp_moy.png");
?>
изображение папки:
Проблема в том, что когда я использую тот же скрипт на моем сервере UBUNTU (с apach), скрипт не генерирует картинку в моемПапка «картинки», я попробовал функцию «autoOutput», чтобы проверить результат, и она работает хорошо, но функция «рендеринга» не сохраняет изображение, тогда как я ничего не изменил, путь моего php_script => "/html / paclido / pchart / php_generator / temp_moy_chart.php "
может быть, это связано с некоторым расширением?моя работа над расширением gd2, потому что я могу запустить скрипт и увидеть результат с помощью "autoOutput".