public function center()
    {
        /* Determine the real center */
        $TargetCenterX = ($this->X2 - $this->X1) / 2 + $this->X1;
        $TargetCenterY = ($this->Y2 - $this->Y1) / 2 + $this->Y1;

        /* Get current boundaries */
        $XMin = $this->X2;
        $XMax = $this->X1;
        $YMin = $this->Y2;
        $YMax = $this->Y1;
        foreach ($this->Data as $Key => $Settings) {
            $X = $Settings["X"];
            $Y = $Settings["Y"];

            if ($X < $XMin) {
                $XMin = $X;
            }
            if ($X > $XMax) {
                $XMax = $X;
            }
            if ($Y < $YMin) {
                $YMin = $Y;
            }
            if ($Y > $YMax) {
                $YMax = $Y;
            }
        }
        $CurrentCenterX = ($XMax - $XMin) / 2 + $XMin;
        $CurrentCenterY = ($YMax - $YMin) / 2 + $YMin;

        /* Compute the offset to apply */
        $XOffset = $TargetCenterX - $CurrentCenterX;
        $YOffset = $TargetCenterY - $CurrentCenterY;

        /* Correct the points position */
        foreach ($this->Data as $Key => $Settings) {
            $this->Data[$Key]["X"] = $Settings["X"] + $XOffset;
            $this->Data[$Key]["Y"] = $Settings["Y"] + $YOffset;
        }
    }
public function center()
    {
        /* Determine the real center */
        $TargetCenterX = ($this->X2 - $this->X1) / 2 + $this->X1;
        $TargetCenterY = ($this->Y2 - $this->Y1) / 2 + $this->Y1;

        /* Get current boundaries */
        $XMin = $this->X2;
        $XMax = $this->X1;
        $YMin = $this->Y2;
        $YMax = $this->Y1;
        foreach ($this->Data as $Key => $Settings) {
            $X = $Settings["X"];
            $Y = $Settings["Y"];

            if ($X < $XMin) {
                $XMin = $X;
            }
            if ($X > $XMax) {
                $XMax = $X;
            }
            if ($Y < $YMin) {
                $YMin = $Y;
            }
            if ($Y > $YMax) {
                $YMax = $Y;
            }
        }
        $CurrentCenterX = ($XMax - $XMin) / 2 + $XMin;
        $CurrentCenterY = ($YMax - $YMin) / 2 + $YMin;

        /* Compute the offset to apply */
        $XOffset = $TargetCenterX - $CurrentCenterX;
        $YOffset = $TargetCenterY - $CurrentCenterY;

        /* Correct the points position */
        foreach ($this->Data as $Key => $Settings) {
            $this->Data[$Key]["X"] = $Settings["X"] + $XOffset;
            $this->Data[$Key]["Y"] = $Settings["Y"] + $YOffset;
        }
    }
public function center ( ) { /* Determine the real center */ $ TargetCenterX = ( $ this -> X2 - $ this -> X1 ) / 2 + $ this -> X1 ; $ TargetCenterY = ( $ this -> Y2 - $ this -> Y1 ) / 2 + $ this -> Y1 ; /* Get current boundaries */ $ XMin = $ this -> X2 ; $ XMax = $ this -> X1 ; $ YMin = $ this -> Y2 ; $ YMax = $ this -> Y1 ; foreach ( $ this -> Data as $ Key => $ Settings ) { $ X = $ Settings [ "X" ] ; $ Y = $ Settings [ "Y" ] ; if ( $ X < $ XMin ) { $ XMin = $ X ; } if ( $ X > $ XMax ) { $ XMax = $ X ; } if ( $ Y < $ YMin ) { $ YMin = $ Y ; } if ( $ Y > $ YMax ) { $ YMax = $ Y ; } } $ CurrentCenterX = ( $ XMax - $ XMin ) / 2 + $ XMin ; $ CurrentCenterY = ( $ YMax - $ YMin ) / 2 + $ YMin ; /* Compute the offset to apply */ $ XOffset = $ TargetCenterX - $ CurrentCenterX ; $ YOffset = $ TargetCenterY - $ CurrentCenterY ; /* Correct the points position */ foreach ( $ this -> Data as $ Key => $ Settings ) { $ this -> Data [ $ Key ] [ "X" ] = $ Settings [ "X" ] + $ XOffset ; $ this -> Data [ $ Key ] [ "Y" ] = $ Settings [ "Y" ] + $ YOffset ; } }
Center the graph
Center the graph