sizeWindow ( $leftMargin, $topMargin, $imageWidth - $rightMargin, $imageHeight - $bottomMargin ); // Draw border around graph area. imageRectangle ( $image, $leftMargin, $topMargin, $imageWidth - $rightMargin, $imageHeight - $bottomMargin, $colorMap[ "LightGray" ] ); //--------------------------------------------------------------------------- // //--------------------------------------------------------------------------- function plotRenderData( $data, $color ) { global $plot; $plot->resetData(); foreach ( $data as $point ) $plot->addData( $point[ 0 ], $point[ 1 ] ); $plot->setColor( $color ); $plot->autoScaleX_MinMax( 0 ); $plot->autoScaleY_MinMax( 1 ); } //--------------------------------------------------------------------------- // Custom vertical text-- just return value with dolor sign in front //--------------------------------------------------------------------------- function textCallback( $Value ) { return number_format( $Value, 1 ); } //--------------------------------------------------------------------------- // //--------------------------------------------------------------------------- function plotAddScale() { global $plot; global $X_MajorScale; global $X_MinorScale; global $Y_MajorScale; global $Y_MinorScale; global $colorMap; // Setup and draw minor horizontal scale (right to left). $plot->SetX_MinorDivisionScale( $X_MinorScale ); $plot->SetX_MinorDivisionColor( $colorMap[ "Gray90" ] ); $plot->DrawX_MinorDivisions(); // Setup and draw minor vertical scale (top to bottom). $plot->SetY_MinorDivisionScale( $Y_MinorScale ); $plot->SetY_MinorDivisionColor( $colorMap[ "Gray90" ] ); $plot->DrawY_MinorDivisions(); //---------------------------------- // Setup and draw major horizontal scale (right to left). //---------------------------------- // Extend lines 5 pixels past margins for label. $plot->SetX_MajorDivisionExtention( 5 ); // Scale. $plot->SetX_MajorDivisionScale( $X_MajorScale ); // Division lines are blue. $plot->SetX_MajorDivisionColor( $colorMap[ "Gray80" ] ); // Text labels are dark gray. $plot->SetX_MajorDivisionTextColor( $colorMap[ "Black" ] ); $plot->SetX_MajorTextCallback( "textCallback" ); // Draw it. $plot->DrawX_MajorDivisions(); //---------------------------------- // Setup and draw major vertical scale (top to bottom) //---------------------------------- // Extend lines 5 pixels past margins for label. $plot->SetY_MajorDivisionExtention( 5 ); // Scale. $plot->SetY_MajorDivisionScale( $Y_MajorScale ); // Divisions in dark gray. $plot->SetY_MajorDivisionColor( $colorMap[ "Gray80" ] ); $plot->SetY_MajorTextCallback( "textCallback" ); // Lables in dark gray. $plot->SetY_MajorDivisionTextColor( $colorMap[ "Black" ] ); // Draw it. $plot->DrawY_MajorDivisions(); } function plotRenderRegression( $regression, $coefficients, $min, $max, $color ) { global $plot; global $imageWidth; global $leftMargin; global $rightMargin; $plot->resetData(); $frameWidth = $imageWidth - $leftMargin - $rightMargin; for ( $xIndex = 0; $xIndex < $frameWidth; ++$xIndex ) { $x = $xIndex * ( $max - $min ) / $frameWidth + $min; $y = $regression->interpolate( $coefficients, $x ); $plot->addData( $x, $y ); } $plot->setColor( $color ); $plot->renderWithLines(); } function plotRectangleRange($scaleFrom,$scaleTo,$xFrom,$xTo, $color) { global $plot; global $imageWidth; global $leftMargin; global $rightMargin; global $imageHeight; global $topMargin; global $bottomMargin; global $image; $plot->resetData(); $frameWidth = $imageWidth - $leftMargin - $rightMargin; $scaleCounter = $frameWidth/($scaleTo-$scaleFrom); if ($color == 'green_value') $rgb = imagecolorallocatealpha($image, 0, 255, 0, 100); else if ($color == 'yellow_value') $rgb = imagecolorallocatealpha($image, 255, 255, 0, 100); else if ($color == 'red_value') $rgb = imagecolorallocatealpha($image, 255, 0, 0, 100); if ($leftMargin+$xTo*$scaleCounter > $imageWidth-$rightMargin) $val=$imageWidth-$rightMargin; else $val=$leftMargin+$xTo*$scaleCounter; imagefilledrectangle($image, $leftMargin+$xFrom*$scaleCounter, $topMargin, $val, $imageHeight-$bottomMargin, $rgb); } function plotCircleRange($scaleXFrom,$scaleXTo,$scaleYFrom,$scaleYTo,$xParam,$yParam) { global $plot; global $imageWidth; global $leftMargin; global $rightMargin; global $imageHeight; global $topMargin; global $bottomMargin; global $image; $plot->resetData(); $frameWidth = $imageWidth - $leftMargin - $rightMargin; $frameHeight = $imageHeight - $topMargin - $bottomMargin; $scaleXCounter = $frameWidth/($scaleXTo-$scaleXFrom); $scaleYCounter = $frameHeight/($scaleYTo-$scaleYFrom); if ($leftMargin+$xParam*$scaleXCounter > $imageWidth-$rightMargin) $valX=$imageWidth-$rightMargin; else $valX=$leftMargin+$xParam*$scaleXCounter; $valY=($imageHeight-$bottomMargin)-$yParam*$scaleYCounter; //$grey = imagecolorallocatealpha($image, 150, 150, 150, 100); $black = imagecolorallocate( $image , 0 , 0 , 0 ); imagefilledellipse($image, $valX, $valY, 10, 10, $black); } ?>