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' );
|
|
|
|
//-----------------------------------------------------------
|
|
$image1Width = 969;
|
|
$image1Height = 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
|
|
$image1 = @imageCreate( $image1Width , $image1Height )
|
|
or die( "Cannot Initialize new GD image stream" );
|
|
|
|
//---------------------------------
|
|
// Create basic color map
|
|
//---------------------------------
|
|
$colorMap = array();
|
|
|
|
//$colorMap[ "Background" ] = imageColorAllocate( $image1 , 0xDB , 0xB3 , 0xE6 );
|
|
$colorMap[ "Background" ] = imageColorAllocate( $image1 , 255, 255, 255 );
|
|
|
|
// Create a standard color palette
|
|
$colorMap[ "Black" ] = imagecolorallocate( $image1, 0, 0, 0 );
|
|
$colorMap[ "Red" ] = imagecolorallocate( $image1, 192, 0, 0 );
|
|
$colorMap[ "Green" ] = imagecolorallocate( $image1, 0, 192, 0 );
|
|
$colorMap[ "Blue" ] = imagecolorallocate( $image1, 0, 0, 192 );
|
|
$colorMap[ "Brown" ] = imagecolorallocate( $image1, 48, 48, 0 );
|
|
$colorMap[ "Cyan" ] = imagecolorallocate( $image1, 0, 192, 192 );
|
|
$colorMap[ "Purple" ] = imagecolorallocate( $image1, 192, 0, 192 );
|
|
$colorMap[ "LightGray" ] = imagecolorallocate( $image1, 192, 192, 192 );
|
|
|
|
$colorMap[ "DarkGray" ] = imagecolorallocate( $image1, 48, 48, 48 );
|
|
$colorMap[ "LightRed" ] = imagecolorallocate( $image1, 255, 0, 0 );
|
|
$colorMap[ "LightGreen" ] = imagecolorallocate( $image1, 0, 255, 0 );
|
|
$colorMap[ "LightBlue" ] = imagecolorallocate( $image1, 0, 0, 255 );
|
|
$colorMap[ "Yellow" ] = imagecolorallocate( $image1, 255, 255, 0 );
|
|
$colorMap[ "LightCyan" ] = imagecolorallocate( $image1, 0, 255, 255 );
|
|
$colorMap[ "LightPurple" ] = imagecolorallocate( $image1, 255, 0, 255 );
|
|
$colorMap[ "White" ] = imagecolorallocate( $image1, 255, 255, 255 );
|
|
$colorMap[ "DarkYellow" ] = imagecolorallocate( $image1, 255, 214, 0 );
|
|
|
|
$colorMap[ "Gray10" ] = imagecolorallocate( $image1 , 26 , 26 , 26 );
|
|
$colorMap[ "Gray20" ] = imagecolorallocate( $image1 , 51 , 51 , 51 );
|
|
$colorMap[ "Gray30" ] = imagecolorallocate( $image1 , 77 , 77 , 77 );
|
|
$colorMap[ "Gray40" ] = imagecolorallocate( $image1 , 102 , 102 , 102 );
|
|
$colorMap[ "Gray50" ] = imagecolorallocate( $image1 , 128 , 128 , 128 );
|
|
$colorMap[ "Gray60" ] = imagecolorallocate( $image1 , 154 , 154 , 154 );
|
|
$colorMap[ "Gray70" ] = imagecolorallocate( $image1 , 180 , 180 , 180 );
|
|
$colorMap[ "Gray80" ] = imagecolorallocate( $image1 , 205 , 205 , 205 );
|
|
$colorMap[ "Gray90" ] = imagecolorallocate( $image1 , 230 , 230 , 230 );
|
|
|
|
// New plot
|
|
$plot = new XY_PlotClass( $image1 );
|
|
|
|
// Setup boundaries
|
|
$plot->sizeWindow
|
|
(
|
|
$leftMargin,
|
|
$topMargin,
|
|
$image1Width - $rightMargin,
|
|
$image1Height - $bottomMargin
|
|
);
|
|
|
|
// Draw border around graph area.
|
|
|
|
|
|
//---------------------------------------------------------------------------
|
|
//
|
|
//---------------------------------------------------------------------------
|
|
|
|
|
|
//---------------------------------------------------------------------------
|
|
//
|
|
//---------------------------------------------------------------------------
|
|
|
|
|
|
|
|
function plotRectangleRange1($scaleFrom,$scaleTo,$xFrom,$xTo, $color)
|
|
{
|
|
global $plot;
|
|
global $image1Width;
|
|
global $leftMargin;
|
|
global $rightMargin;
|
|
global $image1Height;
|
|
global $topMargin;
|
|
global $bottomMargin;
|
|
global $image1;
|
|
|
|
$plot->resetData();
|
|
$frameWidth = $image1Width - $leftMargin - $rightMargin;
|
|
$scaleCounter = $frameWidth/($scaleTo-$scaleFrom);
|
|
|
|
if ($color == 'green_value')
|
|
$rgb = imagecolorallocatealpha($image1, 0, 255, 0, 100);
|
|
else if ($color == 'yellow_value')
|
|
$rgb = imagecolorallocatealpha($image1, 255, 255, 0, 100);
|
|
else if ($color == 'red_value')
|
|
$rgb = imagecolorallocatealpha($image1, 255, 0, 0, 100);
|
|
|
|
|
|
if ($leftMargin+$xTo*$scaleCounter > $image1Width-$rightMargin) $val=$image1Width-$rightMargin;
|
|
else $val=$leftMargin+$xTo*$scaleCounter;
|
|
|
|
imagefilledrectangle($image1, $leftMargin+$xFrom*$scaleCounter, $topMargin, $val, $image1Height-$bottomMargin, $rgb);
|
|
}
|
|
|
|
|
|
function plotCircleRange1($scaleXFrom,$scaleXTo,$scaleYFrom,$scaleYTo,$xParam,$yParam)
|
|
{
|
|
global $plot;
|
|
global $image1Width;
|
|
global $leftMargin;
|
|
global $rightMargin;
|
|
global $image1Height;
|
|
global $topMargin;
|
|
global $bottomMargin;
|
|
global $image1;
|
|
|
|
$plot->resetData();
|
|
$frameWidth = $image1Width - $leftMargin - $rightMargin;
|
|
$frameHeight = $image1Height - $topMargin - $bottomMargin;
|
|
$scaleXCounter = $frameWidth/($scaleXTo-$scaleXFrom);
|
|
$scaleYCounter = $frameHeight/($scaleYTo-$scaleYFrom);
|
|
if ($leftMargin+$xParam*$scaleXCounter > $image1Width-$rightMargin) $valX=$image1Width-$rightMargin;
|
|
else $valX=$leftMargin+$xParam*$scaleXCounter;
|
|
|
|
$valY=($image1Height-$bottomMargin)-$yParam*$scaleYCounter;
|
|
//$grey = imagecolorallocatealpha($image1, 150, 150, 150, 100);
|
|
$black = imagecolorallocate( $image1 , 0 , 0 , 0 );
|
|
imagefilledellipse($image1, $valX, $valY, 10, 10, $black);
|
|
}
|
|
|
|
|
|
|
|
?>
|