Files
kopalnia_2014/polynomial/etaCharts.php
T
2026-09-03 11:24:19 +02:00

624 lines
27 KiB
PHP

<?php
if (file_exists('./polynomial/math.php'))
require_once('./polynomial/math.php');
else
require_once('../polynomial/math.php');
// Eta
// ========================================================== //// ========================================================== //
function createEtaChart($pupData, $tstData, $qVal, $imgFileName, $imgWidth=420, $imgHeight=330, $xDiv=10, $yDiv=10, $m3min=0)
{
$max_XVal=0;
$max_YVal=0;
$polynomial = new zc_math_polynomial($tstData);
$polynomial->calculate_coefficients();
// ustanawia najwy�sza� warto�� dla X i Y
for($i=0; $i<count($tstData); $i++)
{
if ($tstData[$i][0]>$max_XVal) $max_XVal=$tstData[$i][0];
if ($tstData[$i][1]>$max_YVal) $max_YVal=$tstData[$i][1];
}
$max_XVal = $max_XVal;
$max_YVal = 1;
//sprawdza, czy m3/min, czy m3/h
if ($m3min==1)
{
$m3h = 1/60;
$ilosc_po_przecinku = 3;
$m3Desc = 'Q[m3/min]';
}
else
{
$m3h = 1;
$ilosc_po_przecinku = 2;
$m3Desc = 'Q[m3/h]';
}
if (file_exists('./fonts/calibri.ttf')) { $font = './fonts/calibri.ttf'; $fontBold = './fonts/Calibri_b.ttf'; }
else { $font = '../fonts/calibri.ttf'; $fontBold = '../fonts/Calibri_b.ttf'; }
$im = imagecreate($imgWidth, $imgHeight) or die("Cannot Initialize new GD image stream");
$background_color = imagecolorallocate($im, 255, 255, 255);
$black = imagecolorallocate($im, 0, 0, 0);
$gray = imagecolorallocate($im, 200, 200, 200);
$dark_gray = imagecolorallocate($im, 180, 180, 180);
$red = imagecolorallocate($im, 235, 0, 0);
$yellow = imagecolorallocate($im, 240, 240, 0);
$green = imagecolorallocate($im, 34, 177, 76);
$blue = imagecolorallocate($im, 0, 0, 200);
$wspX = ($imgWidth-70)/$max_XVal;
$wspY = ($imgHeight-60)/$max_YVal;
imagerectangle ($im , 40, 30, $imgWidth-30, $imgHeight-30, $gray);
// pionowa skala [X]
imagettftext($im, 10, 0, $imgWidth-61, $imgHeight-2,$black, $fontBold, $m3Desc);
// ========================================================================================================================
// ========================================================================================================================
for ($i=1; $i<$xDiv; $i++)
{
$szer=(($imgWidth-70)/$xDiv)*$i;
imageline($im, 40+$szer, 30, 40+$szer,$imgHeight-29, $gray);
list($left,,$right) = imageftbbox( 8, 0, $font, number_format((($max_XVal/$xDiv)*$i)*$m3h, $ilosc_po_przecinku, ',', ''));
$xMove = 15 + ($right - $left)/2;
imagettftext($im, 8, 0, $xMove+$szer, $imgHeight-15,$black, $font, number_format((($max_XVal/$xDiv)*$i)*$m3h, $ilosc_po_przecinku, ',', ''));
}
// ========================================================================================================================
// pozioma skala [Y]
imagettftext($im, 10, 0, 2, 12,$black, $fontBold, 'ETA');
// ========================================================================================================================
for ($i=0; $i<=$yDiv; $i++)
{
$wys=($imgHeight-60)-(($imgHeight-60)/$yDiv)*$i;
list($left,,$right) = imageftbbox( 8, 0, $font, number_format(($max_YVal/$yDiv)*$i, 2, ',', ''));
$xPos = 36 - ($right - $left);
imageline($im, 39, 30+$wys, $imgWidth-31, 30+$wys, $gray);
imagettftext($im, 8, 0, $xPos, 34+$wys,$black, $font, number_format(($max_YVal/$yDiv)*$i, 2, ',', ''));
}
// ========================================================================================================================
// rysuje punkty
// ========================================================================================================================
for ($i=0; $i<count($tstData); $i++)
imagefilledellipse ($im, 40+$wspX*$tstData[$i][0],($imgHeight-30)-$wspY*$tstData[$i][1], 5, 5, $blue);
// ========================================================================================================================
// rysuje linie
// ========================================================================================================================
$step = round(1/$wspX,2);
for ($i=0; $i<$max_XVal; $i+=$step)
{
if ($i<=$pupData[2]) $color = $red;
else if ($i>$pupData[2] && $i<=$pupData[3]) $color = $yellow;
else if ($i>$pupData[3] && $i<=$pupData[5]) $color = $green;
else if ($i>$pupData[5] && $i<=$pupData[6]) $color = $yellow;
else $color = $red;
$yLineTo = $polynomial->get_y($i+$step);
if ($yLineTo>0 && (40+$wspX*($i+$step))<($imgWidth-32))
imageline($im, 40+$wspX*$i, ($imgHeight-30)-$wspY*$polynomial->get_y($i), 40+$wspX*($i+$step), ($imgHeight-30)-$wspY*$yLineTo, $color);
}
// ========================================================================================================================
return imagepng($im,$imgFileName);
}
// ========================================================== //// ========================================================== //
// Eta
// site 401
// ========================================================== //// ========================================================== //
function createEtaAssesChart($pupData, $tstData, $qVal, $imgFileName, $imgWidth=420, $imgHeight=330, $xDiv=10, $yDiv=10, $m3min=0)
{
$max_XVal=0;
$max_YVal=0;
$polynomial = new zc_math_polynomial($tstData);
$polynomial->calculate_coefficients();
// ustanawia najwy�sza� warto�� dla X i Y
for($i=0; $i<count($tstData); $i++)
{
if ($tstData[$i][0]>$max_XVal) $max_XVal=$tstData[$i][0];
if ($tstData[$i][1]>$max_YVal) $max_YVal=$tstData[$i][1];
}
$max_XVal = $max_XVal;
$max_YVal = ceil(($max_YVal+($max_YVal*0.1))*10)/10;
//sprawdza, czy m3/min, czy m3/h
if ($m3min==1)
{
$m3h = 1/60;
$ilosc_po_przecinku = 3;
$m3Desc = 'Q[m3/min]';
}
else
{
$m3h = 1;
$ilosc_po_przecinku = 2;
$m3Desc = 'Q[m3/h]';
}
if (file_exists('./fonts/calibri.ttf')) { $font = './fonts/calibri.ttf'; $fontBold = './fonts/Calibri_b.ttf'; }
else { $font = '../fonts/calibri.ttf'; $fontBold = '../fonts/Calibri_b.ttf'; }
$im = imagecreate($imgWidth, $imgHeight) or die("Cannot Initialize new GD image stream");
$background_color = imagecolorallocate($im, 255, 255, 255);
$black = imagecolorallocate($im, 0, 0, 0);
$gray = imagecolorallocate($im, 200, 200, 200);
$dark_gray = imagecolorallocate($im, 180, 180, 180);
$red = imagecolorallocate($im, 235, 0, 0);
$yellow = imagecolorallocate($im, 240, 240, 0);
$green = imagecolorallocate($im, 34, 177, 76);
$blue = imagecolorallocate($im, 0, 0, 200);
$wspX = ($imgWidth-70)/$max_XVal;
$wspY = ($imgHeight-60)/$max_YVal;
if ($qVal<=$pupData[2]) imagefilledrectangle($im, 40, 30, 40+$wspX*$pupData[2], $imgHeight-30, imagecolorallocatealpha($im, 255, 0, 0, 240));
elseif ($qVal>$pupData[2] && $qVal<=$pupData[3]) imagefilledrectangle($im, 40+$wspX*$pupData[2], 30, 40+$wspX*$pupData[3], $imgHeight-30, imagecolorallocatealpha($im, 255, 255, 0, 240));
elseif ($qVal>$pupData[3] && $qVal<=$pupData[5]) imagefilledrectangle($im, 40+$wspX*$pupData[3], 30, 40+$wspX*$pupData[5], $imgHeight-30, imagecolorallocatealpha($im, 0, 255, 0, 240));
elseif ($qVal>$pupData[5] && $qVal<=$pupData[6]) imagefilledrectangle($im, 40+$wspX*$pupData[5], 30, 40+$wspX*$pupData[6], $imgHeight-30, imagecolorallocatealpha($im, 255, 255, 0, 240));
else $color = imagefilledrectangle($im, 40+$wspX*$pupData[6], 30, $imgWidth-30, $imgHeight-30, imagecolorallocatealpha($im, 255, 0, 0, 240));
imagerectangle ($im , 40, 30, $imgWidth-30, $imgHeight-30, $gray);
// pionowa skala [X]
imagettftext($im, 10, 0, $imgWidth-61, $imgHeight-2,$black, $fontBold, $m3Desc);
// ========================================================================================================================
// ========================================================================================================================
for ($i=1; $i<$xDiv; $i++)
{
$szer=(($imgWidth-70)/$xDiv)*$i;
imageline($im, 40+$szer, 30, 40+$szer,$imgHeight-29, $gray);
list($left,,$right) = imageftbbox( 8, 0, $font, number_format((($max_XVal/$xDiv)*$i)*$m3h, $ilosc_po_przecinku, ',', ''));
$xMove = 15 + ($right - $left)/2;
imagettftext($im, 8, 0, $xMove+$szer, $imgHeight-15,$black, $font, number_format((($max_XVal/$xDiv)*$i)*$m3h, $ilosc_po_przecinku, ',', ''));
}
// ========================================================================================================================
// pozioma skala [Y]
imagettftext($im, 10, 0, 2, 12,$black, $fontBold, 'ETA');
// ========================================================================================================================
for ($i=0; $i<=$yDiv; $i++)
{
$wys=($imgHeight-60)-(($imgHeight-60)/$yDiv)*$i;
list($left,,$right) = imageftbbox( 8, 0, $font, number_format(($max_YVal/$yDiv)*$i, 2, ',', ''));
$xPos = 36 - ($right - $left);
imageline($im, 39, 30+$wys, $imgWidth-31, 30+$wys, $gray);
imagettftext($im, 8, 0, $xPos, 34+$wys,$black, $font, number_format(($max_YVal/$yDiv)*$i, 2, ',', ''));
}
// ========================================================================================================================
// rysuje pionową kreskę dla Q
// ========================================================================================================================
//imageline($im, 40+$wspX*$qVal, ($imgHeight-30), 40+$wspX*$qVal, 30, $blue);
// ========================================================================================================================
// rysuje punkty
// ========================================================================================================================
for ($i=0; $i<count($tstData); $i++)
imagefilledellipse ($im, 40+$wspX*$tstData[$i][0],($imgHeight-30)-$wspY*$tstData[$i][1], 5, 5, $blue);
// ========================================================================================================================
// rysuje linie
// ========================================================================================================================
//$step = round(1/$wspX,2);
$step = (1/$wspX);
for ($i=0; $i<$max_XVal; $i+=$step)
{
if ($i<=$pupData[2]) $color = $red;
else if ($i>$pupData[2] && $i<=$pupData[3]) $color = $yellow;
else if ($i>$pupData[3] && $i<=$pupData[5]) $color = $green;
else if ($i>$pupData[5] && $i<=$pupData[6]) $color = $yellow;
else $color = $red;
$yLineTo = $polynomial->get_y($i+$step);
if ($yLineTo>0 && (40+$wspX*($i+$step))<($imgWidth-32))
imageline($im, 40+$wspX*$i, ($imgHeight-30)-$wspY*$polynomial->get_y($i), 40+$wspX*($i+$step), ($imgHeight-30)-$wspY*$yLineTo, $color);
}
// ========================================================================================================================
// rysuje kropk�
// ========================================================================================================================
imagefilledellipse ($im, 40+$wspX*$qVal,($imgHeight-30)-$wspY*$polynomial->get_y($qVal), 10, 10, $gray);
// ========================================================================================================================
imagettftext($im, 10, 0, $imgWidth-60, 12,$blue, $font, 'Q='.round($qVal/60,3));
return imagepng($im,$imgFileName);
}
// ========================================================== //// ========================================================== //
// Eta - stacja pr�b
// ========================================================== //// ========================================================== //
function createEtaTestChart($pupData, $tstData, $qVal, $imgFileName, $imgWidth=420, $imgHeight=330, $xDiv=10, $yDiv=10, $m3min=0)
{
$max_XVal=0;
$max_YVal=0;
$polynomial = new zc_math_polynomial($tstData);
$polynomial->calculate_coefficients();
// ustanawia najwy�sza� warto�� dla X i Y
for($i=0; $i<count($tstData); $i++)
{
if ($tstData[$i][0]>$max_XVal) $max_XVal=$tstData[$i][0];
if ($tstData[$i][1]>$max_YVal) $max_YVal=$tstData[$i][1];
}
$max_XVal = ceil($max_XVal+($max_XVal*0.1));
$max_YVal = ceil(($max_YVal+($max_YVal*0.1))*10)/10;
//sprawdza, czy m3/min, czy m3/h
if ($m3min==1)
{
$m3h = 1/60;
$ilosc_po_przecinku = 3;
$m3Desc = 'Q[m3/min]';
}
else
{
$m3h = 1;
$ilosc_po_przecinku = 2;
$m3Desc = 'Q[m3/h]';
}
if (file_exists('./fonts/calibri.ttf')) { $font = './fonts/calibri.ttf'; $fontBold = './fonts/Calibri_b.ttf'; }
else { $font = '../fonts/calibri.ttf'; $fontBold = '../fonts/Calibri_b.ttf'; }
$im = imagecreate($imgWidth, $imgHeight) or die("Cannot Initialize new GD image stream");
$background_color = imagecolorallocate($im, 255, 255, 255);
$black = imagecolorallocate($im, 0, 0, 0);
$gray = imagecolorallocate($im, 200, 200, 200);
$dark_gray = imagecolorallocate($im, 180, 180, 180);
$red = imagecolorallocate($im, 235, 0, 0);
$yellow = imagecolorallocate($im, 240, 240, 0);
$green = imagecolorallocate($im, 34, 177, 76);
$blue = imagecolorallocate($im, 0, 0, 200);
$wspX = ($imgWidth-70)/$max_XVal;
$wspY = ($imgHeight-60)/$max_YVal;
imagefilledrectangle($im, 40, 30, 40+$wspX*$pupData[2], $imgHeight-30, imagecolorallocatealpha($im, 255, 0, 0, 245));
imagefilledrectangle($im, 40+$wspX*$pupData[2], 30, 40+$wspX*$pupData[3], $imgHeight-30, imagecolorallocatealpha($im, 255, 255, 0, 245));
imagefilledrectangle($im, 40+$wspX*$pupData[3], 30, 40+$wspX*$pupData[5], $imgHeight-30, imagecolorallocatealpha($im, 0, 255, 0, 245));
imagefilledrectangle($im, 40+$wspX*$pupData[5], 30, 40+$wspX*$pupData[6], $imgHeight-30, imagecolorallocatealpha($im, 255, 255, 0, 245));
imagefilledrectangle($im, 40+$wspX*$pupData[6], 30, $imgWidth-30, $imgHeight-30, imagecolorallocatealpha($im, 255, 0, 0, 245));
imagerectangle ($im , 40, 30, $imgWidth-30, $imgHeight-30, $gray);
// pionowa skala [X]
imagettftext($im, 10, 0, $imgWidth-61, $imgHeight-2,$black, $fontBold, $m3Desc);
// ========================================================================================================================
// ========================================================================================================================
for ($i=1; $i<$xDiv; $i++)
{
$szer=(($imgWidth-70)/$xDiv)*$i;
imageline($im, 40+$szer, 30, 40+$szer,$imgHeight-29, $gray);
list($left,,$right) = imageftbbox( 8, 0, $font, number_format((($max_XVal/$xDiv)*$i)*$m3h, $ilosc_po_przecinku, ',', ''));
$xMove = 15 + ($right - $left)/2;
imagettftext($im, 8, 0, $xMove+$szer, $imgHeight-15,$black, $font, number_format((($max_XVal/$xDiv)*$i)*$m3h, $ilosc_po_przecinku, ',', ''));
}
// ========================================================================================================================
// pozioma skala [Y]
imagettftext($im, 10, 0, 2, 12,$black, $fontBold, 'ETA');
// ========================================================================================================================
for ($i=0; $i<=$yDiv; $i++)
{
$wys=($imgHeight-60)-(($imgHeight-60)/$yDiv)*$i;
list($left,,$right) = imageftbbox( 8, 0, $font, number_format(($max_YVal/$yDiv)*$i, 2, ',', ''));
$xPos = 36 - ($right - $left);
imageline($im, 39, 30+$wys, $imgWidth-31, 30+$wys, $gray);
imagettftext($im, 8, 0, $xPos, 34+$wys,$black, $font, number_format(($max_YVal/$yDiv)*$i, 2, ',', ''));
}
// ========================================================================================================================
// rysuje linie
// ========================================================================================================================
$step = round(1/$wspX,2);
for ($i=0; $i<$max_XVal; $i+=$step)
{
$yLineTo = $polynomial->get_y($i+$step);
if ($yLineTo>0 && (40+$wspX*($i+$step))<=($imgWidth-32))
imageline($im, 40+$wspX*$i, ($imgHeight-30)-$wspY*$polynomial->get_y($i), 40+$wspX*($i+$step), ($imgHeight-30)-$wspY*$yLineTo, $black);
}
// ========================================================================================================================
// rysuje punkty
// ========================================================================================================================
for ($i=0; $i<count($tstData); $i++)
imagefilledellipse ($im, 40+$wspX*$tstData[$i][0],($imgHeight-30)-$wspY*$tstData[$i][1], 7, 7, $blue);
// ========================================================================================================================
return imagepng($im,$imgFileName);
}
// ========================================================== //// ========================================================== //
// Eta - wizard (kreator doboru)
// ========================================================== //// ========================================================== //
function createEtaPumpWizardChart($pupData, $tstData, $qVal, $imgFileName, $imgWidth=420, $imgHeight=330, $xDiv=10, $yDiv=10, $m3min=0)
{
$max_XVal=0;
$max_YVal=0;
$polynomial = new zc_math_polynomial($tstData);
$polynomial->calculate_coefficients();
// ustanawia najwy�sza� warto�� dla X i Y
for($i=0; $i<count($tstData); $i++)
{
if ($tstData[$i][0]>$max_XVal) $max_XVal=$tstData[$i][0];
if ($tstData[$i][1]>$max_YVal) $max_YVal=$tstData[$i][1];
}
$max_XVal = ceil($max_XVal+($max_XVal*0.1));
$max_YVal = ceil(($max_YVal+($max_YVal*0.1))*10)/10;
//sprawdza, czy m3/min, czy m3/h
if ($m3min==1)
{
$m3h = 1/60;
$ilosc_po_przecinku = 3;
$m3Desc = 'Q[m3/min]';
}
else
{
$m3h = 1;
$ilosc_po_przecinku = 2;
$m3Desc = 'Q[m3/h]';
}
if (file_exists('./fonts/calibri.ttf')) { $font = './fonts/calibri.ttf'; $fontBold = './fonts/Calibri_b.ttf'; }
else { $font = '../fonts/calibri.ttf'; $fontBold = '../fonts/Calibri_b.ttf'; }
$im = imagecreate($imgWidth, $imgHeight) or die("Cannot Initialize new GD image stream");
$background_color = imagecolorallocate($im, 255, 255, 255);
$black = imagecolorallocate($im, 0, 0, 0);
$gray = imagecolorallocate($im, 200, 200, 200);
$dark_gray = imagecolorallocate($im, 180, 180, 180);
$red = imagecolorallocate($im, 235, 0, 0);
$yellow = imagecolorallocate($im, 240, 240, 0);
$green = imagecolorallocate($im, 34, 177, 76);
$blue = imagecolorallocate($im, 0, 0, 200);
//$bool = imagecolorallocate($im, 185, 0, 0);
$bool = imagecolorallocate($im, 0, 128, 255);
$wspX = ($imgWidth-70)/$max_XVal;
$wspY = ($imgHeight-60)/$max_YVal;
imagefilledrectangle($im, 40, 30, 40+$wspX*$pupData[2], $imgHeight-30, imagecolorallocatealpha($im, 255, 0, 0, 245));
imagefilledrectangle($im, 40+$wspX*$pupData[2], 30, 40+$wspX*$pupData[3], $imgHeight-30, imagecolorallocatealpha($im, 255, 255, 0, 245));
imagefilledrectangle($im, 40+$wspX*$pupData[3], 30, 40+$wspX*$pupData[5], $imgHeight-30, imagecolorallocatealpha($im, 0, 255, 0, 245));
imagefilledrectangle($im, 40+$wspX*$pupData[5], 30, 40+$wspX*$pupData[6], $imgHeight-30, imagecolorallocatealpha($im, 255, 255, 0, 245));
imagefilledrectangle($im, 40+$wspX*$pupData[6], 30, $imgWidth-30, $imgHeight-30, imagecolorallocatealpha($im, 255, 0, 0, 245));
imagerectangle ($im , 40, 30, $imgWidth-30, $imgHeight-30, $gray);
// pionowa skala [X]
imagettftext($im, 10, 0, $imgWidth-61, $imgHeight-2,$black, $fontBold, $m3Desc);
// ========================================================================================================================
// ========================================================================================================================
for ($i=1; $i<$xDiv; $i++)
{
$szer=(($imgWidth-70)/$xDiv)*$i;
imageline($im, 40+$szer, 30, 40+$szer,$imgHeight-29, $gray);
list($left,,$right) = imageftbbox( 8, 0, $font, number_format((($max_XVal/$xDiv)*$i)*$m3h, $ilosc_po_przecinku, ',', ''));
$xMove = 15 + ($right - $left)/2;
imagettftext($im, 8, 0, $xMove+$szer, $imgHeight-15,$black, $font, number_format((($max_XVal/$xDiv)*$i)*$m3h, $ilosc_po_przecinku, ',', ''));
}
// ========================================================================================================================
// pozioma skala [Y]
imagettftext($im, 10, 0, 2, 12,$black, $fontBold, 'ETA');
// ========================================================================================================================
for ($i=0; $i<=$yDiv; $i++)
{
$wys=($imgHeight-60)-(($imgHeight-60)/$yDiv)*$i;
list($left,,$right) = imageftbbox( 8, 0, $font, number_format(($max_YVal/$yDiv)*$i, 2, ',', ''));
$xPos = 36 - ($right - $left);
imageline($im, 39, 30+$wys, $imgWidth-31, 30+$wys, $gray);
imagettftext($im, 8, 0, $xPos, 34+$wys,$black, $font, number_format(($max_YVal/$yDiv)*$i, 2, ',', ''));
}
// ========================================================================================================================
// rysuje linie
// ========================================================================================================================
$step = round(1/$wspX,2);
for ($i=0; $i<$max_XVal; $i+=$step)
{
$yLineTo = $polynomial->get_y($i+$step);
if ($yLineTo>0 && (40+$wspX*($i+$step))<=($imgWidth-32))
imageline($im, 40+$wspX*$i, ($imgHeight-30)-$wspY*$polynomial->get_y($i), 40+$wspX*($i+$step), ($imgHeight-30)-$wspY*$yLineTo, $black);
}
// ========================================================================================================================
// rysuje punkty
// ========================================================================================================================
for ($i=0; $i<count($tstData); $i++)
imagefilledellipse ($im, 40+$wspX*$tstData[$i][0],($imgHeight-30)-$wspY*$tstData[$i][1], 5, 5, $blue);
// ========================================================================================================================
// rysuje kropk� + opis
// ========================================================================================================================
if ($qVal>0)
{
$qyVal = $polynomial->get_y($qVal);
//imagesetstyle($im, Array($bool,$bool,$bool,$bool,IMG_COLOR_TRANSPARENT,IMG_COLOR_TRANSPARENT,IMG_COLOR_TRANSPARENT,IMG_COLOR_TRANSPARENT));
//imagedashedline($im, 40+$wspX*$qVal, 30, 40+$wspX*$qVal, $imgHeight-30, IMG_COLOR_STYLED);
//imageline($im, 40, ($imgHeight-30)-$wspY*$qyVal, $imgWidth-30, ($imgHeight-30)-$wspY*$qyVal, IMG_COLOR_STYLED);
imagefilledellipse ($im, 40+$wspX*$qVal,($imgHeight-30)-$wspY*$qyVal, 9, 9, $bool);
list($left,,$right) = imageftbbox( 8, 0, $font, '(Q='.round($qVal*$m3h,$ilosc_po_przecinku).'; ETA='.round($qyVal,2).')');
$xPos = ($imgWidth-47) - ($right - $left);
imagettftext($im, 10, 0, $xPos, 17,$bool, $font, '(Q='.round($qVal*$m3h,$ilosc_po_przecinku).'; ETA='.round($qyVal,2).')');
}
// ========================================================================================================================
return imagepng($im,$imgFileName);
}
// ========================================================== //// ========================================================== //
// Eta - pompy stacjonarne
// ========================================================== //// ========================================================== //
function createRoomEtaChart($pupData, $tstData, $qVal, $imgFileName, $imgWidth=420, $imgHeight=330, $xDiv=10, $yDiv=10, $m3min=0, $pointColor)
{
$max_XVal=0;
$max_YVal=0;
$polynomial = new zc_math_polynomial($tstData);
$polynomial->calculate_coefficients();
// ustanawia najwy�sza� warto�� dla X i Y
for($i=0; $i<count($tstData); $i++)
{
if ($tstData[$i][0]>$max_XVal) $max_XVal=$tstData[$i][0];
if ($tstData[$i][1]>$max_YVal) $max_YVal=$tstData[$i][1];
}
$max_XVal = ceil($max_XVal+($max_XVal*0.1));
$max_YVal = ceil(($max_YVal+($max_YVal*0.1))*10)/10;
//sprawdza, czy m3/min, czy m3/h
if ($m3min==1)
{
$m3h = 1/60;
$ilosc_po_przecinku = 3;
$m3Desc = 'Q[m3/min]';
}
else
{
$m3h = 1;
$ilosc_po_przecinku = 2;
$m3Desc = 'Q[m3/h]';
}
if (file_exists('./fonts/calibri.ttf')) { $font = './fonts/calibri.ttf'; $fontBold = './fonts/Calibri_b.ttf'; }
else { $font = '../fonts/calibri.ttf'; $fontBold = '../fonts/Calibri_b.ttf'; }
$im = imagecreate($imgWidth, $imgHeight) or die("Cannot Initialize new GD image stream");
$background_color = imagecolorallocate($im, 255, 255, 255);
$black = imagecolorallocate($im, 0, 0, 0);
$gray = imagecolorallocate($im, 200, 200, 200);
$dark_gray = imagecolorallocate($im, 180, 180, 180);
$red = imagecolorallocate($im, 235, 0, 0);
$yellow = imagecolorallocate($im, 240, 240, 0);
$green = imagecolorallocate($im, 34, 177, 76);
$blue = imagecolorallocate($im, 0, 0, 200);
$wspX = ($imgWidth-70)/$max_XVal;
$wspY = ($imgHeight-60)/$max_YVal;
imagerectangle ($im , 40, 30, $imgWidth-30, $imgHeight-30, $gray);
// pionowa skala [X]
imagettftext($im, 10, 0, $imgWidth-61, $imgHeight-2,$black, $fontBold, $m3Desc);
// ========================================================================================================================
// ========================================================================================================================
for ($i=1; $i<$xDiv; $i++)
{
$szer=(($imgWidth-70)/$xDiv)*$i;
imageline($im, 40+$szer, 30, 40+$szer,$imgHeight-29, $gray);
list($left,,$right) = imageftbbox( 8, 0, $font, number_format((($max_XVal/$xDiv)*$i)*$m3h, $ilosc_po_przecinku, ',', ''));
$xMove = 15 + ($right - $left)/2;
imagettftext($im, 8, 0, $xMove+$szer, $imgHeight-15,$black, $font, number_format((($max_XVal/$xDiv)*$i)*$m3h, $ilosc_po_przecinku, ',', ''));
}
// ========================================================================================================================
// pozioma skala [Y]
imagettftext($im, 10, 0, 2, 12,$black, $fontBold, 'ETA');
// ========================================================================================================================
for ($i=0; $i<=$yDiv; $i++)
{
$wys=($imgHeight-60)-(($imgHeight-60)/$yDiv)*$i;
list($left,,$right) = imageftbbox( 8, 0, $font, number_format(($max_YVal/$yDiv)*$i, 2, ',', ''));
$xPos = 36 - ($right - $left);
imageline($im, 39, 30+$wys, $imgWidth-31, 30+$wys, $gray);
imagettftext($im, 8, 0, $xPos, 34+$wys,$black, $font, number_format(($max_YVal/$yDiv)*$i, 2, ',', ''));
}
// ========================================================================================================================
// rysuje punkty
// ========================================================================================================================
for ($i=0; $i<count($tstData); $i++)
imagefilledellipse ($im, 40+$wspX*$tstData[$i][0],($imgHeight-30)-$wspY*$tstData[$i][1], 5, 5, $blue);
// ========================================================================================================================
// rysuje linie
// ========================================================================================================================
$step = round(1/$wspX,2);
for ($i=0; $i<$max_XVal; $i+=$step)
{
$yLineTo = $polynomial->get_y($i+$step);
if ($yLineTo>0 && (40+$wspX*($i+$step))<($imgWidth-32))
imageline($im, 40+$wspX*$i, ($imgHeight-30)-$wspY*$polynomial->get_y($i), 40+$wspX*($i+$step), ($imgHeight-30)-$wspY*$yLineTo, $blue);
}
// ========================================================================================================================
// rysuje kropk�
// ========================================================================================================================
imagefilledellipse ($im, 40+$wspX*$qVal,($imgHeight-30)-$wspY*$polynomial->get_y($qVal), 10, 10, imagecolorallocate($im, $pointColor['R'], $pointColor['G'], $pointColor['B']));
// ========================================================================================================================
return imagepng($im,$imgFileName);
}
// ========================================================== //// ========================================================== //