Draw a filled spline chart
@param array $Format
557204
public function drawFilledSplineChart(array $Format = [])
    {
        $DisplayValues = isset($Format["DisplayValues"]) ? $Format["DisplayValues"] : false;
        $DisplayOffset = isset($Format["DisplayOffset"]) ? $Format["DisplayOffset"] : 2;
        $DisplayColor = isset($Format["DisplayColor"]) ? $Format["DisplayColor"] : DISPLAY_MANUAL;
        $DisplayR = isset($Format["DisplayR"]) ? $Format["DisplayR"] : 0;
        $DisplayG = isset($Format["DisplayG"]) ? $Format["DisplayG"] : 0;
        $DisplayB = isset($Format["DisplayB"]) ? $Format["DisplayB"] : 0;
        $AroundZero = isset($Format["AroundZero"]) ? $Format["AroundZero"] : true;
        $Threshold = isset($Format["Threshold"]) ? $Format["Threshold"] : null;

        $this->LastChartLayout = CHART_LAST_LAYOUT_REGULAR;

        $Data = $this->DataSet->getData();
        list($XMargin, $XDivs) = $this->scaleGetXSettings();
        foreach ($Data["Series"] as $SerieName => $Serie) {
            if ($Serie["isDrawable"] == true && $SerieName != $Data["Abscissa"]) {
                $R = $Serie["Color"]["R"];
                $G = $Serie["Color"]["G"];
                $B = $Serie["Color"]["B"];
                $Alpha = $Serie["Color"]["Alpha"];
                $Ticks = $Serie["Ticks"];
                if ($DisplayColor == DISPLAY_AUTO) {
                    $DisplayR = $R;
                    $DisplayG = $G;
                    $DisplayB = $B;
                }

                $AxisID = $Serie["Axis"];
                $Mode = $Data["Axis"][$AxisID]["Display"];
                $Format = $Data["Axis"][$AxisID]["Format"];
                $Unit = $Data["Axis"][$AxisID]["Unit"];

                $PosArray = $this->scaleComputeY(
                    $Serie["Data"],
                    ["AxisID" => $Serie["Axis"]]
                );
                if ($AroundZero) {
                    $YZero = $this->scaleComputeY(0, ["AxisID" => $Serie["Axis"]]);
                }

                if ($Threshold != null) {
                    foreach ($Threshold as $Key => $Params) {
                        $Threshold[$Key]["MinX"] = $this->scaleComputeY(
                            $Params["Min"],
                            ["AxisID" => $Serie["Axis"]]
                        );
                        $Threshold[$Key]["MaxX"] = $this->scaleComputeY(
                            $Params["Max"],
                            ["AxisID" => $Serie["Axis"]]
                        );
                    }
                }

                $this->DataSet->Data["Series"][$SerieName]["XOffset"] = 0;

                if ($Data["Orientation"] == SCALE_POS_LEFTRIGHT) {
                    if ($XDivs == 0) {
                        $XStep = ($this->GraphAreaX2 - $this->GraphAreaX1) / 4;
                    } else {
                        $XStep = ($this->GraphAreaX2 - $this->GraphAreaX1 - $XMargin * 2) / $XDivs;
                    }
                    $X = $this->GraphAreaX1 + $XMargin;
                    $WayPoints = [];
                    $Force = $XStep / 5;

                    if (!$AroundZero) {
                        $YZero = $this->GraphAreaY2 - 1;
                    }
                    if ($YZero > $this->GraphAreaY2 - 1) {
                        $YZero = $this->GraphAreaY2 - 1;
                    }
                    if ($YZero < $this->GraphAreaY1 + 1) {
                        $YZero = $this->GraphAreaY1 + 1;
                    }

                    if (!is_array($PosArray)) {
                        $Value = $PosArray;
                        $PosArray = [];
                        $PosArray[0] = $Value;
                    }
                    foreach ($PosArray as $Key => $Y) {
                        if ($DisplayValues) {
                            $this->drawText(
                                $X,
                                $Y - $DisplayOffset,
                                $this->scaleFormat(
                                    $Serie["Data"][$Key],
                                    $Mode,
                                    $Format,
                                    $Unit
                                ),
                                [
                                    "R" => $DisplayR,
                                    "G" => $DisplayG,
                                    "B" => $DisplayB,
                                    "Align" => TEXT_ALIGN_BOTTOMMIDDLE
                                ]
                            );
                        }
                        if ($Y == VOID) {
                            $Area = $this->drawSpline(
                                $WayPoints,
                                ["Force" => $Force, "PathOnly" => true]
                            );

                            if (count($Area)) {
                                foreach ($Area as $key => $Points) {
                                    $Corners = [];
                                    $Corners[] = $Area[$key][0]["X"];
                                    $Corners[] = $YZero;
                                    foreach ($Points as $subKey => $Point) {
                                        if ($subKey == count($Points) - 1) {
                                            $Corners[] = $Point["X"] - 1;
                                        } else {
                                            $Corners[] = $Point["X"];
                                        }
                                        $Corners[] = $Point["Y"] + 1;
                                    }
                                    $Corners[] = $Points[$subKey]["X"] - 1;
                                    $Corners[] = $YZero;

                                    $this->drawPolygonChart(
                                        $Corners,
                                        [
                                            "R" => $R,
                                            "G" => $G,
                                            "B" => $B,
                                            "Alpha" => $Alpha / 2,
                                            "NoBorder" => true,
                                            "Threshold" => $Threshold
                                        ]
                                    );
                                }
                                $this->drawSpline(
                                    $WayPoints,
                                    [
                                        "Force" => $Force,
                                        "R" => $R,
                                        "G" => $G,
                                        "B" => $B,
                                        "Alpha" => $Alpha,
                                        "Ticks" => $Ticks
                                    ]
                                );
                            }

                            $WayPoints = [];
                        } else {
                            $WayPoints[] = [$X, $Y - .5]; /* -.5 for AA visual fix */
                        }
                        $X = $X + $XStep;
                    }
                    $Area = $this->drawSpline($WayPoints, ["Force" => $Force, "PathOnly" => true]);

                    if (count($Area)) {
                        foreach ($Area as $key => $Points) {
                            $Corners = [];
                            $Corners[] = $Area[$key][0]["X"];
                            $Corners[] = $YZero;
                            foreach ($Points as $subKey => $Point) {
                                if ($subKey == count($Points) - 1) {
                                    $Corners[] = $Point["X"] - 1;
                                } else {
                                    $Corners[] = $Point["X"];
                                }
                                $Corners[] = $Point["Y"] + 1;
                            }
                            $Corners[] = $Points[$subKey]["X"] - 1;
                            $Corners[] = $YZero;

                            $this->drawPolygonChart(
                                $Corners,
                                [
                                    "R" => $R,
                                    "G" => $G,
                                    "B" => $B,
                                    "Alpha" => $Alpha / 2,
                                    "NoBorder" => true,
                                    "Threshold" => $Threshold
                                ]
                            );
                        }
                        $this->drawSpline(
                            $WayPoints,
                            [
                                "Force" => $Force,
                                "R" => $R,
                                "G" => $G,
                                "B" => $B,
                                "Alpha" => $Alpha,
                                "Ticks" => $Ticks
                            ]
                        );
                    }
                } else {
                    if ($XDivs == 0) {
                        $YStep = ($this->GraphAreaY2 - $this->GraphAreaY1) / 4;
                    } else {
                        $YStep = ($this->GraphAreaY2 - $this->GraphAreaY1 - $XMargin * 2) / $XDivs;
                    }
                    $Y = $this->GraphAreaY1 + $XMargin;
                    $WayPoints = [];
                    $Force = $YStep / 5;

                    if (!$AroundZero) {
                        $YZero = $this->GraphAreaX1 + 1;
                    }
                    if ($YZero > $this->GraphAreaX2 - 1) {
                        $YZero = $this->GraphAreaX2 - 1;
                    }
                    if ($YZero < $this->GraphAreaX1 + 1) {
                        $YZero = $this->GraphAreaX1 + 1;
                    }

                    if (!is_array($PosArray)) {
                        $Value = $PosArray;
                        $PosArray = [];
                        $PosArray[0] = $Value;
                    }
                    foreach ($PosArray as $Key => $X) {
                        if ($DisplayValues) {
                            $this->drawText(
                                $X + $DisplayOffset,
                                $Y,
                                $this->scaleFormat($Serie["Data"][$Key], $Mode, $Format, $Unit),
                                [
                                    "Angle" => 270,
                                    "R" => $DisplayR,
                                    "G" => $DisplayG,
                                    "B" => $DisplayB,
                                    "Align" => TEXT_ALIGN_BOTTOMMIDDLE
                                ]
                            );
                        }
                        if ($X == VOID) {
                            $Area = $this->drawSpline(
                                $WayPoints,
                                ["Force" => $Force, "PathOnly" => true]
                            );

                            if (count($Area)) {
                                foreach ($Area as $key => $Points) {
                                    $Corners = [];
                                    $Corners[] = $YZero;
                                    $Corners[] = $Area[$key][0]["Y"];
                                    foreach ($Points as $subKey => $Point) {
                                        if ($subKey == count($Points) - 1) {
                                            $Corners[] = $Point["X"] - 1;
                                        } else {
                                            $Corners[] = $Point["X"];
                                        }
                                        $Corners[] = $Point["Y"];
                                    }
                                    $Corners[] = $YZero;
                                    $Corners[] = $Points[$subKey]["Y"] - 1;

                                    $this->drawPolygonChart(
                                        $Corners,
                                        [
                                            "R" => $R,
                                            "G" => $G,
                                            "B" => $B,
                                            "Alpha" => $Alpha / 2,
                                            "NoBorder" => true,
                                            "Threshold" => $Threshold
                                        ]
                                    );
                                }
                                $this->drawSpline(
                                    $WayPoints,
                                    [
                                        "Force" => $Force,
                                        "R" => $R,
                                        "G" => $G,
                                        "B" => $B,
                                        "Alpha" => $Alpha,
                                        "Ticks" => $Ticks
                                    ]
                                );
                            }

                            $WayPoints = [];
                        } else {
                            $WayPoints[] = [$X, $Y];
                        }
                        $Y = $Y + $YStep;
                    }
                    $Area = $this->drawSpline(
                        $WayPoints,
                        ["Force" => $Force, "PathOnly" => true]
                    );

                    if (count($Area)) {
                        foreach ($Area as $key => $Points) {
                            $Corners = [];
                            $Corners[] = $YZero;
                            $Corners[] = $Area[$key][0]["Y"];
                            foreach ($Points as $subKey => $Point) {
                                if ($subKey == count($Points) - 1) {
                                    $Corners[] = $Point["X"] - 1;
                                } else {
                                    $Corners[] = $Point["X"];
                                }
                                $Corners[] = $Point["Y"];
                            }
                            $Corners[] = $YZero;
                            $Corners[] = $Points[$subKey]["Y"] - 1;

                            $this->drawPolygonChart(
                                $Corners,
                                [
                                    "R" => $R,
                                    "G" => $G,
                                    "B" => $B,
                                    "Alpha" => $Alpha / 2,
                                    "NoBorder" => true,
                                    "Threshold" => $Threshold
                                ]
                            );
                        }
                        $this->drawSpline(
                            $WayPoints,
                            [
                                "Force" => $Force,
                                "R" => $R,
                                "G" => $G,
                                "B" => $B,
                                "Alpha" => $Alpha,
                                "Ticks" => $Ticks
                            ]
                        );
                    }
                }
            }
        }
    }
974568
public function formatColumn(string $column, string $format)
    {
        $this->worksheet
            ->getStyle($column . '1:' . $column . $this->worksheet->getHighestRow())
            ->getNumberFormat()
            ->setFormatCode($format);
    }
697152
public function drawLabelBox($X, $Y, $Title, array $Captions, array $Format = [])
    {
        $NoTitle = isset($Format["NoTitle"]) ? $Format["NoTitle"] : null;
        $BoxWidth = isset($Format["BoxWidth"]) ? $Format["BoxWidth"] : 50;
        $DrawSerieColor = isset($Format["DrawSerieColor"]) ? $Format["DrawSerieColor"] : true;
        $SerieBoxSize = isset($Format["SerieBoxSize"]) ? $Format["SerieBoxSize"] : 6;
        $SerieBoxSpacing = isset($Format["SerieBoxSpacing"]) ? $Format["SerieBoxSpacing"] : 4;
        $VerticalMargin = isset($Format["VerticalMargin"]) ? $Format["VerticalMargin"] : 10;
        $HorizontalMargin = isset($Format["HorizontalMargin"]) ? $Format["HorizontalMargin"] : 8;
        $R = isset($Format["R"]) ? $Format["R"] : $this->FontColorR;
        $G = isset($Format["G"]) ? $Format["G"] : $this->FontColorG;
        $B = isset($Format["B"]) ? $Format["B"] : $this->FontColorB;
        $FontName = isset($Format["FontName"]) ? $this->loadFont($Format["FontName"], 'fonts') : $this->FontName;
        $FontSize = isset($Format["FontSize"]) ? $Format["FontSize"] : $this->FontSize;
        $TitleMode = isset($Format["TitleMode"]) ? $Format["TitleMode"] : LABEL_TITLE_NOBACKGROUND;
        $TitleR = isset($Format["TitleR"]) ? $Format["TitleR"] : $R;
        $TitleG = isset($Format["TitleG"]) ? $Format["TitleG"] : $G;
        $TitleB = isset($Format["TitleB"]) ? $Format["TitleB"] : $B;
        $TitleBackgroundR = isset($Format["TitleBackgroundR"]) ? $Format["TitleBackgroundR"] : 0;
        $TitleBackgroundG = isset($Format["TitleBackgroundG"]) ? $Format["TitleBackgroundG"] : 0;
        $TitleBackgroundB = isset($Format["TitleBackgroundB"]) ? $Format["TitleBackgroundB"] : 0;
        $GradientStartR = isset($Format["GradientStartR"]) ? $Format["GradientStartR"] : 255;
        $GradientStartG = isset($Format["GradientStartG"]) ? $Format["GradientStartG"] : 255;
        $GradientStartB = isset($Format["GradientStartB"]) ? $Format["GradientStartB"] : 255;
        $GradientEndR = isset($Format["GradientEndR"]) ? $Format["GradientEndR"] : 220;
        $GradientEndG = isset($Format["GradientEndG"]) ? $Format["GradientEndG"] : 220;
        $GradientEndB = isset($Format["GradientEndB"]) ? $Format["GradientEndB"] : 220;
        $BoxAlpha = isset($Format["BoxAlpha"]) ? $Format["BoxAlpha"] : 100;

        if (!$DrawSerieColor) {
            $SerieBoxSize = 0;
            $SerieBoxSpacing = 0;
        }

        $TxtPos = $this->getTextBox($X, $Y, $FontName, $FontSize, 0, $Title);
        $TitleWidth = ($TxtPos[1]["X"] - $TxtPos[0]["X"]) + $VerticalMargin * 2;
        $TitleHeight = ($TxtPos[0]["Y"] - $TxtPos[2]["Y"]);

        if ($NoTitle) {
            $TitleWidth = 0;
            $TitleHeight = 0;
        }

        $CaptionWidth = 0;
        $CaptionHeight = -$HorizontalMargin;
        foreach ($Captions as $Key => $Caption) {
            $TxtPos = $this->getTextBox(
                $X,
                $Y,
                $FontName,
                $FontSize,
                0,
                $Caption["Caption"]
            );
            $CaptionWidth = max(
                $CaptionWidth,
                ($TxtPos[1]["X"] - $TxtPos[0]["X"]) + $VerticalMargin * 2
            );
            $CaptionHeight = $CaptionHeight
                + max(($TxtPos[0]["Y"] - $TxtPos[2]["Y"]), ($SerieBoxSize + 2))
                + $HorizontalMargin
            ;
        }

        if ($CaptionHeight <= 5) {
            $CaptionHeight = $CaptionHeight + $HorizontalMargin / 2;
        }

        if ($DrawSerieColor) {
            $CaptionWidth = $CaptionWidth + $SerieBoxSize + $SerieBoxSpacing;
        }

        $BoxWidth = max($BoxWidth, $TitleWidth, $CaptionWidth);

        $XMin = $X - 5 - floor(($BoxWidth - 10) / 2);
        $XMax = $X + 5 + floor(($BoxWidth - 10) / 2);

        $RestoreShadow = $this->Shadow;
        if ($this->Shadow == true) {
            $this->Shadow = false;

            $Poly = [];
            $Poly[] = $X + $this->ShadowX;
            $Poly[] = $Y + $this->ShadowX;
            $Poly[] = $X + 5 + $this->ShadowX;
            $Poly[] = $Y - 5 + $this->ShadowX;
            $Poly[] = $XMax + $this->ShadowX;
            $Poly[] = $Y - 5 + $this->ShadowX;

            if ($NoTitle) {
                $Poly[] = $XMax + $this->ShadowX;
                $Poly[] = $Y - 5 - $TitleHeight - $CaptionHeight - $HorizontalMargin * 2 + $this->ShadowX;
                $Poly[] = $XMin + $this->ShadowX;
                $Poly[] = $Y - 5 - $TitleHeight - $CaptionHeight - $HorizontalMargin * 2 + $this->ShadowX;
            } else {
                $Poly[] = $XMax + $this->ShadowX;
                $Poly[] = $Y - 5 - $TitleHeight - $CaptionHeight - $HorizontalMargin * 3 + $this->ShadowX;
                $Poly[] = $XMin + $this->ShadowX;
                $Poly[] = $Y - 5 - $TitleHeight - $CaptionHeight - $HorizontalMargin * 3 + $this->ShadowX;
            }

            $Poly[] = $XMin + $this->ShadowX;
            $Poly[] = $Y - 5 + $this->ShadowX;
            $Poly[] = $X - 5 + $this->ShadowX;
            $Poly[] = $Y - 5 + $this->ShadowX;
            $this->drawPolygon(
                $Poly,
                [
                    "R" => $this->ShadowR,
                    "G" => $this->ShadowG,
                    "B" => $this->ShadowB,
                    "Alpha" => $this->Shadowa
                ]
            );
        }

        /* Draw the background */
        $GradientSettings = [
            "StartR" => $GradientStartR,
            "StartG" => $GradientStartG,
            "StartB" => $GradientStartB,
            "EndR" => $GradientEndR,
            "EndG" => $GradientEndG,
            "EndB" => $GradientEndB,
            "Alpha" => $BoxAlpha
        ];
        if ($NoTitle) {
            $this->drawGradientArea(
                $XMin,
                $Y - 5 - $TitleHeight - $CaptionHeight - $HorizontalMargin * 2,
                $XMax,
                $Y - 6,
                DIRECTION_VERTICAL,
                $GradientSettings
            );
        } else {
            $this->drawGradientArea(
                $XMin,
                $Y - 5 - $TitleHeight - $CaptionHeight - $HorizontalMargin * 3,
                $XMax,
                $Y - 6,
                DIRECTION_VERTICAL,
                $GradientSettings
            );
        }
        $Poly = [];
        $Poly[] = $X;
        $Poly[] = $Y;
        $Poly[] = $X - 5;
        $Poly[] = $Y - 5;
        $Poly[] = $X + 5;
        $Poly[] = $Y - 5;
        $this->drawPolygon(
            $Poly,
            [
                "R" => $GradientEndR,
                "G" => $GradientEndG,
                "B" => $GradientEndB,
                "Alpha" => $BoxAlpha,
                "NoBorder" => true
            ]
        );

        /* Outer border */
        $OuterBorderColor = $this->allocateColor($this->Picture, 100, 100, 100, $BoxAlpha);
        imageline($this->Picture, $XMin, $Y - 5, $X - 5, $Y - 5, $OuterBorderColor);
        imageline($this->Picture, $X, $Y, $X - 5, $Y - 5, $OuterBorderColor);
        imageline($this->Picture, $X, $Y, $X + 5, $Y - 5, $OuterBorderColor);
        imageline($this->Picture, $X + 5, $Y - 5, $XMax, $Y - 5, $OuterBorderColor);
        if ($NoTitle) {
            imageline(
                $this->Picture,
                $XMin,
                $Y - 5 - $TitleHeight - $CaptionHeight - $HorizontalMargin * 2,
                $XMin,
                $Y - 5,
                $OuterBorderColor
            );
            imageline(
                $this->Picture,
                $XMax,
                $Y - 5 - $TitleHeight - $CaptionHeight - $HorizontalMargin * 2,
                $XMax,
                $Y - 5,
                $OuterBorderColor
            );
            imageline(
                $this->Picture,
                $XMin,
                $Y - 5 - $TitleHeight - $CaptionHeight - $HorizontalMargin * 2,
                $XMax,
                $Y - 5 - $TitleHeight - $CaptionHeight - $HorizontalMargin * 2,
                $OuterBorderColor
            );
        } else {
            imageline(
                $this->Picture,
                $XMin,
                $Y - 5 - $TitleHeight - $CaptionHeight - $HorizontalMargin * 3,
                $XMin,
                $Y - 5,
                $OuterBorderColor
            );
            imageline(
                $this->Picture,
                $XMax,
                $Y - 5 - $TitleHeight - $CaptionHeight - $HorizontalMargin * 3,
                $XMax,
                $Y - 5,
                $OuterBorderColor
            );
            imageline(
                $this->Picture,
                $XMin,
                $Y - 5 - $TitleHeight - $CaptionHeight - $HorizontalMargin * 3,
                $XMax,
                $Y - 5 - $TitleHeight - $CaptionHeight - $HorizontalMargin * 3,
                $OuterBorderColor
            );
        }

        /* Inner border */
        $InnerBorderColor = $this->allocateColor($this->Picture, 255, 255, 255, $BoxAlpha);
        imageline($this->Picture, $XMin + 1, $Y - 6, $X - 5, $Y - 6, $InnerBorderColor);
        imageline($this->Picture, $X, $Y - 1, $X - 5, $Y - 6, $InnerBorderColor);
        imageline($this->Picture, $X, $Y - 1, $X + 5, $Y - 6, $InnerBorderColor);
        imageline($this->Picture, $X + 5, $Y - 6, $XMax - 1, $Y - 6, $InnerBorderColor);
        if ($NoTitle) {
            imageline(
                $this->Picture,
                $XMin + 1,
                $Y - 4 - $TitleHeight - $CaptionHeight - $HorizontalMargin * 2,
                $XMin + 1,
                $Y - 6,
                $InnerBorderColor
            );
            imageline(
                $this->Picture,
                $XMax - 1,
                $Y - 4 - $TitleHeight - $CaptionHeight - $HorizontalMargin * 2,
                $XMax - 1,
                $Y - 6,
                $InnerBorderColor
            );
            imageline(
                $this->Picture,
                $XMin + 1,
                $Y - 4 - $TitleHeight - $CaptionHeight - $HorizontalMargin * 2,
                $XMax - 1,
                $Y - 4 - $TitleHeight - $CaptionHeight - $HorizontalMargin * 2,
                $InnerBorderColor
            );
        } else {
            imageline(
                $this->Picture,
                $XMin + 1,
                $Y - 4 - $TitleHeight - $CaptionHeight - $HorizontalMargin * 3,
                $XMin + 1,
                $Y - 6,
                $InnerBorderColor
            );
            imageline(
                $this->Picture,
                $XMax - 1,
                $Y - 4 - $TitleHeight - $CaptionHeight - $HorizontalMargin * 3,
                $XMax - 1,
                $Y - 6,
                $InnerBorderColor
            );
            imageline(
                $this->Picture,
                $XMin + 1,
                $Y - 4 - $TitleHeight - $CaptionHeight - $HorizontalMargin * 3,
                $XMax - 1,
                $Y - 4 - $TitleHeight - $CaptionHeight - $HorizontalMargin * 3,
                $InnerBorderColor
            );
        }

        /* Draw the separator line */
        if ($TitleMode == LABEL_TITLE_NOBACKGROUND && !$NoTitle) {
            $YPos = $Y - 7 - $CaptionHeight - $HorizontalMargin - $HorizontalMargin / 2;
            $XMargin = $VerticalMargin / 2;
            $this->drawLine(
                $XMin + $XMargin,
                $YPos + 1,
                $XMax - $XMargin,
                $YPos + 1,
                [
                    "R" => $GradientEndR,
                    "G" => $GradientEndG,
                    "B" => $GradientEndB,
                    "Alpha" => $BoxAlpha
                ]
            );
            $this->drawLine(
                $XMin + $XMargin,
                $YPos,
                $XMax - $XMargin,
                $YPos,
                [
                    "R" => $GradientStartR,
                    "G" => $GradientStartG,
                    "B" => $GradientStartB,
                    "Alpha" => $BoxAlpha
                ]
            );
        } elseif ($TitleMode == LABEL_TITLE_BACKGROUND) {
            $this->drawFilledRectangle(
                $XMin,
                $Y - 5 - $TitleHeight - $CaptionHeight - $HorizontalMargin * 3,
                $XMax,
                $Y - 5 - $TitleHeight - $CaptionHeight - $HorizontalMargin + $HorizontalMargin / 2,
                [
                    "R" => $TitleBackgroundR,
                    "G" => $TitleBackgroundG,
                    "B" => $TitleBackgroundB,
                    "Alpha" => $BoxAlpha
                ]
            );
            imageline(
                $this->Picture,
                $XMin + 1,
                $Y - 5 - $TitleHeight - $CaptionHeight - $HorizontalMargin + $HorizontalMargin / 2 + 1,
                $XMax - 1,
                $Y - 5 - $TitleHeight - $CaptionHeight - $HorizontalMargin + $HorizontalMargin / 2 + 1,
                $InnerBorderColor
            );
        }

        /* Write the description */
        if (!$NoTitle) {
            $this->drawText(
                $XMin + $VerticalMargin,
                $Y - 7 - $CaptionHeight - $HorizontalMargin * 2,
                $Title,
                [
                    "Align" => TEXT_ALIGN_BOTTOMLEFT,
                    "R" => $TitleR,
                    "G" => $TitleG,
                    "B" => $TitleB
                ]
            );
        }

        /* Write the value */
        $YPos = $Y - 5 - $HorizontalMargin;
        $XPos = $XMin + $VerticalMargin + $SerieBoxSize + $SerieBoxSpacing;
        foreach ($Captions as $Key => $Caption) {
            $CaptionTxt = $Caption["Caption"];
            $TxtPos = $this->getTextBox($XPos, $YPos, $FontName, $FontSize, 0, $CaptionTxt);
            $CaptionHeight = ($TxtPos[0]["Y"] - $TxtPos[2]["Y"]);

            /* Write the serie color if needed */
            if ($DrawSerieColor) {
                $BoxSettings = [
                    "R" => $Caption["Format"]["R"],
                    "G" => $Caption["Format"]["G"],
                    "B" => $Caption["Format"]["B"],
                    "Alpha" => $Caption["Format"]["Alpha"],
                    "BorderR" => 0,
                    "BorderG" => 0,
                    "BorderB" => 0
                ];
                $this->drawFilledRectangle(
                    $XMin + $VerticalMargin,
                    $YPos - $SerieBoxSize,
                    $XMin + $VerticalMargin + $SerieBoxSize,
                    $YPos,
                    $BoxSettings
                );
            }

            $this->drawText($XPos, $YPos, $CaptionTxt, ["Align" => TEXT_ALIGN_BOTTOMLEFT]);

            $YPos = $YPos - $CaptionHeight - $HorizontalMargin;
        }

        $this->Shadow = $RestoreShadow;
    }
733572
public function draw3DPie($X, $Y, array $Format = [])
    {
        /* Rendering layout */
        $Radius = isset($Format["Radius"]) ? $Format["Radius"] : 80;
        $Precision = isset($Format["Precision"]) ? $Format["Precision"] : 0;
        $SkewFactor = isset($Format["SkewFactor"]) ? $Format["SkewFactor"] : .5;
        $SliceHeight = isset($Format["SliceHeight"]) ? $Format["SliceHeight"] : 20;
        $DataGapAngle = isset($Format["DataGapAngle"]) ? $Format["DataGapAngle"] : 0;
        $DataGapRadius = isset($Format["DataGapRadius"]) ? $Format["DataGapRadius"] : 0;
        $SecondPass = isset($Format["SecondPass"]) ? $Format["SecondPass"] : true;
        $Border = isset($Format["Border"]) ? $Format["Border"] : false;
        $Shadow = isset($Format["Shadow"]) ? $Format["Shadow"] : false;
        $DrawLabels = isset($Format["DrawLabels"]) ? $Format["DrawLabels"] : false;
        $LabelStacked = isset($Format["LabelStacked"]) ? $Format["LabelStacked"] : false;
        $LabelColor = isset($Format["LabelColor"]) ? $Format["LabelColor"] : PIE_LABEL_COLOR_MANUAL;
        $LabelR = isset($Format["LabelR"]) ? $Format["LabelR"] : 0;
        $LabelG = isset($Format["LabelG"]) ? $Format["LabelG"] : 0;
        $LabelB = isset($Format["LabelB"]) ? $Format["LabelB"] : 0;
        $LabelAlpha = isset($Format["LabelAlpha"]) ? $Format["LabelAlpha"] : 100;
        $WriteValues = isset($Format["WriteValues"]) ? $Format["WriteValues"] : null; //PIE_VALUE_PERCENTAGE
        $ValuePosition = isset($Format["ValuePosition"]) ? $Format["ValuePosition"] : PIE_VALUE_INSIDE;
        $ValuePadding = isset($Format["ValuePadding"]) ? $Format["ValuePadding"] : 15;
        $ValueSuffix = isset($Format["ValueSuffix"]) ? $Format["ValueSuffix"] : "";
        $ValueR = isset($Format["ValueR"]) ? $Format["ValueR"] : 255;
        $ValueG = isset($Format["ValueG"]) ? $Format["ValueG"] : 255;
        $ValueB = isset($Format["ValueB"]) ? $Format["ValueB"] : 255;
        $ValueAlpha = isset($Format["ValueAlpha"]) ? $Format["ValueAlpha"] : 100;
        $RecordImageMap = isset($Format["RecordImageMap"]) ? $Format["RecordImageMap"] : false;

        /* Error correction for overlaying rounded corners */
        if ($SkewFactor < .5) {
            $SkewFactor = .5;
        }

        /* Data Processing */
        $Data = $this->pDataObject->getData();
        $Palette = $this->pDataObject->getPalette();

        /* Do we have an abscissa serie defined? */
        if ($Data["Abscissa"] == "") {
            return PIE_NO_ABSCISSA;
        }

        /* Try to find the data serie */
        $DataSerie = null;
        foreach ($Data["Series"] as $SerieName => $SerieData) {
            if ($SerieName != $Data["Abscissa"]) {
                $DataSerie = $SerieName;
            }
        }

        /* Do we have data to compute? */
        if (!$DataSerie) {
            return PIE_NO_DATASERIE;
        }

        /* Remove unused data */
        list($Data, $Palette) = $this->clean0Values($Data, $Palette, $DataSerie, $Data["Abscissa"]);

        /* Compute the pie sum */
        $SerieSum = $this->pDataObject->getSum($DataSerie);

        /* Do we have data to draw? */
        if ($SerieSum == 0) {
            return PIE_SUMISNULL;
        }

        /* Dump the real number of data to draw */
        $Values = [];
        foreach ($Data["Series"][$DataSerie]["Data"] as $Key => $Value) {
            if ($Value != 0) {
                $Values[] = $Value;
            }
        }

        /* Compute the wasted angular space between series */
        if (count($Values) == 1) {
            $WastedAngular = 0;
        } else {
            $WastedAngular = count($Values) * $DataGapAngle;
        }

        /* Compute the scale */
        $ScaleFactor = (360 - $WastedAngular) / $SerieSum;

        $RestoreShadow = $this->pChartObject->Shadow;
        if ($this->pChartObject->Shadow) {
            $this->pChartObject->Shadow = false;
        }

        /* Draw the polygon pie elements */
        $Step = 360 / (2 * PI * $Radius);
        $Offset = 360;
        $ID = count($Values) - 1;
        $Values = array_reverse($Values);
        $Slice = 0;
        $Slices = [];
        $SliceColors = [];
        $Visible = [];
        $SliceAngle = [];
        foreach ($Values as $Key => $Value) {
            if (!isset($Palette[$ID]["R"])) {
                $Color = $this->pChartObject->getRandomColor();
                $Palette[$ID] = $Color;
                $this->pDataObject->savePalette($ID, $Color);
            }
            $Settings = [
                "R" => $Palette[$ID]["R"],
                "G" => $Palette[$ID]["G"],
                "B" => $Palette[$ID]["B"],
                "Alpha" => $Palette[$ID]["Alpha"]
            ];

            $SliceColors[$Slice] = $Settings;

            $StartAngle = $Offset;
            $EndAngle = $Offset - ($Value * $ScaleFactor);
            if ($EndAngle < 0) {
                $EndAngle = 0;
            }

            if ($StartAngle > 180) {
                $Visible[$Slice]["Start"] = true;
            } else {
                $Visible[$Slice]["Start"] = true;
            }
            if ($EndAngle < 180) {
                $Visible[$Slice]["End"] = false;
            } else {
                $Visible[$Slice]["End"] = true;
            }

            if ($DataGapAngle == 0) {
                $X0 = $X;
                $Y0 = $Y;
            } else {
                $Angle = ($EndAngle - $Offset) / 2 + $Offset;
                $X0 = cos(($Angle - 90) * PI / 180) * $DataGapRadius + $X;
                $Y0 = sin(($Angle - 90) * PI / 180) * $DataGapRadius * $SkewFactor + $Y;
            }
            $Slices[$Slice][] = $X0;
            $Slices[$Slice][] = $Y0;
            $SliceAngle[$Slice][] = 0;

            for ($i = $Offset; $i >= $EndAngle; $i = $i - $Step) {
                $Xc = cos(($i - 90) * PI / 180) * $Radius + $X;
                $Yc = sin(($i - 90) * PI / 180) * $Radius * $SkewFactor + $Y;

                if (($SecondPass || $RestoreShadow) && ($i < 90)) {
                    $Yc++;
                }
                if (($SecondPass || $RestoreShadow) && ($i > 90 && $i < 180)) {
                    $Xc++;
                }
                if (($SecondPass || $RestoreShadow) && ($i > 180 && $i < 270)) {
                    $Xc++;
                }
                if (($SecondPass || $RestoreShadow) && ($i >= 270)) {
                    $Xc++;
                    $Yc++;
                }

                $Slices[$Slice][] = $Xc;
                $Slices[$Slice][] = $Yc;
                $SliceAngle[$Slice][] = $i;
            }

            $Offset = $i - $DataGapAngle;
            $ID--;
            $Slice++;
        }

        /* Draw the bottom shadow if needed */
        if ($RestoreShadow && ($this->pChartObject->ShadowX != 0 || $this->pChartObject->ShadowY != 0)) {
            foreach ($Slices as $SliceID => $Plots) {
                $ShadowPie = [];
                for ($i = 0; $i < count($Plots); $i = $i + 2) {
                    $ShadowPie[] = $Plots[$i] + $this->pChartObject->ShadowX;
                    $ShadowPie[] = $Plots[$i + 1] + $this->pChartObject->ShadowY;
                }

                $Settings = [
                    "R" => $this->pChartObject->ShadowR,
                    "G" => $this->pChartObject->ShadowG,
                    "B" => $this->pChartObject->ShadowB,
                    "Alpha" => $this->pChartObject->Shadowa,
                    "NoBorder" => true
                ];
                $this->pChartObject->drawPolygon($ShadowPie, $Settings);
            }

            $Step = 360 / (2 * PI * $Radius);
            $Offset = 360;
            foreach ($Values as $Key => $Value) {
                $EndAngle = $Offset - ($Value * $ScaleFactor);
                if ($EndAngle < 0) {
                    $EndAngle = 0;
                }

                for ($i = $Offset; $i >= $EndAngle; $i = $i - $Step) {
                    $Xc = cos(($i - 90) * PI / 180) * $Radius + $X + $this->pChartObject->ShadowX;
                    $Yc = sin(($i - 90) * PI / 180) * $Radius * $SkewFactor + $Y + $this->pChartObject->ShadowY;

                    $this->pChartObject->drawAntialiasPixel($Xc, $Yc, $Settings);
                }

                $Offset = $i - $DataGapAngle;
                $ID--;
            }
        }

        /* Draw the bottom pie splice */
        foreach ($Slices as $SliceID => $Plots) {
            $Settings = $SliceColors[$SliceID];
            $Settings["NoBorder"] = true;
            $this->pChartObject->drawPolygon($Plots, $Settings);

            if ($SecondPass) {
                $Settings = $SliceColors[$SliceID];
                if ($Border) {
                    $Settings["R"] += 30;
                    $Settings["G"] += 30;
                    $Settings["B"] += 30;
                }
                /* Empty error handling */
                if (isset($SliceAngle[$SliceID][1])) {
                    $Angle = $SliceAngle[$SliceID][1];
                    $Xc = cos(($Angle - 90) * PI / 180) * $Radius + $X;
                    $Yc = sin(($Angle - 90) * PI / 180) * $Radius * $SkewFactor + $Y;
                    $this->pChartObject->drawLine($Plots[0], $Plots[1], $Xc, $Yc, $Settings);

                    $Angle = $SliceAngle[$SliceID][count($SliceAngle[$SliceID]) - 1];
                    $Xc = cos(($Angle - 90) * PI / 180) * $Radius + $X;
                    $Yc = sin(($Angle - 90) * PI / 180) * $Radius * $SkewFactor + $Y;
                    $this->pChartObject->drawLine($Plots[0], $Plots[1], $Xc, $Yc, $Settings);
                }
            }
        }

        /* Draw the two vertical edges */
        $Slices = array_reverse($Slices);
        $SliceColors = array_reverse($SliceColors);
        foreach ($Slices as $SliceID => $Plots) {
            $Settings = $SliceColors[$SliceID];
            $Settings["R"] += 10;
            $Settings["G"] += 10;
            $Settings["B"] += 10;
            $Settings["NoBorder"] = true;
            /* Empty error handling */
            if ($Visible[$SliceID]["Start"] && isset($Plots[2])) {
                $this->pChartObject->drawLine(
                    $Plots[2],
                    $Plots[3],
                    $Plots[2],
                    $Plots[3] - $SliceHeight,
                    ["R" => $Settings["R"], "G" => $Settings["G"], "B" => $Settings["B"]]
                );
                $Border = [];
                $Border[] = $Plots[0];
                $Border[] = $Plots[1];
                $Border[] = $Plots[0];
                $Border[] = $Plots[1] - $SliceHeight;
                $Border[] = $Plots[2];
                $Border[] = $Plots[3] - $SliceHeight;
                $Border[] = $Plots[2];
                $Border[] = $Plots[3];
                $this->pChartObject->drawPolygon($Border, $Settings);
            }
        }

        $Slices = array_reverse($Slices);
        $SliceColors = array_reverse($SliceColors);
        foreach ($Slices as $SliceID => $Plots) {
            $Settings = $SliceColors[$SliceID];
            $Settings["R"] += 10;
            $Settings["G"] += 10;
            $Settings["B"] += 10;
            $Settings["NoBorder"] = true;
            if ($Visible[$SliceID]["End"]) {
                $this->pChartObject->drawLine(
                    $Plots[count($Plots) - 2],
                    $Plots[count($Plots) - 1],
                    $Plots[count($Plots) - 2],
                    $Plots[count($Plots) - 1] - $SliceHeight,
                    ["R" => $Settings["R"], "G" => $Settings["G"], "B" => $Settings["B"]]
                );

                $Border = [];
                $Border[] = $Plots[0];
                $Border[] = $Plots[1];
                $Border[] = $Plots[0];
                $Border[] = $Plots[1] - $SliceHeight;
                $Border[] = $Plots[count($Plots) - 2];
                $Border[] = $Plots[count($Plots) - 1] - $SliceHeight;
                $Border[] = $Plots[count($Plots) - 2];
                $Border[] = $Plots[count($Plots) - 1];
                $this->pChartObject->drawPolygon($Border, $Settings);
            }
        }

        /* Draw the rounded edges */
        foreach ($Slices as $SliceID => $Plots) {
            $Settings = $SliceColors[$SliceID];
            $Settings["R"] += 10;
            $Settings["G"] += 10;
            $Settings["B"] += 10;
            $Settings["NoBorder"] = true;

            for ($j = 2; $j < count($Plots) - 2; $j = $j + 2) {
                $Angle = $SliceAngle[$SliceID][$j / 2];
                if ($Angle < 270 && $Angle > 90) {
                    $Border = [];
                    $Border[] = $Plots[$j];
                    $Border[] = $Plots[$j + 1];
                    $Border[] = $Plots[$j + 2];
                    $Border[] = $Plots[$j + 3];
                    $Border[] = $Plots[$j + 2];
                    $Border[] = $Plots[$j + 3] - $SliceHeight;
                    $Border[] = $Plots[$j];
                    $Border[] = $Plots[$j + 1] - $SliceHeight;
                    $this->pChartObject->drawPolygon($Border, $Settings);
                }
            }

            if ($SecondPass) {
                $Settings = $SliceColors[$SliceID];
                if (count($Border)) {
                    $Settings["R"] += 30;
                    $Settings["G"] += 30;
                    $Settings["B"] += 30;
                }

                /* Empty error handling */
                if (isset($SliceAngle[$SliceID][1])) {
                    $Angle = $SliceAngle[$SliceID][1];
                    if ($Angle < 270 && $Angle > 90) {
                        $Xc = cos(($Angle - 90) * PI / 180) * $Radius + $X;
                        $Yc = sin(($Angle - 90) * PI / 180) * $Radius * $SkewFactor + $Y;
                        $this->pChartObject->drawLine($Xc, $Yc, $Xc, $Yc - $SliceHeight, $Settings);
                    }
                }

                $Angle = $SliceAngle[$SliceID][count($SliceAngle[$SliceID]) - 1];
                if ($Angle < 270 && $Angle > 90) {
                    $Xc = cos(($Angle - 90) * PI / 180) * $Radius + $X;
                    $Yc = sin(($Angle - 90) * PI / 180) * $Radius * $SkewFactor + $Y;
                    $this->pChartObject->drawLine($Xc, $Yc, $Xc, $Yc - $SliceHeight, $Settings);
                }

                if (isset($SliceAngle[$SliceID][1])
                    && $SliceAngle[$SliceID][1] > 270
                    && $SliceAngle[$SliceID][count($SliceAngle[$SliceID]) - 1] < 270
                ) {
                    $Xc = cos((270 - 90) * PI / 180) * $Radius + $X;
                    $Yc = sin((270 - 90) * PI / 180) * $Radius * $SkewFactor + $Y;
                    $this->pChartObject->drawLine($Xc, $Yc, $Xc, $Yc - $SliceHeight, $Settings);
                }

                if (isset($SliceAngle[$SliceID][1])
                    && $SliceAngle[$SliceID][1] > 90
                    && $SliceAngle[$SliceID][count($SliceAngle[$SliceID]) - 1] < 90
                ) {
                    $Xc = cos((0) * PI / 180) * $Radius + $X;
                    $Yc = sin((0) * PI / 180) * $Radius * $SkewFactor + $Y;
                    $this->pChartObject->drawLine($Xc, $Yc, $Xc, $Yc - $SliceHeight, $Settings);
                }
            }
        }

        /* Draw the top splice */
        foreach ($Slices as $SliceID => $Plots) {
            $Settings = $SliceColors[$SliceID];
            $Settings["R"] += 20;
            $Settings["G"] += 20;
            $Settings["B"] += 20;

            $Top = [];
            for ($j = 0; $j < count($Plots); $j = $j + 2) {
                $Top[] = $Plots[$j];
                $Top[] = $Plots[$j + 1] - $SliceHeight;
            }
            $this->pChartObject->drawPolygon($Top, $Settings);

            if ($RecordImageMap && !$Shadow) {
                $this->pChartObject->addToImageMap(
                    "POLY",
                    $this->arraySerialize($Top),
                    $this->pChartObject->toHTMLColor(
                        $Settings["R"],
                        $Settings["G"],
                        $Settings["B"]
                    ),
                    $Data["Series"][$Data["Abscissa"]]["Data"][count($Slices) - $SliceID - 1],
                    $Values[$SliceID]
                );
            }
        }


        /* Second pass to smooth the angles */
        if ($SecondPass) {
            $Step = 360 / (2 * PI * $Radius);
            $Offset = 360;
            $ID = count($Values) - 1;
            foreach ($Values as $Key => $Value) {
                $FirstPoint = true;
                if ($Shadow) {
                    $Settings = [
                        "R" => $this->pChartObject->ShadowR,
                        "G" => $this->pChartObject->ShadowG,
                        "B" => $this->pChartObject->ShadowB,
                        "Alpha" => $this->pChartObject->Shadowa
                    ];
                } else {
                    if ($Border) {
                        $Settings = [
                            "R" => $Palette[$ID]["R"] + 30,
                            "G" => $Palette[$ID]["G"] + 30,
                            "B" => $Palette[$ID]["B"] + 30,
                            "Alpha" => $Palette[$ID]["Alpha"]
                        ];
                    } else {
                        $Settings = [
                            "R" => $Palette[$ID]["R"],
                            "G" => $Palette[$ID]["G"],
                            "B" => $Palette[$ID]["B"],
                            "Alpha" => $Palette[$ID]["Alpha"]
                        ];
                    }
                }

                $EndAngle = $Offset - ($Value * $ScaleFactor);
                if ($EndAngle < 0) {
                    $EndAngle = 0;
                }

                if ($DataGapAngle == 0) {
                    $X0 = $X;
                    $Y0 = $Y - $SliceHeight;
                } else {
                    $Angle = ($EndAngle - $Offset) / 2 + $Offset;
                    $X0 = cos(($Angle - 90) * PI / 180) * $DataGapRadius + $X;
                    $Y0 = sin(($Angle - 90) * PI / 180) * $DataGapRadius * $SkewFactor + $Y - $SliceHeight;
                }
                $Plots[] = $X0;
                $Plots[] = $Y0;

                for ($i = $Offset; $i >= $EndAngle; $i = $i - $Step) {
                    $Xc = cos(($i - 90) * PI / 180) * $Radius + $X;
                    $Yc = sin(($i - 90) * PI / 180) * $Radius * $SkewFactor + $Y - $SliceHeight;

                    if ($FirstPoint) {
                        $this->pChartObject->drawLine($Xc, $Yc, $X0, $Y0, $Settings);
                        $FirstPoint = false;
                    }

                    $this->pChartObject->drawAntialiasPixel($Xc, $Yc, $Settings);
                    if ($i < 270 && $i > 90) {
                        $this->pChartObject->drawAntialiasPixel($Xc, $Yc + $SliceHeight, $Settings);
                    }
                }
                $this->pChartObject->drawLine($Xc, $Yc, $X0, $Y0, $Settings);

                $Offset = $i - $DataGapAngle;
                $ID--;
            }
        }

        if ($WriteValues != null) {
            $Step = 360 / (2 * PI * $Radius);
            $Offset = 360;
            $ID = count($Values) - 1;
            $Settings = [
                "Align" => TEXT_ALIGN_MIDDLEMIDDLE,
                "R" => $ValueR,
                "G" => $ValueG,
                "B" => $ValueB,
                "Alpha" => $ValueAlpha
            ];
            foreach ($Values as $Key => $Value) {
                $EndAngle = $Offset - ($Value * $ScaleFactor);
                if ($EndAngle < 0) {
                    $EndAngle = 0;
                }

                $Angle = ($EndAngle - $Offset) / 2 + $Offset;

                if ($ValuePosition == PIE_VALUE_OUTSIDE) {
                    $Xc = cos(($Angle - 90) * PI / 180) * ($Radius + $ValuePadding) + $X;
                    $Yc = sin(($Angle - 90) * PI / 180)
                        * (($Radius * $SkewFactor) + $ValuePadding)
                        + $Y - $SliceHeight
                    ;
                } else {
                    $Xc = cos(($Angle - 90) * PI / 180) * ($Radius) / 2 + $X;
                    $Yc = sin(($Angle - 90) * PI / 180) * ($Radius * $SkewFactor) / 2 + $Y - $SliceHeight;
                }

                if ($WriteValues == PIE_VALUE_PERCENTAGE) {
                    $Display = round((100 / $SerieSum) * $Value, $Precision) . "%";
                } elseif ($WriteValues == PIE_VALUE_NATURAL) {
                    $Display = $Value . $ValueSuffix;
                }

                $this->pChartObject->drawText($Xc, $Yc, $Display, $Settings);

                $Offset = $EndAngle - $DataGapAngle;
                $ID--;
            }
        }

        if ($DrawLabels) {
            $Step = 360 / (2 * PI * $Radius);
            $Offset = 360;
            $ID = count($Values) - 1;
            foreach ($Values as $Key => $Value) {
                if ($LabelColor == PIE_LABEL_COLOR_AUTO) {
                    $Settings = [
                        "FillR" => $Palette[$ID]["R"],
                        "FillG" => $Palette[$ID]["G"],
                        "FillB" => $Palette[$ID]["B"],
                        "Alpha" => $Palette[$ID]["Alpha"]
                    ];
                } else {
                    $Settings = [
                        "FillR" => $LabelR,
                        "FillG" => $LabelG,
                        "FillB" => $LabelB,
                        "Alpha" => $LabelAlpha
                    ];
                }

                $EndAngle = $Offset - ($Value * $ScaleFactor);
                if ($EndAngle < 0) {
                    $EndAngle = 0;
                }

                $Angle = ($EndAngle - $Offset) / 2 + $Offset;
                $Xc = cos(($Angle - 90) * PI / 180) * $Radius + $X;
                $Yc = sin(($Angle - 90) * PI / 180) * $Radius * $SkewFactor + $Y - $SliceHeight;

                if (isset($Data["Series"][$Data["Abscissa"]]["Data"][$ID])) {
                    $Label = $Data["Series"][$Data["Abscissa"]]["Data"][$ID];

                    if ($LabelStacked) {
                        $this->writePieLabel($Xc, $Yc, $Label, $Angle, $Settings, true, $X, $Y, $Radius, true);
                    } else {
                        $this->writePieLabel($Xc, $Yc, $Label, $Angle, $Settings, false);
                    }
                }

                $Offset = $EndAngle - $DataGapAngle;
                $ID--;
            }
        }

        if ($DrawLabels && $LabelStacked) {
            $this->writeShiftedLabels();
        }

        $this->pChartObject->Shadow = $RestoreShadow;

        return PIE_RENDERED;
    }
1079958
public function drawProgress($X, $Y, $Percent, array $Format = [])
    {
        if ($Percent > 100) {
            $Percent = 100;
        }
        if ($Percent < 0) {
            $Percent = 0;
        }

        $Width = isset($Format["Width"]) ? $Format["Width"] : 200;
        $Height = isset($Format["Height"]) ? $Format["Height"] : 20;
        $Orientation = isset($Format["Orientation"]) ? $Format["Orientation"] : ORIENTATION_HORIZONTAL;
        $ShowLabel = isset($Format["ShowLabel"]) ? $Format["ShowLabel"] : false;
        $LabelPos = isset($Format["LabelPos"]) ? $Format["LabelPos"] : LABEL_POS_INSIDE;
        $Margin = isset($Format["Margin"]) ? $Format["Margin"] : 10;
        $R = isset($Format["R"]) ? $Format["R"] : 130;
        $G = isset($Format["G"]) ? $Format["G"] : 130;
        $B = isset($Format["B"]) ? $Format["B"] : 130;
        $RFade = isset($Format["RFade"]) ? $Format["RFade"] : -1;
        $GFade = isset($Format["GFade"]) ? $Format["GFade"] : -1;
        $BFade = isset($Format["BFade"]) ? $Format["BFade"] : -1;
        $BorderR = isset($Format["BorderR"]) ? $Format["BorderR"] : $R;
        $BorderG = isset($Format["BorderG"]) ? $Format["BorderG"] : $G;
        $BorderB = isset($Format["BorderB"]) ? $Format["BorderB"] : $B;
        $BoxBorderR = isset($Format["BoxBorderR"]) ? $Format["BoxBorderR"] : 0;
        $BoxBorderG = isset($Format["BoxBorderG"]) ? $Format["BoxBorderG"] : 0;
        $BoxBorderB = isset($Format["BoxBorderB"]) ? $Format["BoxBorderB"] : 0;
        $BoxBackR = isset($Format["BoxBackR"]) ? $Format["BoxBackR"] : 255;
        $BoxBackG = isset($Format["BoxBackG"]) ? $Format["BoxBackG"] : 255;
        $BoxBackB = isset($Format["BoxBackB"]) ? $Format["BoxBackB"] : 255;
        $Surrounding = isset($Format["Surrounding"]) ? $Format["Surrounding"] : null;
        $BoxSurrounding = isset($Format["BoxSurrounding"]) ? $Format["BoxSurrounding"] : null;
        $NoAngle = isset($Format["NoAngle"]) ? $Format["NoAngle"] : false;

        if ($RFade != -1 && $GFade != -1 && $BFade != -1) {
            $RFade = (($RFade - $R) / 100) * $Percent + $R;
            $GFade = (($GFade - $G) / 100) * $Percent + $G;
            $BFade = (($BFade - $B) / 100) * $Percent + $B;
        }

        if ($Surrounding != null) {
            $BorderR = $R + $Surrounding;
            $BorderG = $G + $Surrounding;
            $BorderB = $B + $Surrounding;
        }
        if ($BoxSurrounding != null) {
            $BoxBorderR = $BoxBackR + $Surrounding;
            $BoxBorderG = $BoxBackG + $Surrounding;
            $BoxBorderB = $BoxBackB + $Surrounding;
        }

        if ($Orientation == ORIENTATION_VERTICAL) {
            $InnerHeight = (($Height - 2) / 100) * $Percent;
            $this->drawFilledRectangle(
                $X,
                $Y,
                $X + $Width,
                $Y - $Height,
                [
                    "R" => $BoxBackR,
                    "G" => $BoxBackG,
                    "B" => $BoxBackB,
                    "BorderR" => $BoxBorderR,
                    "BorderG" => $BoxBorderG,
                    "BorderB" => $BoxBorderB,
                    "NoAngle" => $NoAngle
                ]
            );

            $RestoreShadow = $this->Shadow;
            $this->Shadow = false;
            if ($RFade != -1 && $GFade != -1 && $BFade != -1) {
                $GradientOptions = [
                    "StartR" => $RFade,
                    "StartG" => $GFade,
                    "StartB" => $BFade,
                    "EndR" => $R,
                    "EndG" => $G,
                    "EndB" => $B
                ];
                $this->drawGradientArea(
                    $X + 1,
                    $Y - 1,
                    $X + $Width - 1,
                    $Y - $InnerHeight,
                    DIRECTION_VERTICAL,
                    $GradientOptions
                );

                if ($Surrounding) {
                    $this->drawRectangle(
                        $X + 1,
                        $Y - 1,
                        $X + $Width - 1,
                        $Y - $InnerHeight,
                        ["R" => 255, "G" => 255, "B" => 255, "Alpha" => $Surrounding]
                    );
                }
            } else {
                $this->drawFilledRectangle(
                    $X + 1,
                    $Y - 1,
                    $X + $Width - 1,
                    $Y - $InnerHeight,
                    [
                        "R" => $R,
                        "G" => $G,
                        "B" => $B,
                        "BorderR" => $BorderR,
                        "BorderG" => $BorderG,
                        "BorderB" => $BorderB
                    ]
                );
            }
            $this->Shadow = $RestoreShadow;

            if ($ShowLabel && $LabelPos == LABEL_POS_BOTTOM) {
                $this->drawText(
                    $X + ($Width / 2),
                    $Y + $Margin,
                    $Percent . "%",
                    ["Align" => TEXT_ALIGN_TOPMIDDLE]
                );
            }
            if ($ShowLabel && $LabelPos == LABEL_POS_TOP) {
                $this->drawText(
                    $X + ($Width / 2),
                    $Y - $Height - $Margin,
                    $Percent . "%",
                    ["Align" => TEXT_ALIGN_BOTTOMMIDDLE]
                );
            }
            if ($ShowLabel && $LabelPos == LABEL_POS_INSIDE) {
                $this->drawText(
                    $X + ($Width / 2),
                    $Y - $InnerHeight - $Margin,
                    $Percent . "%",
                    ["Align" => TEXT_ALIGN_MIDDLELEFT, "Angle" => 90]
                );
            }
            if ($ShowLabel && $LabelPos == LABEL_POS_CENTER) {
                $this->drawText(
                    $X + ($Width / 2),
                    $Y - ($Height / 2),
                    $Percent . "%",
                    ["Align" => TEXT_ALIGN_MIDDLEMIDDLE, "Angle" => 90]
                );
            }
        } else {
            if ($Percent == 100) {
                $InnerWidth = $Width - 1;
            } else {
                $InnerWidth = (($Width - 2) / 100) * $Percent;
            }
            $this->drawFilledRectangle(
                $X,
                $Y,
                $X + $Width,
                $Y + $Height,
                [
                    "R" => $BoxBackR,
                    "G" => $BoxBackG,
                    "B" => $BoxBackB,
                    "BorderR" => $BoxBorderR,
                    "BorderG" => $BoxBorderG,
                    "BorderB" => $BoxBorderB,
                    "NoAngle" => $NoAngle
                ]
            );

            $RestoreShadow = $this->Shadow;
            $this->Shadow = false;
            if ($RFade != -1 && $GFade != -1 && $BFade != -1) {
                $GradientOptions = [
                    "StartR" => $R,
                    "StartG" => $G,
                    "StartB" => $B,
                    "EndR" => $RFade,
                    "EndG" => $GFade,
                    "EndB" => $BFade
                ];
                $this->drawGradientArea(
                    $X + 1,
                    $Y + 1,
                    $X + $InnerWidth,
                    $Y + $Height - 1,
                    DIRECTION_HORIZONTAL,
                    $GradientOptions
                );

                if ($Surrounding) {
                    $this->drawRectangle(
                        $X + 1,
                        $Y + 1,
                        $X + $InnerWidth,
                        $Y + $Height - 1,
                        ["R" => 255, "G" => 255, "B" => 255, "Alpha" => $Surrounding]
                    );
                }
            } else {
                $this->drawFilledRectangle(
                    $X + 1,
                    $Y + 1,
                    $X + $InnerWidth,
                    $Y + $Height - 1,
                    [
                        "R" => $R,
                        "G" => $G,
                        "B" => $B,
                        "BorderR" => $BorderR, "BorderG" => $BorderG, "BorderB" => $BorderB
                    ]
                );
            }
            $this->Shadow = $RestoreShadow;

            if ($ShowLabel && $LabelPos == LABEL_POS_LEFT) {
                $this->drawText(
                    $X - $Margin,
                    $Y + ($Height / 2),
                    $Percent . "%",
                    ["Align" => TEXT_ALIGN_MIDDLERIGHT]
                );
            }
            if ($ShowLabel && $LabelPos == LABEL_POS_RIGHT) {
                $this->drawText(
                    $X + $Width + $Margin,
                    $Y + ($Height / 2),
                    $Percent . "%",
                    ["Align" => TEXT_ALIGN_MIDDLELEFT]
                );
            }
            if ($ShowLabel && $LabelPos == LABEL_POS_CENTER) {
                $this->drawText(
                    $X + ($Width / 2),
                    $Y + ($Height / 2),
                    $Percent . "%",
                    ["Align" => TEXT_ALIGN_MIDDLEMIDDLE]
                );
            }
            if ($ShowLabel && $LabelPos == LABEL_POS_INSIDE) {
                $this->drawText(
                    $X + $InnerWidth + $Margin,
                    $Y + ($Height / 2),
                    $Percent . "%",
                    ["Align" => TEXT_ALIGN_MIDDLELEFT]
                );
            }
        }
    }
550213
public function export($format = FilledFormExportFormat::JSON)
    {
        if (! $format instanceof FilledFormExportFormat) {
            $format = new FilledFormExportFormat($format);
        }

        return static::query($this->client, [$this->filled_form_id, self::EXPORT], ['format' => $format->getValue()]);
    }
926752
public function drawSplineChart(array $Format = [])
    {
        $BreakVoid = isset($Format["BreakVoid"]) ? $Format["BreakVoid"] : true;
        $VoidTicks = isset($Format["VoidTicks"]) ? $Format["VoidTicks"] : 4;
        $BreakR = isset($Format["BreakR"]) ? $Format["BreakR"] : null; // 234
        $BreakG = isset($Format["BreakG"]) ? $Format["BreakG"] : null; // 55
        $BreakB = isset($Format["BreakB"]) ? $Format["BreakB"] : null; // 26
        $DisplayValues = isset($Format["DisplayValues"]) ? $Format["DisplayValues"] : false;
        $DisplayOffset = isset($Format["DisplayOffset"]) ? $Format["DisplayOffset"] : 2;
        $DisplayColor = isset($Format["DisplayColor"]) ? $Format["DisplayColor"] : DISPLAY_MANUAL;
        $DisplayR = isset($Format["DisplayR"]) ? $Format["DisplayR"] : 0;
        $DisplayG = isset($Format["DisplayG"]) ? $Format["DisplayG"] : 0;
        $DisplayB = isset($Format["DisplayB"]) ? $Format["DisplayB"] : 0;
        $RecordImageMap = isset($Format["RecordImageMap"]) ? $Format["RecordImageMap"] : false;
        $ImageMapPlotSize = isset($Format["ImageMapPlotSize"]) ? $Format["ImageMapPlotSize"] : 5;

        $this->LastChartLayout = CHART_LAST_LAYOUT_REGULAR;

        $Data = $this->DataSet->getData();
        list($XMargin, $XDivs) = $this->scaleGetXSettings();
        foreach ($Data["Series"] as $SerieName => $Serie) {
            if ($Serie["isDrawable"] == true && $SerieName != $Data["Abscissa"]) {
                $R = $Serie["Color"]["R"];
                $G = $Serie["Color"]["G"];
                $B = $Serie["Color"]["B"];
                $Alpha = $Serie["Color"]["Alpha"];
                $Ticks = $Serie["Ticks"];
                $Weight = $Serie["Weight"];

                if ($BreakR == null) {
                    $BreakSettings = [
                        "R" => $R,
                        "G" => $G,
                        "B" => $B,
                        "Alpha" => $Alpha,
                        "Ticks" => $VoidTicks
                    ];
                } else {
                    $BreakSettings = [
                        "R" => $BreakR,
                        "G" => $BreakG,
                        "B" => $BreakB,
                        "Alpha" => $Alpha,
                        "Ticks" => $VoidTicks,
                        "Weight" => $Weight
                    ];
                }
                if ($DisplayColor == DISPLAY_AUTO) {
                    $DisplayR = $R;
                    $DisplayG = $G;
                    $DisplayB = $B;
                }

                $AxisID = $Serie["Axis"];
                $Mode = $Data["Axis"][$AxisID]["Display"];
                $Format = $Data["Axis"][$AxisID]["Format"];
                $Unit = $Data["Axis"][$AxisID]["Unit"];

                if (isset($Serie["Description"])) {
                    $SerieDescription = $Serie["Description"];
                } else {
                    $SerieDescription = $SerieName;
                }

                $PosArray = $this->scaleComputeY(
                    $Serie["Data"],
                    ["AxisID" => $Serie["Axis"]]
                );

                $this->DataSet->Data["Series"][$SerieName]["XOffset"] = 0;

                if ($Data["Orientation"] == SCALE_POS_LEFTRIGHT) {
                    if ($XDivs == 0) {
                        $XStep = ($this->GraphAreaX2 - $this->GraphAreaX1) / 4;
                    } else {
                        $XStep = ($this->GraphAreaX2 - $this->GraphAreaX1 - $XMargin * 2) / $XDivs;
                    }
                    $X = $this->GraphAreaX1 + $XMargin;
                    $WayPoints = [];
                    $Force = $XStep / 5;

                    if (!is_array($PosArray)) {
                        $Value = $PosArray;
                        $PosArray = [];
                        $PosArray[0] = $Value;
                    }
                    $LastGoodY = null;
                    $LastGoodX = null;
                    $LastX = 1;
                    $LastY = 1;
                    foreach ($PosArray as $Key => $Y) {
                        if ($DisplayValues) {
                            $this->drawText(
                                $X,
                                $Y - $DisplayOffset,
                                $this->scaleFormat($Serie["Data"][$Key], $Mode, $Format, $Unit),
                                [
                                    "R" => $DisplayR,
                                    "G" => $DisplayG,
                                    "B" => $DisplayB,
                                    "Align" => TEXT_ALIGN_BOTTOMMIDDLE
                                ]
                            );
                        }
                        if ($RecordImageMap && $Y != VOID) {
                            $this->addToImageMap(
                                "CIRCLE",
                                floor($X) . "," . floor($Y) . "," . $ImageMapPlotSize,
                                $this->toHTMLColor($R, $G, $B),
                                $SerieDescription,
                                $this->scaleFormat($Serie["Data"][$Key], $Mode, $Format, $Unit)
                            );
                        }

                        if ($Y == VOID && $LastY != null) {
                            $this->drawSpline(
                                $WayPoints,
                                [
                                    "Force" => $Force,
                                    "R" => $R,
                                    "G" => $G,
                                    "B" => $B,
                                    "Alpha" => $Alpha,
                                    "Ticks" => $Ticks,
                                    "Weight" => $Weight
                                ]
                            );
                            $WayPoints = [];
                        }

                        if ($Y != VOID && $LastY == null && $LastGoodY != null && !$BreakVoid) {
                            $this->drawLine($LastGoodX, $LastGoodY, $X, $Y, $BreakSettings);
                        }

                        if ($Y != VOID) {
                            $WayPoints[] = [$X, $Y];
                        }
                        if ($Y != VOID) {
                            $LastGoodY = $Y;
                            $LastGoodX = $X;
                        }
                        if ($Y == VOID) {
                            $Y = null;
                        }

                        $LastX = $X;
                        $LastY = $Y;
                        $X = $X + $XStep;
                    }
                    $this->drawSpline(
                        $WayPoints,
                        [
                            "Force" => $Force,
                            "R" => $R,
                            "G" => $G,
                            "B" => $B,
                            "Alpha" => $Alpha,
                            "Ticks" => $Ticks,
                            "Weight" => $Weight
                        ]
                    );
                } else {
                    if ($XDivs == 0) {
                        $YStep = ($this->GraphAreaY2 - $this->GraphAreaY1) / 4;
                    } else {
                        $YStep = ($this->GraphAreaY2 - $this->GraphAreaY1 - $XMargin * 2) / $XDivs;
                    }
                    $Y = $this->GraphAreaY1 + $XMargin;
                    $WayPoints = [];
                    $Force = $YStep / 5;

                    if (!is_array($PosArray)) {
                        $Value = $PosArray;
                        $PosArray = [];
                        $PosArray[0] = $Value;
                    }
                    $LastGoodY = null;
                    $LastGoodX = null;
                    $LastX = 1;
                    $LastY = 1;
                    foreach ($PosArray as $Key => $X) {
                        if ($DisplayValues) {
                            $this->drawText(
                                $X + $DisplayOffset,
                                $Y,
                                $this->scaleFormat(
                                    $Serie["Data"][$Key],
                                    $Mode,
                                    $Format,
                                    $Unit
                                ),
                                [
                                    "Angle" => 270,
                                    "R" => $DisplayR,
                                    "G" => $DisplayG,
                                    "B" => $DisplayB,
                                    "Align" => TEXT_ALIGN_BOTTOMMIDDLE
                                ]
                            );
                        }
                        if ($RecordImageMap && $X != VOID) {
                            $this->addToImageMap(
                                "CIRCLE",
                                floor($X) . "," . floor($Y) . "," . $ImageMapPlotSize,
                                $this->toHTMLColor($R, $G, $B),
                                $SerieDescription,
                                $this->scaleFormat($Serie["Data"][$Key], $Mode, $Format, $Unit)
                            );
                        }

                        if ($X == VOID && $LastX != null) {
                            $this->drawSpline(
                                $WayPoints,
                                [
                                    "Force" => $Force,
                                    "R" => $R,
                                    "G" => $G,
                                    "B" => $B,
                                    "Alpha" => $Alpha,
                                    "Ticks" => $Ticks,
                                    "Weight" => $Weight
                                ]
                            );
                            $WayPoints = [];
                        }

                        if ($X != VOID && $LastX == null && $LastGoodX != null && !$BreakVoid) {
                            $this->drawLine($LastGoodX, $LastGoodY, $X, $Y, $BreakSettings);
                        }

                        if ($X != VOID) {
                            $WayPoints[] = [$X, $Y];
                        }
                        if ($X != VOID) {
                            $LastGoodX = $X;
                            $LastGoodY = $Y;
                        }
                        if ($X == VOID) {
                            $X = null;
                        }

                        $LastX = $X;
                        $LastY = $Y;
                        $Y = $Y + $YStep;
                    }
                    $this->drawSpline(
                        $WayPoints,
                        [
                            "Force" => $Force,
                            "R" => $R,
                            "G" => $G,
                            "B" => $B,
                            "Alpha" => $Alpha,
                            "Ticks" => $Ticks,
                            "Weight" => $Weight
                        ]
                    );
                }
            }
        }
    }
205736
public static function setStringFormat(string $format)
    {
        switch ($format) {
            case 'raw':
                self::$format = 'raw';
                break;
            case 'basic':
                self::$format = 'basic';
                break;
            case 'full':
            default:
                self::$format = 'full';
                break;
        }
    }
729063
function printFormatted(string $format): int {
		$args = func_get_args ();
		$s = call_user_func_array ( 'sprintf', $args );
		return $this->write ( $s );
	}
453957
public function drawRoundedFilledRectangle($X1, $Y1, $X2, $Y2, $Radius, array $Format = [])
    {
        $R = isset($Format["R"]) ? $Format["R"] : 0;
        $G = isset($Format["G"]) ? $Format["G"] : 0;
        $B = isset($Format["B"]) ? $Format["B"] : 0;
        $BorderR = isset($Format["BorderR"]) ? $Format["BorderR"] : -1;
        $BorderG = isset($Format["BorderG"]) ? $Format["BorderG"] : -1;
        $BorderB = isset($Format["BorderB"]) ? $Format["BorderB"] : -1;
        $Alpha = isset($Format["Alpha"]) ? $Format["Alpha"] : 100;
        $Surrounding = isset($Format["Surrounding"]) ? $Format["Surrounding"] : null;

        /* Temporary fix for AA issue */
        $Y1 = floor($Y1);
        $Y2 = floor($Y2);
        $X1 = floor($X1);
        $X2 = floor($X2);

        if ($Surrounding != null) {
            $BorderR = $R + $Surrounding;
            $BorderG = $G + $Surrounding;
            $BorderB = $B + $Surrounding;
        }
        if ($BorderR == -1) {
            $BorderR = $R;
            $BorderG = $G;
            $BorderB = $B;
        }

        list($X1, $Y1, $X2, $Y2) = $this->fixBoxCoordinates($X1, $Y1, $X2, $Y2);

        if ($X2 - $X1 < $Radius * 2) {
            $Radius = floor((($X2 - $X1)) / 4);
        }
        if ($Y2 - $Y1 < $Radius * 2) {
            $Radius = floor((($Y2 - $Y1)) / 4);
        }

        $RestoreShadow = $this->Shadow;
        if ($this->Shadow && $this->ShadowX != 0 && $this->ShadowY != 0) {
            $this->Shadow = false;
            $this->drawRoundedFilledRectangle(
                $X1 + $this->ShadowX,
                $Y1 + $this->ShadowY,
                $X2 + $this->ShadowX,
                $Y2 + $this->ShadowY,
                $Radius,
                [
                    "R" => $this->ShadowR,
                    "G" => $this->ShadowG,
                    "B" => $this->ShadowB,
                    "Alpha" => $this->Shadowa
                ]
            );
        }

        $Color = ["R" => $R, "G" => $G, "B" => $B, "Alpha" => $Alpha, "NoBorder" => true];

        if ($Radius <= 0) {
            $this->drawFilledRectangle($X1, $Y1, $X2, $Y2, $Color);
            return 0;
        }

        $YTop = $Y1 + $Radius;
        $YBottom = $Y2 - $Radius;

        $Step = 360 / (2 * PI * $Radius);
        $Positions = [];
        $Radius--;
        $MinY = null;
        $MaxY = null;
        for ($i = 0; $i <= 90; $i = $i + $Step) {
            $Xp1 = cos(($i + 180) * PI / 180) * $Radius + $X1 + $Radius;
            $Xp2 = cos(((90 - $i) + 270) * PI / 180) * $Radius + $X2 - $Radius;
            $Yp = floor(sin(($i + 180) * PI / 180) * $Radius + $YTop);
            if (null === $MinY || $Yp > $MinY) {
                $MinY = $Yp;
            }

            if ($Xp1 <= floor($X1)) {
                $Xp1++;
            }
            if ($Xp2 >= floor($X2)) {
                $Xp2--;
            }
            $Xp1++;

            if (!isset($Positions[$Yp])) {
                $Positions[$Yp]["X1"] = $Xp1;
                $Positions[$Yp]["X2"] = $Xp2;
            } else {
                $Positions[$Yp]["X1"] = ($Positions[$Yp]["X1"] + $Xp1) / 2;
                $Positions[$Yp]["X2"] = ($Positions[$Yp]["X2"] + $Xp2) / 2;
            }

            $Xp1 = cos(($i + 90) * PI / 180) * $Radius + $X1 + $Radius;
            $Xp2 = cos((90 - $i) * PI / 180) * $Radius + $X2 - $Radius;
            $Yp = floor(sin(($i + 90) * PI / 180) * $Radius + $YBottom);
            if (null === $MaxY || $Yp < $MaxY) {
                $MaxY = $Yp;
            }

            if ($Xp1 <= floor($X1)) {
                $Xp1++;
            }
            if ($Xp2 >= floor($X2)) {
                $Xp2--;
            }
            $Xp1++;

            if (!isset($Positions[$Yp])) {
                $Positions[$Yp]["X1"] = $Xp1;
                $Positions[$Yp]["X2"] = $Xp2;
            } else {
                $Positions[$Yp]["X1"] = ($Positions[$Yp]["X1"] + $Xp1) / 2;
                $Positions[$Yp]["X2"] = ($Positions[$Yp]["X2"] + $Xp2) / 2;
            }
        }

        $ManualColor = $this->allocateColor($this->Picture, $R, $G, $B, $Alpha);
        foreach ($Positions as $Yp => $Bounds) {
            $X1 = $Bounds["X1"];
            $X1Dec = $this->getFirstDecimal($X1);
            if ($X1Dec != 0) {
                $X1 = floor($X1) + 1;
            }
            $X2 = $Bounds["X2"];
            $X2Dec = $this->getFirstDecimal($X2);
            if ($X2Dec != 0) {
                $X2 = floor($X2) - 1;
            }
            imageline($this->Picture, $X1, $Yp, $X2, $Yp, $ManualColor);
        }
        $this->drawFilledRectangle($X1, $MinY + 1, floor($X2), $MaxY - 1, $Color);

        $Radius++;
        $this->drawRoundedRectangle(
            $X1,
            $Y1,
            $X2 + 1,
            $Y2 - 1,
            $Radius,
            ["R" => $BorderR, "G" => $BorderG, "B" => $BorderB, "Alpha" => $Alpha]
        );

        $this->Shadow = $RestoreShadow;
    }
1322307
public function setFormat($format)
    {
        if (!is_null($format)) {
            $this->format = $format;
            $this->useFormat(false);
        }

        return $this;
    }
1306376
public function drawRectangle($X1, $Y1, $X2, $Y2, array $Format = [])
    {
        $R = isset($Format["R"]) ? $Format["R"] : 0;
        $G = isset($Format["G"]) ? $Format["G"] : 0;
        $B = isset($Format["B"]) ? $Format["B"] : 0;
        $Alpha = isset($Format["Alpha"]) ? $Format["Alpha"] : 100;
        $Ticks = isset($Format["Ticks"]) ? $Format["Ticks"] : null;
        $NoAngle = isset($Format["NoAngle"]) ? $Format["NoAngle"] : false;

        if ($X1 > $X2) {
            list($X1, $X2) = [$X2, $X1];
        }
        if ($Y1 > $Y2) {
            list($Y1, $Y2) = [$Y2, $Y1];
        }

        if ($this->Antialias) {
            if ($NoAngle) {
                $this->drawLine(
                    $X1 + 1,
                    $Y1,
                    $X2 - 1,
                    $Y1,
                    ["R" => $R, "G" => $G, "B" => $B, "Alpha" => $Alpha, "Ticks" => $Ticks]
                );
                $this->drawLine(
                    $X2,
                    $Y1 + 1,
                    $X2,
                    $Y2 - 1,
                    ["R" => $R, "G" => $G, "B" => $B, "Alpha" => $Alpha, "Ticks" => $Ticks]
                );
                $this->drawLine(
                    $X2 - 1,
                    $Y2,
                    $X1 + 1,
                    $Y2,
                    ["R" => $R, "G" => $G, "B" => $B, "Alpha" => $Alpha, "Ticks" => $Ticks]
                );
                $this->drawLine(
                    $X1,
                    $Y1 + 1,
                    $X1,
                    $Y2 - 1,
                    ["R" => $R, "G" => $G, "B" => $B, "Alpha" => $Alpha, "Ticks" => $Ticks]
                );
            } else {
                $this->drawLine(
                    $X1 + 1,
                    $Y1,
                    $X2 - 1,
                    $Y1,
                    ["R" => $R, "G" => $G, "B" => $B, "Alpha" => $Alpha, "Ticks" => $Ticks]
                );
                $this->drawLine(
                    $X2,
                    $Y1,
                    $X2,
                    $Y2,
                    ["R" => $R, "G" => $G, "B" => $B, "Alpha" => $Alpha, "Ticks" => $Ticks]
                );
                $this->drawLine(
                    $X2 - 1,
                    $Y2,
                    $X1 + 1,
                    $Y2,
                    ["R" => $R, "G" => $G, "B" => $B, "Alpha" => $Alpha, "Ticks" => $Ticks]
                );
                $this->drawLine(
                    $X1,
                    $Y1,
                    $X1,
                    $Y2,
                    ["R" => $R, "G" => $G, "B" => $B, "Alpha" => $Alpha, "Ticks" => $Ticks]
                );
            }
        } else {
            $Color = $this->allocateColor($this->Picture, $R, $G, $B, $Alpha);
            imagerectangle($this->Picture, $X1, $Y1, $X2, $Y2, $Color);
        }
    }
685346
public function drawRectangleMarker($X, $Y, array $Format = [])
    {
        $Size = isset($Format["Size"]) ? $Format["Size"] : 4;

        $HalfSize = floor($Size / 2);
        $this->drawFilledRectangle($X - $HalfSize, $Y - $HalfSize, $X + $HalfSize, $Y + $HalfSize, $Format);
    }
115278
public function drawStockChart(array $Format = [])
    {
        $SerieOpen = isset($Format["SerieOpen"]) ? $Format["SerieOpen"] : "Open";
        $SerieClose = isset($Format["SerieClose"]) ? $Format["SerieClose"] : "Close";
        $SerieMin = isset($Format["SerieMin"]) ? $Format["SerieMin"] : "Min";
        $SerieMax = isset($Format["SerieMax"]) ? $Format["SerieMax"] : "Max";
        $SerieMedian = isset($Format["SerieMedian"]) ? $Format["SerieMedian"] : null;
        $LineWidth = isset($Format["LineWidth"]) ? $Format["LineWidth"] : 1;
        $LineR = isset($Format["LineR"]) ? $Format["LineR"] : 0;
        $LineG = isset($Format["LineG"]) ? $Format["LineG"] : 0;
        $LineB = isset($Format["LineB"]) ? $Format["LineB"] : 0;
        $LineAlpha = isset($Format["LineAlpha"]) ? $Format["LineAlpha"] : 100;
        $ExtremityWidth = isset($Format["ExtremityWidth"]) ? $Format["ExtremityWidth"] : 1;
        $ExtremityLength = isset($Format["ExtremityLength"]) ? $Format["ExtremityLength"] : 3;
        $ExtremityR = isset($Format["ExtremityR"]) ? $Format["ExtremityR"] : 0;
        $ExtremityG = isset($Format["ExtremityG"]) ? $Format["ExtremityG"] : 0;
        $ExtremityB = isset($Format["ExtremityB"]) ? $Format["ExtremityB"] : 0;
        $ExtremityAlpha = isset($Format["ExtremityAlpha"]) ? $Format["ExtremityAlpha"] : 100;
        $BoxWidth = isset($Format["BoxWidth"]) ? $Format["BoxWidth"] : 8;
        $BoxUpR = isset($Format["BoxUpR"]) ? $Format["BoxUpR"] : 188;
        $BoxUpG = isset($Format["BoxUpG"]) ? $Format["BoxUpG"] : 224;
        $BoxUpB = isset($Format["BoxUpB"]) ? $Format["BoxUpB"] : 46;
        $BoxUpAlpha = isset($Format["BoxUpAlpha"]) ? $Format["BoxUpAlpha"] : 100;
        $BoxUpSurrounding = isset($Format["BoxUpSurrounding"]) ? $Format["BoxUpSurrounding"] : null;
        $BoxUpBorderR = isset($Format["BoxUpBorderR"]) ? $Format["BoxUpBorderR"] : $BoxUpR - 20;
        $BoxUpBorderG = isset($Format["BoxUpBorderG"]) ? $Format["BoxUpBorderG"] : $BoxUpG - 20;
        $BoxUpBorderB = isset($Format["BoxUpBorderB"]) ? $Format["BoxUpBorderB"] : $BoxUpB - 20;
        $BoxUpBorderAlpha = isset($Format["BoxUpBorderAlpha"]) ? $Format["BoxUpBorderAlpha"] : 100;
        $BoxDownR = isset($Format["BoxDownR"]) ? $Format["BoxDownR"] : 224;
        $BoxDownG = isset($Format["BoxDownG"]) ? $Format["BoxDownG"] : 100;
        $BoxDownB = isset($Format["BoxDownB"]) ? $Format["BoxDownB"] : 46;
        $BoxDownAlpha = isset($Format["BoxDownAlpha"]) ? $Format["BoxDownAlpha"] : 100;
        $BoxDownSurrounding = isset($Format["BoxDownSurrounding"]) ? $Format["BoxDownSurrounding"] : null;
        $BoxDownBorderR = isset($Format["BoxDownBorderR"]) ? $Format["BoxDownBorderR"] : $BoxDownR - 20;
        $BoxDownBorderG = isset($Format["BoxDownBorderG"]) ? $Format["BoxDownBorderG"] : $BoxDownG - 20;
        $BoxDownBorderB = isset($Format["BoxDownBorderB"]) ? $Format["BoxDownBorderB"] : $BoxDownB - 20;
        $BoxDownBorderAlpha = isset($Format["BoxDownBorderAlpha"]) ? $Format["BoxDownBorderAlpha"] : 100;
        $ShadowOnBoxesOnly = isset($Format["ShadowOnBoxesOnly"]) ? $Format["ShadowOnBoxesOnly"] : true;
        $MedianR = isset($Format["MedianR"]) ? $Format["MedianR"] : 255;
        $MedianG = isset($Format["MedianG"]) ? $Format["MedianG"] : 0;
        $MedianB = isset($Format["MedianB"]) ? $Format["MedianB"] : 0;
        $MedianAlpha = isset($Format["MedianAlpha"]) ? $Format["MedianAlpha"] : 100;
        $RecordImageMap = isset($Format["RecordImageMap"]) ? $Format["RecordImageMap"] : false;
        $ImageMapTitle = isset($Format["ImageMapTitle"]) ? $Format["ImageMapTitle"] : "Stock Chart";

        /* Data Processing */
        if ($BoxUpSurrounding != null) {
            $BoxUpBorderR = $BoxUpR + $BoxUpSurrounding;
            $BoxUpBorderG = $BoxUpG + $BoxUpSurrounding;
            $BoxUpBorderB = $BoxUpB + $BoxUpSurrounding;
        }
        if ($BoxDownSurrounding != null) {
            $BoxDownBorderR = $BoxDownR + $BoxDownSurrounding;
            $BoxDownBorderG = $BoxDownG + $BoxDownSurrounding;
            $BoxDownBorderB = $BoxDownB + $BoxDownSurrounding;
        }

        if ($LineWidth != 1) {
            $LineOffset = $LineWidth / 2;
        }
        $BoxOffset = $BoxWidth / 2;

        $Data = $this->pChartObject->DataSet->getData();
        list($XMargin, $XDivs) = $this->pChartObject->scaleGetXSettings();

        if (!isset($Data["Series"][$SerieOpen])
            || !isset($Data["Series"][$SerieClose])
            || !isset($Data["Series"][$SerieMin])
            || !isset($Data["Series"][$SerieMax])
        ) {
            return STOCK_MISSING_SERIE;
        }
        $Plots = [];
        foreach ($Data["Series"][$SerieOpen]["Data"] as $Key => $Value) {
            $Point = [];
            if (isset($Data["Series"][$SerieClose]["Data"][$Key])
                || isset($Data["Series"][$SerieMin]["Data"][$Key])
                || isset($Data["Series"][$SerieMax]["Data"][$Key])
            ) {
                $Point = [
                    $Value,
                    $Data["Series"][$SerieClose]["Data"][$Key],
                    $Data["Series"][$SerieMin]["Data"][$Key],
                    $Data["Series"][$SerieMax]["Data"][$Key]
                ];
            }
            if ($SerieMedian != null && isset($Data["Series"][$SerieMedian]["Data"][$Key])) {
                $Point[] = $Data["Series"][$SerieMedian]["Data"][$Key];
            }
            $Plots[] = $Point;
        }

        $AxisID = $Data["Series"][$SerieOpen]["Axis"];
        $Format = $Data["Axis"][$AxisID]["Format"];

        $YZero = $this->pChartObject->scaleComputeY(0, ["AxisID" => $AxisID]);
        $XStep = ($this->pChartObject->GraphAreaX2 - $this->pChartObject->GraphAreaX1 - $XMargin * 2) / $XDivs;

        $X = $this->pChartObject->GraphAreaX1 + $XMargin;
        $Y = $this->pChartObject->GraphAreaY1 + $XMargin;

        $LineSettings = ["R" => $LineR, "G" => $LineG, "B" => $LineB, "Alpha" => $LineAlpha];
        $ExtremitySettings = [
            "R" => $ExtremityR,
            "G" => $ExtremityG,
            "B" => $ExtremityB,
            "Alpha" => $ExtremityAlpha
        ];
        $BoxUpSettings = [
            "R" => $BoxUpR,
            "G" => $BoxUpG,
            "B" => $BoxUpB,
            "Alpha" => $BoxUpAlpha,
            "BorderR" => $BoxUpBorderR,
            "BorderG" => $BoxUpBorderG,
            "BorderB" => $BoxUpBorderB,
            "BorderAlpha" => $BoxUpBorderAlpha
        ];
        $BoxDownSettings = [
            "R" => $BoxDownR,
            "G" => $BoxDownG,
            "B" => $BoxDownB,
            "Alpha" => $BoxDownAlpha,
            "BorderR" => $BoxDownBorderR,
            "BorderG" => $BoxDownBorderG,
            "BorderB" => $BoxDownBorderB,
            "BorderAlpha" => $BoxDownBorderAlpha
        ];
        $MedianSettings = ["R" => $MedianR, "G" => $MedianG, "B" => $MedianB, "Alpha" => $MedianAlpha];

        foreach ($Plots as $Key => $Points) {
            $PosArray = $this->pChartObject->scaleComputeY($Points, ["AxisID" => $AxisID]);

            $Values = "Open :" . $Data["Series"][$SerieOpen]["Data"][$Key]
                    . "<BR>Close : " . $Data["Series"][$SerieClose]["Data"][$Key]
                    . "<BR>Min : " . $Data["Series"][$SerieMin]["Data"][$Key]
                    . "<BR>Max : " . $Data["Series"][$SerieMax]["Data"][$Key] . "<BR>";
            if ($SerieMedian != null) {
                $Values = $Values . "Median : " . $Data["Series"][$SerieMedian]["Data"][$Key] . "<BR>";
            }
            if ($PosArray[0] > $PosArray[1]) {
                $ImageMapColor = $this->pChartObject->toHTMLColor($BoxUpR, $BoxUpG, $BoxUpB);
            } else {
                $ImageMapColor = $this->pChartObject->toHTMLColor($BoxDownR, $BoxDownG, $BoxDownB);
            }

            if ($Data["Orientation"] == SCALE_POS_LEFTRIGHT) {
                if ($YZero > $this->pChartObject->GraphAreaY2 - 1) {
                    $YZero = $this->pChartObject->GraphAreaY2 - 1;
                }
                if ($YZero < $this->pChartObject->GraphAreaY1 + 1) {
                    $YZero = $this->pChartObject->GraphAreaY1 + 1;
                }

                if ($XDivs == 0) {
                    $XStep = 0;
                } else {
                    $XStep = ($this->pChartObject->GraphAreaX2 - $this->pChartObject->GraphAreaX1 - $XMargin * 2)
                        / $XDivs
                    ;
                }

                if ($ShadowOnBoxesOnly) {
                    $RestoreShadow = $this->pChartObject->Shadow;
                    $this->pChartObject->Shadow = false;
                }

                if ($LineWidth == 1) {
                    $this->pChartObject->drawLine($X, $PosArray[2], $X, $PosArray[3], $LineSettings);
                } else {
                    $this->pChartObject->drawFilledRectangle(
                        $X - $LineOffset,
                        $PosArray[2],
                        $X + $LineOffset,
                        $PosArray[3],
                        $LineSettings
                    );
                }

                if ($ExtremityWidth == 1) {
                    $this->pChartObject->drawLine(
                        $X - $ExtremityLength,
                        $PosArray[2],
                        $X + $ExtremityLength,
                        $PosArray[2],
                        $ExtremitySettings
                    );
                    $this->pChartObject->drawLine(
                        $X - $ExtremityLength,
                        $PosArray[3],
                        $X + $ExtremityLength,
                        $PosArray[3],
                        $ExtremitySettings
                    );

                    if ($RecordImageMap) {
                        $this->pChartObject->addToImageMap(
                            "RECT",
                            sprintf(
                                "%s,%s,%s,%s",
                                floor($X - $ExtremityLength),
                                floor($PosArray[2]),
                                floor($X + $ExtremityLength),
                                floor($PosArray[3])
                            ),
                            $ImageMapColor,
                            $ImageMapTitle,
                            $Values
                        );
                    }
                } else {
                    $this->pChartObject->drawFilledRectangle(
                        $X - $ExtremityLength,
                        $PosArray[2],
                        $X + $ExtremityLength,
                        $PosArray[2] - $ExtremityWidth,
                        $ExtremitySettings
                    );
                    $this->pChartObject->drawFilledRectangle(
                        $X - $ExtremityLength,
                        $PosArray[3],
                        $X + $ExtremityLength,
                        $PosArray[3] + $ExtremityWidth,
                        $ExtremitySettings
                    );

                    if ($RecordImageMap) {
                        $this->pChartObject->addToImageMap(
                            "RECT",
                            sprintf(
                                "%s,%s,%s,%s",
                                floor($X - $ExtremityLength),
                                floor($PosArray[2] - $ExtremityWidth),
                                floor($X + $ExtremityLength),
                                floor($PosArray[3] + $ExtremityWidth)
                            ),
                            $ImageMapColor,
                            $ImageMapTitle,
                            $Values
                        );
                    }
                }

                if ($ShadowOnBoxesOnly) {
                    $this->pChartObject->Shadow = $RestoreShadow;
                }

                if ($PosArray[0] > $PosArray[1]) {
                    $this->pChartObject->drawFilledRectangle(
                        $X - $BoxOffset,
                        $PosArray[0],
                        $X + $BoxOffset,
                        $PosArray[1],
                        $BoxUpSettings
                    );
                } else {
                    $this->pChartObject->drawFilledRectangle(
                        $X - $BoxOffset,
                        $PosArray[0],
                        $X + $BoxOffset,
                        $PosArray[1],
                        $BoxDownSettings
                    );
                }

                if (isset($PosArray[4])) {
                    $this->pChartObject->drawLine(
                        $X - $ExtremityLength,
                        $PosArray[4],
                        $X + $ExtremityLength,
                        $PosArray[4],
                        $MedianSettings
                    );
                }
                $X = $X + $XStep;
            } elseif ($Data["Orientation"] == SCALE_POS_TOPBOTTOM) {
                if ($YZero > $this->pChartObject->GraphAreaX2 - 1) {
                    $YZero = $this->pChartObject->GraphAreaX2 - 1;
                }
                if ($YZero < $this->pChartObject->GraphAreaX1 + 1) {
                    $YZero = $this->pChartObject->GraphAreaX1 + 1;
                }

                if ($XDivs == 0) {
                    $XStep = 0;
                } else {
                    $XStep = ($this->pChartObject->GraphAreaY2 - $this->pChartObject->GraphAreaY1 - $XMargin * 2)
                        / $XDivs
                    ;
                }

                if ($LineWidth == 1) {
                    $this->pChartObject->drawLine($PosArray[2], $Y, $PosArray[3], $Y, $LineSettings);
                } else {
                    $this->pChartObject->drawFilledRectangle(
                        $PosArray[2],
                        $Y - $LineOffset,
                        $PosArray[3],
                        $Y + $LineOffset,
                        $LineSettings
                    );
                }
                if ($ShadowOnBoxesOnly) {
                    $RestoreShadow = $this->pChartObject->Shadow;
                    $this->pChartObject->Shadow = false;
                }

                if ($ExtremityWidth == 1) {
                    $this->pChartObject->drawLine(
                        $PosArray[2],
                        $Y - $ExtremityLength,
                        $PosArray[2],
                        $Y + $ExtremityLength,
                        $ExtremitySettings
                    );
                    $this->pChartObject->drawLine(
                        $PosArray[3],
                        $Y - $ExtremityLength,
                        $PosArray[3],
                        $Y + $ExtremityLength,
                        $ExtremitySettings
                    );

                    if ($RecordImageMap) {
                        $this->pChartObject->addToImageMap(
                            "RECT",
                            sprintf(
                                "%s,%s,%s,%s",
                                floor($PosArray[2]),
                                floor($Y - $ExtremityLength),
                                floor($PosArray[3]),
                                floor($Y + $ExtremityLength)
                            ),
                            $ImageMapColor,
                            $ImageMapTitle,
                            $Values
                        );
                    }
                } else {
                    $this->pChartObject->drawFilledRectangle(
                        $PosArray[2],
                        $Y - $ExtremityLength,
                        $PosArray[2] - $ExtremityWidth,
                        $Y + $ExtremityLength,
                        $ExtremitySettings
                    );
                    $this->pChartObject->drawFilledRectangle(
                        $PosArray[3],
                        $Y - $ExtremityLength,
                        $PosArray[3] + $ExtremityWidth,
                        $Y + $ExtremityLength,
                        $ExtremitySettings
                    );

                    if ($RecordImageMap) {
                        $this->pChartObject->addToImageMap(
                            "RECT",
                            sprintf(
                                "%s,%s,%s,%s",
                                floor($PosArray[2] - $ExtremityWidth),
                                floor($Y - $ExtremityLength),
                                floor($PosArray[3] + $ExtremityWidth),
                                floor($Y + $ExtremityLength)
                            ),
                            $ImageMapColor,
                            $ImageMapTitle,
                            $Values
                        );
                    }
                }

                if ($ShadowOnBoxesOnly) {
                    $this->pChartObject->Shadow = $RestoreShadow;
                }

                if ($PosArray[0] < $PosArray[1]) {
                    $this->pChartObject->drawFilledRectangle(
                        $PosArray[0],
                        $Y - $BoxOffset,
                        $PosArray[1],
                        $Y + $BoxOffset,
                        $BoxUpSettings
                    );
                } else {
                    $this->pChartObject->drawFilledRectangle(
                        $PosArray[0],
                        $Y - $BoxOffset,
                        $PosArray[1],
                        $Y + $BoxOffset,
                        $BoxDownSettings
                    );
                }
                if (isset($PosArray[4])) {
                    $this->pChartObject->drawLine(
                        $PosArray[4],
                        $Y - $ExtremityLength,
                        $PosArray[4],
                        $Y + $ExtremityLength,
                        $MedianSettings
                    );
                }
                $Y = $Y + $XStep;
            }
        }
    }
1026730
public function drawScatterBestFit(array $Format = [])
    {
        $Ticks = isset($Format["Ticks"]) ? $Format["Ticks"] : 0;

        $Data = $this->pDataObject->getData();

        foreach ($Data["ScatterSeries"] as $Key => $Series) {
            if ($Series["isDrawable"] == true) {
                $SerieX = $Series["X"];
                $SerieXAxis = $Data["Series"][$SerieX]["Axis"];
                $SerieY = $Series["Y"];
                $SerieYAxis = $Data["Series"][$SerieY]["Axis"];

                $Color = [
                    "R" => $Series["Color"]["R"],
                    "G" => $Series["Color"]["G"],
                    "B" => $Series["Color"]["B"],
                    "Alpha" => $Series["Color"]["Alpha"]
                ];
                $Color["Ticks"] = $Ticks;

                $PosArrayX = $Data["Series"][$Series["X"]]["Data"];
                $PosArrayY = $Data["Series"][$Series["Y"]]["Data"];

                $Sxy = 0;
                $Sx = 0;
                $Sy = 0;
                $Sxx = 0;
                foreach ($PosArrayX as $Key => $Value) {
                    $X = $Value;
                    $Y = $PosArrayY[$Key];

                    $Sxy = $Sxy + $X * $Y;
                    $Sx = $Sx + $X;
                    $Sy = $Sy + $Y;
                    $Sxx = $Sxx + $X * $X;
                }

                $n = count($PosArrayX);

                if ((($n * $Sxx) == ($Sx * $Sx))) {
                    $X1 = $this->getPosArray($Data["Axis"][$SerieXAxis]["ScaleMin"], $SerieXAxis);
                    $X2 = $X1;
                    $Y1 = $this->pChartObject->GraphAreaY1;
                    $Y2 = $this->pChartObject->GraphAreaY2;
                } else {
                    $M = (($n * $Sxy) - ($Sx * $Sy)) / (($n * $Sxx) - ($Sx * $Sx));
                    $B = (($Sy) - ($M * $Sx)) / ($n);

                    $X1 = $this->getPosArray($Data["Axis"][$SerieXAxis]["ScaleMin"], $SerieXAxis);
                    $Y1 = $this->getPosArray($M * $Data["Axis"][$SerieXAxis]["ScaleMin"] + $B, $SerieYAxis);
                    $X2 = $this->getPosArray($Data["Axis"][$SerieXAxis]["ScaleMax"], $SerieXAxis);
                    $Y2 = $this->getPosArray($M * $Data["Axis"][$SerieXAxis]["ScaleMax"] + $B, $SerieYAxis);

                    $RealM = -($Y2 - $Y1) / ($X2 - $X1);

                    if ($Y1 < $this->pChartObject->GraphAreaY1) {
                        $X1 = $X1 + ($this->pChartObject->GraphAreaY1 - $Y1 / $RealM);
                        $Y1 = $this->pChartObject->GraphAreaY1;
                    }
                    if ($Y1 > $this->pChartObject->GraphAreaY2) {
                        $X1 = $X1 + ($Y1 - $this->pChartObject->GraphAreaY2) / $RealM;
                        $Y1 = $this->pChartObject->GraphAreaY2;
                    }
                    if ($Y2 < $this->pChartObject->GraphAreaY1) {
                        $X2 = $X2 - ($this->pChartObject->GraphAreaY1 - $Y2) / $RealM;
                        $Y2 = $this->pChartObject->GraphAreaY1;
                    }
                    if ($Y2 > $this->pChartObject->GraphAreaY2) {
                        $X2 = $X2 - ($Y2 - $this->pChartObject->GraphAreaY2) / $RealM;
                        $Y2 = $this->pChartObject->GraphAreaY2;
                    }
                }

                $this->pChartObject->drawLine($X1, $Y1, $X2, $Y2, $Color);
            }
        }
    }
1254115
public function formatLine(string $format, array $item, array $style = [])
    {
        foreach ($item as $key => $value) {
            $value = (isset($style[$key]) && ! empty($style[$key])) ?
                    "<{$style[$key]}>{$value}</>" :
                    $value;
            $format = str_replace("<{$key}>", $value, $format);
        }

        $this->output->writeln($format);
    }
21509
public function stylesheets(string $collection, ?string $format = null) : string {
        return $this->serve($collection, 'stylesheets', $format);
    }