Initial commit
This commit is contained in:
+424
@@ -0,0 +1,424 @@
|
||||
<?php session_start();?>
|
||||
<?php
|
||||
require_once'./func.php';
|
||||
require_once("./dbaccess.php");
|
||||
require_once('./polynomial/math.php');
|
||||
|
||||
$con = mysql_connect($db_host, $db_user, $db_user_pass) or die ('cannot connect to db');
|
||||
mysql_select_db($db_name);
|
||||
mysql_query("SET NAMES utf8");
|
||||
mysql_query("SET CHARACTER_SET utf8_general_ci");
|
||||
|
||||
|
||||
|
||||
|
||||
function createHandPChart($pupData, $tstData, $qVal, $imgFileName, $imgWidth=420, $imgHeight=330, $xDiv=10, $yDiv=10, $m3min=0, $point=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));
|
||||
|
||||
|
||||
//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]';
|
||||
}
|
||||
|
||||
$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-4,$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, 'H[m]');
|
||||
// ========================================================================================================================
|
||||
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+1);
|
||||
if ($yLineTo>0)
|
||||
imageline($im, 40+$wspX*$i, ($imgHeight-30)-$wspY*$polynomial->get_y($i), 40+$wspX*($i+1), ($imgHeight-30)-$wspY*$yLineTo, $color);
|
||||
|
||||
|
||||
}
|
||||
// ========================================================================================================================
|
||||
|
||||
|
||||
// rysuje kropkę
|
||||
// 0 nie rysuje, 1 - zielona, 2 - żółta, 3 - czerwona, 4 - biała
|
||||
// ========================================================================================================================
|
||||
if ($point==1)
|
||||
imagefilledellipse ($im, 40+$wspX*$qVal,($imgHeight-30)-$wspY*$polynomial->get_y($qVal), 10, 10, $green);
|
||||
elseif ($point==2)
|
||||
imagefilledellipse ($im, 40+$wspX*$qVal,($imgHeight-28)-$wspY*$polynomial->get_y($qVal), 10, 10, $yellow);
|
||||
elseif ($point==3)
|
||||
imagefilledellipse ($im, 40+$wspX*$qVal,($imgHeight-25)-$wspY*$polynomial->get_y($qVal), 10, 10, $red);
|
||||
elseif ($point==4)
|
||||
{
|
||||
imagefilledellipse ($im, 40+$wspX*$qVal,($imgHeight-30)-$wspY*$polynomial->get_y($qVal), 10, 10, $background_color);
|
||||
imageellipse($im, 40+$wspX*$qVal,($imgHeight-30)-$wspY*$polynomial->get_y($qVal), 10, 10, $black);
|
||||
}
|
||||
|
||||
// ========================================================================================================================
|
||||
|
||||
return imagepng($im,$imgFileName);
|
||||
|
||||
}
|
||||
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 = ceil($max_XVal+($max_XVal*0.1));
|
||||
$max_YVal = ceil($max_YVal+($max_YVal*0.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]';
|
||||
}
|
||||
|
||||
$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-4,$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, 'H[m]');
|
||||
// ========================================================================================================================
|
||||
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, ',', ''));
|
||||
}
|
||||
// ========================================================================================================================
|
||||
|
||||
|
||||
|
||||
$wspX = ($imgWidth-70)/$max_XVal;
|
||||
$wspY = ($imgHeight-60)/$max_YVal;
|
||||
|
||||
// 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+1);
|
||||
if ($yLineTo>0)
|
||||
imageline($im, 40+$wspX*$i, ($imgHeight-30)-$wspY*$polynomial->get_y($i), 40+$wspX*($i+1), ($imgHeight-30)-$wspY*$yLineTo, $color);
|
||||
|
||||
}
|
||||
// ========================================================================================================================
|
||||
|
||||
|
||||
// rysuje kropkę
|
||||
// ========================================================================================================================
|
||||
imagefilledellipse ($im, 40+$wspX*$qVal,($imgHeight-30)-$wspY*$polynomial->get_y($qVal), 10, 10, $gray);
|
||||
// ========================================================================================================================
|
||||
|
||||
return imagepng($im,$imgFileName);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
//$data = array(array(0,176.12),array(8.25,176.12), array(15.00, 150.00), array(20.25, 92.78));
|
||||
unset($testArray); unset($pupArray);
|
||||
$testArray = sqlGetResAsArray("select TSD_VAL_04,TSD_VAL_08,TSD_VAL_14,TSD_VAL_18 from tst_tests left join tst_test_details on TSD_TST_ID=TST_ID where TST_ID=13112 order by TSD_MSR_STEP");
|
||||
$pupArray = sqlGetResAsArray("select PEP_X_PARAM from seg_pump_eng_param where PEP_TYPE='H' and PEP_PUP_ID=88 order by PEP_X_PARAM ");
|
||||
|
||||
for ($i=0; $i<count($testArray); $i++)
|
||||
{
|
||||
$dataH[] = array(
|
||||
$testArray[$i]['TSD_VAL_04'],
|
||||
$testArray[$i]['TSD_VAL_08'],
|
||||
);
|
||||
$dataEta[] = array(
|
||||
$testArray[$i]['TSD_VAL_04'],
|
||||
$testArray[$i]['TSD_VAL_18'],
|
||||
);
|
||||
|
||||
|
||||
}
|
||||
|
||||
for ($i=0; $i<count($pupArray); $i++)
|
||||
$dataP[] = $pupArray[$i]['PEP_X_PARAM'];
|
||||
|
||||
|
||||
|
||||
createHandPChart($dataP, $dataH, 19.5, 'testHP.png', 420, 330, 10, 10, 0, 4);
|
||||
|
||||
createEtaChart($dataP, $dataEta, 32, 'testETA.png', 420, 330, 10, 10, 0);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/*
|
||||
|
||||
$polynomial = new zc_math_polynomial($dataH);
|
||||
$polynomial->calculate_coefficients();
|
||||
|
||||
|
||||
$width = 570;
|
||||
$height = 400;
|
||||
|
||||
$max_YVal=250;
|
||||
$max_XVal=35;
|
||||
|
||||
$y_Split = 10;
|
||||
$x_Split = 10;
|
||||
|
||||
|
||||
$max_XVal = ceil($max_XVal+($max_XVal*0.1));
|
||||
$max_YVal = ceil($max_YVal+($max_YVal*0.1));
|
||||
|
||||
|
||||
// czy m3/h, czy m3/min
|
||||
//$m3h = 1;
|
||||
//$ilosc_po_przecinku = 2;
|
||||
$m3h = 1/60;
|
||||
$ilosc_po_przecinku = 3;
|
||||
|
||||
|
||||
$font = './fonts/calibri.ttf';
|
||||
$im = imagecreate($width, $height) 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);
|
||||
|
||||
|
||||
//imagerectangle ($im , 1, 1, $width-1, $height-1, $black);
|
||||
imagerectangle ($im , 40, 30, $width-30, $height-30, $gray);
|
||||
|
||||
|
||||
// pionowa skala [X]
|
||||
imagettftext($im, 10, 0, $width-61, $height-4,$black, $font, 'Q[m3/min]');
|
||||
// ========================================================================================================================
|
||||
// ========================================================================================================================
|
||||
for ($i=1; $i<$x_Split; $i++)
|
||||
{
|
||||
$szer=(($width-70)/$x_Split)*$i;
|
||||
imageline($im, 40+$szer, 30, 40+$szer,$height-29, $gray);
|
||||
|
||||
list($left,,$right) = imageftbbox( 8, 0, $font, number_format((($max_XVal/$x_Split)*$i)*$m3h, $ilosc_po_przecinku, ',', ''));
|
||||
$xMove = 15 + ($right - $left)/2;
|
||||
imagettftext($im, 8, 0, $xMove+$szer, $height-15,$black, $font, number_format((($max_XVal/$x_Split)*$i)*$m3h, $ilosc_po_przecinku, ',', ''));
|
||||
}
|
||||
// ========================================================================================================================
|
||||
|
||||
// pozioma skala [Y]
|
||||
imagettftext($im, 10, 0, 2, 12,$black, $font, 'H[m]');
|
||||
// ========================================================================================================================
|
||||
for ($i=0; $i<=$y_Split; $i++)
|
||||
{
|
||||
$wys=($height-60)-(($height-60)/$y_Split)*$i;
|
||||
list($left,,$right) = imageftbbox( 8, 0, $font, number_format(($max_YVal/$y_Split)*$i, 2, ',', ''));
|
||||
$xPos = 36 - ($right - $left);
|
||||
imageline($im, 39, 30+$wys, $width-31, 30+$wys, $gray);
|
||||
imagettftext($im, 8, 0, $xPos, 34+$wys,$black, $font, number_format(($max_YVal/$y_Split)*$i, 2, ',', ''));
|
||||
}
|
||||
// ========================================================================================================================
|
||||
|
||||
|
||||
$wspX = ($width-70)/$max_XVal;
|
||||
$wspY = ($height-60)/$max_YVal;
|
||||
|
||||
// rysuje punkty
|
||||
// ========================================================================================================================
|
||||
for ($i=0; $i<count($dataH); $i++)
|
||||
imagefilledellipse ($im, 40+$wspX*$dataH[$i][0],($height-30)-$wspY*$dataH[$i][1], 5, 5, $blue);
|
||||
// ========================================================================================================================
|
||||
|
||||
|
||||
|
||||
// rysuje linie
|
||||
// ========================================================================================================================
|
||||
for ($i=0; $i<35; $i++)
|
||||
{
|
||||
if ($i<=$pupArray[2]['PEP_X_PARAM']) $color = $red;
|
||||
else if ($i>$pupArray[2]['PEP_X_PARAM'] && $i<=$pupArray[3]['PEP_X_PARAM']) $color = $yellow;
|
||||
else if ($i>$pupArray[3]['PEP_X_PARAM'] && $i<=$pupArray[5]['PEP_X_PARAM']) $color = $green;
|
||||
else if ($i>$pupArray[5]['PEP_X_PARAM'] && $i<=$pupArray[6]['PEP_X_PARAM']) $color = $yellow;
|
||||
else $color = $red;
|
||||
|
||||
imageline($im, 40+$wspX*$i, ($height-30)-$wspY*$polynomial->get_y($i), 40+$wspX*($i+1), ($height-30)-$wspY*$polynomial->get_y($i+1), $color);
|
||||
}
|
||||
// ========================================================================================================================
|
||||
|
||||
|
||||
|
||||
// rysuje kropkę
|
||||
// ========================================================================================================================
|
||||
//imagefilledellipse ($im, 40+$wspX*23.4,($height-30)-$wspY*$polynomial->get_y(23.4), 10, 10, $green);
|
||||
imageellipse($im, 40+$wspX*23.4,($height-30)-$wspY*$polynomial->get_y(23.4), 10, 10, $black);
|
||||
// ========================================================================================================================
|
||||
|
||||
|
||||
|
||||
imagepng($im,'test.png');
|
||||
|
||||
*/
|
||||
|
||||
|
||||
mysql_close($con);
|
||||
?>
|
||||
|
||||
<img src="testHP.png">
|
||||
<br/>
|
||||
<img src="testETA.png">
|
||||
Reference in New Issue
Block a user