148 lines
5.3 KiB
PHP
148 lines
5.3 KiB
PHP
<?php
|
|
|
|
// Load the least-square regression class.
|
|
require_once('./polynomial/XY_Plot.php' );
|
|
|
|
//-----------------------------------------------------------
|
|
$image2Width = 969;
|
|
$image2Height = 330;
|
|
|
|
$leftMargin = 25;
|
|
$rightMargin = 50;
|
|
|
|
$topMargin = 25;
|
|
$bottomMargin = 40;
|
|
|
|
// Verticle scale
|
|
$Y_MajorScale = 0.1;
|
|
$Y_MinorScale = $Y_MajorScale / 5;
|
|
$X_MajorScale = 0.1;
|
|
$X_MinorScale = $X_MajorScale / 5;
|
|
//-----------------------------------------------------------
|
|
|
|
// Create image
|
|
$image2 = @imageCreate( $image2Width , $image2Height )
|
|
or die( "Cannot Initialize new GD image stream" );
|
|
|
|
//---------------------------------
|
|
// Create basic color map
|
|
//---------------------------------
|
|
$colorMap = array();
|
|
|
|
//$colorMap[ "Background" ] = imageColorAllocate( $image2 , 0xDB , 0xB3 , 0xE6 );
|
|
$colorMap[ "Background" ] = imageColorAllocate( $image2 , 255, 255, 255 );
|
|
|
|
// Create a standard color palette
|
|
$colorMap[ "Black" ] = imagecolorallocate( $image2, 0, 0, 0 );
|
|
$colorMap[ "Red" ] = imagecolorallocate( $image2, 192, 0, 0 );
|
|
$colorMap[ "Green" ] = imagecolorallocate( $image2, 0, 192, 0 );
|
|
$colorMap[ "Blue" ] = imagecolorallocate( $image2, 0, 0, 192 );
|
|
$colorMap[ "Brown" ] = imagecolorallocate( $image2, 48, 48, 0 );
|
|
$colorMap[ "Cyan" ] = imagecolorallocate( $image2, 0, 192, 192 );
|
|
$colorMap[ "Purple" ] = imagecolorallocate( $image2, 192, 0, 192 );
|
|
$colorMap[ "LightGray" ] = imagecolorallocate( $image2, 192, 192, 192 );
|
|
|
|
$colorMap[ "DarkGray" ] = imagecolorallocate( $image2, 48, 48, 48 );
|
|
$colorMap[ "LightRed" ] = imagecolorallocate( $image2, 255, 0, 0 );
|
|
$colorMap[ "LightGreen" ] = imagecolorallocate( $image2, 0, 255, 0 );
|
|
$colorMap[ "LightBlue" ] = imagecolorallocate( $image2, 0, 0, 255 );
|
|
$colorMap[ "Yellow" ] = imagecolorallocate( $image2, 255, 255, 0 );
|
|
$colorMap[ "LightCyan" ] = imagecolorallocate( $image2, 0, 255, 255 );
|
|
$colorMap[ "LightPurple" ] = imagecolorallocate( $image2, 255, 0, 255 );
|
|
$colorMap[ "White" ] = imagecolorallocate( $image2, 255, 255, 255 );
|
|
$colorMap[ "DarkYellow" ] = imagecolorallocate( $image2, 255, 214, 0 );
|
|
|
|
$colorMap[ "Gray10" ] = imagecolorallocate( $image2 , 26 , 26 , 26 );
|
|
$colorMap[ "Gray20" ] = imagecolorallocate( $image2 , 51 , 51 , 51 );
|
|
$colorMap[ "Gray30" ] = imagecolorallocate( $image2 , 77 , 77 , 77 );
|
|
$colorMap[ "Gray40" ] = imagecolorallocate( $image2 , 102 , 102 , 102 );
|
|
$colorMap[ "Gray50" ] = imagecolorallocate( $image2 , 128 , 128 , 128 );
|
|
$colorMap[ "Gray60" ] = imagecolorallocate( $image2 , 154 , 154 , 154 );
|
|
$colorMap[ "Gray70" ] = imagecolorallocate( $image2 , 180 , 180 , 180 );
|
|
$colorMap[ "Gray80" ] = imagecolorallocate( $image2 , 205 , 205 , 205 );
|
|
$colorMap[ "Gray90" ] = imagecolorallocate( $image2 , 230 , 230 , 230 );
|
|
|
|
// New plot
|
|
$plot = new XY_PlotClass( $image2 );
|
|
|
|
// Setup boundaries
|
|
$plot->sizeWindow
|
|
(
|
|
$leftMargin,
|
|
$topMargin,
|
|
$image2Width - $rightMargin,
|
|
$image2Height - $bottomMargin
|
|
);
|
|
|
|
// Draw border around graph area.
|
|
|
|
|
|
//---------------------------------------------------------------------------
|
|
//
|
|
//---------------------------------------------------------------------------
|
|
|
|
|
|
//---------------------------------------------------------------------------
|
|
//
|
|
//---------------------------------------------------------------------------
|
|
|
|
|
|
|
|
function plotRectangleRange2($scaleFrom,$scaleTo,$xFrom,$xTo, $color)
|
|
{
|
|
global $plot;
|
|
global $image2Width;
|
|
global $leftMargin;
|
|
global $rightMargin;
|
|
global $image2Height;
|
|
global $topMargin;
|
|
global $bottomMargin;
|
|
global $image2;
|
|
|
|
$plot->resetData();
|
|
$frameWidth = $image2Width - $leftMargin - $rightMargin;
|
|
$scaleCounter = $frameWidth/($scaleTo-$scaleFrom);
|
|
|
|
if ($color == 'green_value')
|
|
$rgb = imagecolorallocatealpha($image2, 0, 255, 0, 100);
|
|
else if ($color == 'yellow_value')
|
|
$rgb = imagecolorallocatealpha($image2, 255, 255, 0, 100);
|
|
else if ($color == 'red_value')
|
|
$rgb = imagecolorallocatealpha($image2, 255, 0, 0, 100);
|
|
|
|
|
|
if ($leftMargin+$xTo*$scaleCounter > $image2Width-$rightMargin) $val=$image2Width-$rightMargin;
|
|
else $val=$leftMargin+$xTo*$scaleCounter;
|
|
|
|
imagefilledrectangle($image2, $leftMargin+$xFrom*$scaleCounter, $topMargin, $val, $image2Height-$bottomMargin, $rgb);
|
|
}
|
|
|
|
|
|
function plotCircleRange2($scaleXFrom,$scaleXTo,$scaleYFrom,$scaleYTo,$xParam,$yParam)
|
|
{
|
|
global $plot;
|
|
global $image2Width;
|
|
global $leftMargin;
|
|
global $rightMargin;
|
|
global $image2Height;
|
|
global $topMargin;
|
|
global $bottomMargin;
|
|
global $image2;
|
|
|
|
$plot->resetData();
|
|
$frameWidth = $image2Width - $leftMargin - $rightMargin;
|
|
$frameHeight = $image2Height - $topMargin - $bottomMargin;
|
|
$scaleXCounter = $frameWidth/($scaleXTo-$scaleXFrom);
|
|
$scaleYCounter = $frameHeight/($scaleYTo-$scaleYFrom);
|
|
if ($leftMargin+$xParam*$scaleXCounter > $image2Width-$rightMargin) $valX=$image2Width-$rightMargin;
|
|
else $valX=$leftMargin+$xParam*$scaleXCounter;
|
|
|
|
$valY=($image2Height-$bottomMargin)-$yParam*$scaleYCounter;
|
|
//$grey = imagecolorallocatealpha($image2, 150, 150, 150, 100);
|
|
$black = imagecolorallocate( $image2 , 0 , 0 , 0 );
|
|
imagefilledellipse($image2, $valX, $valY, 10, 10, $black);
|
|
}
|
|
|
|
|
|
|
|
?>
|