resetData(); foreach ( $data as $point ) $plot->addData( $point[ 0 ], $point[ 1 ] ); $plot->setColor( $color ); $plot->autoScaleX_MinMax( 0 ); $plot->autoScaleY_MinMax( 1 ); } 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(); } ?>