Draw a radar chart
@param Image $Object
@param Data $Values
@param array $Format
760431
public function drawRadar(Image $Object, Data $Values, array $Format = [])
    {
        $this->pChartObject = $Object;

        $FixedMax = isset($Format["FixedMax"]) ? $Format["FixedMax"] : VOID;
        $AxisR = isset($Format["AxisR"]) ? $Format["AxisR"] : 60;
        $AxisG = isset($Format["AxisG"]) ? $Format["AxisG"] : 60;
        $AxisB = isset($Format["AxisB"]) ? $Format["AxisB"] : 60;
        $AxisAlpha = isset($Format["AxisAlpha"]) ? $Format["AxisAlpha"] : 50;
        $AxisRotation = isset($Format["AxisRotation"]) ? $Format["AxisRotation"] : 0;
        $DrawTicks = isset($Format["DrawTicks"]) ? $Format["DrawTicks"] : true;
        $TicksLength = isset($Format["TicksLength"]) ? $Format["TicksLength"] : 2;
        $DrawAxisValues = isset($Format["DrawAxisValues"]) ? $Format["DrawAxisValues"] : true;
        $AxisBoxRounded = isset($Format["AxisBoxRounded"]) ? $Format["AxisBoxRounded"] : true;
        $AxisFontName = isset($Format["AxisFontName"]) ? $Format["AxisFontName"] : $this->pChartObject->FontName;
        $AxisFontSize = isset($Format["AxisFontSize"]) ? $Format["AxisFontSize"] : $this->pChartObject->FontSize;
        $WriteValues = isset($Format["WriteValues"]) ? $Format["WriteValues"] : false;
        $WriteValuesInBubble = isset($Format["WriteValuesInBubble"]) ? $Format["WriteValuesInBubble"] : true;
        $ValueFontName = isset($Format["ValueFontName"]) ? $Format["ValueFontName"] : $this->pChartObject->FontName
        ;
        $ValueFontSize = isset($Format["ValueFontSize"]) ? $Format["ValueFontSize"] : $this->pChartObject->FontSize
        ;
        $ValuePadding = isset($Format["ValuePadding"]) ? $Format["ValuePadding"] : 4;
        $OuterBubbleRadius = isset($Format["OuterBubbleRadius"]) ? $Format["OuterBubbleRadius"] : 2;
        $OuterBubbleR = isset($Format["OuterBubbleR"]) ? $Format["OuterBubbleR"] : VOID;
        $OuterBubbleG = isset($Format["OuterBubbleG"]) ? $Format["OuterBubbleG"] : VOID;
        $OuterBubbleB = isset($Format["OuterBubbleB"]) ? $Format["OuterBubbleB"] : VOID;
        $OuterBubbleAlpha = isset($Format["OuterBubbleAlpha"]) ? $Format["OuterBubbleAlpha"] : 100;
        $InnerBubbleR = isset($Format["InnerBubbleR"]) ? $Format["InnerBubbleR"] : 255;
        $InnerBubbleG = isset($Format["InnerBubbleG"]) ? $Format["InnerBubbleG"] : 255;
        $InnerBubbleB = isset($Format["InnerBubbleB"]) ? $Format["InnerBubbleB"] : 255;
        $InnerBubbleAlpha = isset($Format["InnerBubbleAlpha"]) ? $Format["InnerBubbleAlpha"] : 100;
        $DrawBackground = isset($Format["DrawBackground"]) ? $Format["DrawBackground"] : true;
        $BackgroundR = isset($Format["BackgroundR"]) ? $Format["BackgroundR"] : 255;
        $BackgroundG = isset($Format["BackgroundG"]) ? $Format["BackgroundG"] : 255;
        $BackgroundB = isset($Format["BackgroundB"]) ? $Format["BackgroundB"] : 255;
        $BackgroundAlpha = isset($Format["BackgroundAlpha"]) ? $Format["BackgroundAlpha"] : 50;
        $BackgroundGradient = isset($Format["BackgroundGradient"]) ? $Format["BackgroundGradient"] : null;
        $Layout = isset($Format["Layout"]) ? $Format["Layout"] : RADAR_LAYOUT_STAR;
        $SegmentHeight = isset($Format["SegmentHeight"]) ? $Format["SegmentHeight"] : SEGMENT_HEIGHT_AUTO;
        $Segments = isset($Format["Segments"]) ? $Format["Segments"] : 4;
        $WriteLabels = isset($Format["WriteLabels"]) ? $Format["WriteLabels"] : true;
        $SkipLabels = isset($Format["SkipLabels"]) ? $Format["SkipLabels"] : 1;
        $LabelMiddle = isset($Format["LabelMiddle"]) ? $Format["LabelMiddle"] : false;
        $LabelsBackground = isset($Format["LabelsBackground"]) ? $Format["LabelsBackground"] : true;
        $LabelsBGR = isset($Format["LabelsBGR"]) ? $Format["LabelsBGR"] : 255;
        $LabelsBGG = isset($Format["LabelsBGR"]) ? $Format["LabelsBGG"] : 255;
        $LabelsBGB = isset($Format["LabelsBGR"]) ? $Format["LabelsBGB"] : 255;
        $LabelsBGAlpha = isset($Format["LabelsBGAlpha"]) ? $Format["LabelsBGAlpha"] : 50;
        $LabelPos = isset($Format["LabelPos"]) ? $Format["LabelPos"] : RADAR_LABELS_ROTATED;
        $LabelPadding = isset($Format["LabelPadding"]) ? $Format["LabelPadding"] : 4;
        $DrawPoints = isset($Format["DrawPoints"]) ? $Format["DrawPoints"] : true;
        $PointRadius = isset($Format["PointRadius"]) ? $Format["PointRadius"] : 4;
        $PointSurrounding = isset($Format["PointRadius"]) ? $Format["PointRadius"] : -30;
        $DrawLines = isset($Format["DrawLines"]) ? $Format["DrawLines"] : true;
        $LineLoopStart = isset($Format["LineLoopStart"]) ? $Format["LineLoopStart"] : true;
        $DrawPoly = isset($Format["DrawPoly"]) ? $Format["DrawPoly"] : false;
        $PolyAlpha = isset($Format["PolyAlpha"]) ? $Format["PolyAlpha"] : 40;
        $FontSize = $Object->FontSize;
        $X1 = $Object->GraphAreaX1;
        $Y1 = $Object->GraphAreaY1;
        $X2 = $Object->GraphAreaX2;
        $Y2 = $Object->GraphAreaY2;
        $RecordImageMap = isset($Format["RecordImageMap"]) ? $Format["RecordImageMap"] : false;

        /* Cancel default tick length if ticks not enabled */
        if ($DrawTicks == false) {
            $TicksLength = 0;
        }

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

        /* Catch the number of required axis */
        $LabelSerie = $Data["Abscissa"];
        if ($LabelSerie) {
            $Points = count($Data["Series"][$LabelSerie]["Data"]);
        } else {
            $Points = 0;
            foreach ($Data["Series"] as $SerieName => $DataArray) {
                if (count($DataArray["Data"]) > $Points) {
                    $Points = count($DataArray["Data"]);
                }
            }
        }

        /* Draw the axis */
        $CenterX = ($X2 - $X1) / 2 + $X1;
        $CenterY = ($Y2 - $Y1) / 2 + $Y1;

        $EdgeHeight = min(($X2 - $X1) / 2, ($Y2 - $Y1) / 2);
        if ($WriteLabels) {
            $EdgeHeight = $EdgeHeight - $FontSize - $LabelPadding - $TicksLength;
        }
        /* Determine the scale if set to automatic */
        if ($SegmentHeight == SEGMENT_HEIGHT_AUTO) {
            if ($FixedMax != VOID) {
                $Max = $FixedMax;
            } else {
                $Max = 0;
                foreach ($Data["Series"] as $SerieName => $DataArray) {
                    if ($SerieName != $LabelSerie) {
                        if (max($DataArray["Data"]) > $Max) {
                            $Max = max($DataArray["Data"]);
                        }
                    }
                }
            }
            $MaxSegments = $EdgeHeight / 20;
            $Scale = $Object->computeScale(0, $Max, $MaxSegments, [1, 2, 5]);

            $Segments = $Scale["Rows"];
            $SegmentHeight = $Scale["RowHeight"];
        }

        if ($LabelMiddle && $SkipLabels == 1) {
            $Axisoffset = (360 / $Points) / 2;
        } elseif ($LabelMiddle && $SkipLabels != 1) {
            $Axisoffset = (360 / ($Points / $SkipLabels)) / 2;
        } elseif (!$LabelMiddle) {
            $Axisoffset = 0;
        }

        /* Background processing */
        if ($DrawBackground) {
            $RestoreShadow = $Object->Shadow;
            $Object->Shadow = false;

            if ($BackgroundGradient == null) {
                if ($Layout == RADAR_LAYOUT_STAR) {
                    $Color = [
                        "R" => $BackgroundR,
                        "G" => $BackgroundG,
                        "B" => $BackgroundB,
                        "Alpha" => $BackgroundAlpha
                    ];
                    $PointArray = [];
                    for ($i = 0; $i <= 360; $i = $i + (360 / $Points)) {
                        $PointArray[] = cos(deg2rad($i + $AxisRotation)) * $EdgeHeight + $CenterX;
                        $PointArray[] = sin(deg2rad($i + $AxisRotation)) * $EdgeHeight + $CenterY;
                    }
                    $Object->drawPolygon($PointArray, $Color);
                } elseif ($Layout == RADAR_LAYOUT_CIRCLE) {
                    $Color = [
                        "R" => $BackgroundR,
                        "G" => $BackgroundG,
                        "B" => $BackgroundB,
                        "Alpha" => $BackgroundAlpha
                    ];
                    $Object->drawFilledCircle(
                        $CenterX,
                        $CenterY,
                        $EdgeHeight,
                        $Color
                    );
                }
            } else {
                $GradientROffset = ($BackgroundGradient["EndR"] - $BackgroundGradient["StartR"]) / $Segments;
                $GradientGOffset = ($BackgroundGradient["EndG"] - $BackgroundGradient["StartG"]) / $Segments;
                $GradientBOffset = ($BackgroundGradient["EndB"] - $BackgroundGradient["StartB"]) / $Segments;
                $GradientAlphaOffset = ($BackgroundGradient["EndAlpha"] - $BackgroundGradient["StartAlpha"])
                    / $Segments
                ;

                if ($Layout == RADAR_LAYOUT_STAR) {
                    for ($j = $Segments; $j >= 1; $j--) {
                        $Color = [
                            "R" => $BackgroundGradient["StartR"] + $GradientROffset * $j,
                            "G" => $BackgroundGradient["StartG"] + $GradientGOffset * $j,
                            "B" => $BackgroundGradient["StartB"] + $GradientBOffset * $j,
                            "Alpha" => $BackgroundGradient["StartAlpha"] + $GradientAlphaOffset * $j
                        ];
                        $PointArray = [];

                        for ($i = 0; $i <= 360; $i = $i + (360 / $Points)) {
                            $PointArray[] = cos(deg2rad($i + $AxisRotation))
                                * ($EdgeHeight / $Segments) * $j + $CenterX
                            ;
                            $PointArray[] = sin(deg2rad($i + $AxisRotation))
                                * ($EdgeHeight / $Segments) * $j + $CenterY
                            ;
                        }
                        $Object->drawPolygon($PointArray, $Color);
                    }
                } elseif ($Layout == RADAR_LAYOUT_CIRCLE) {
                    for ($j = $Segments; $j >= 1; $j--) {
                        $Color = [
                            "R" => $BackgroundGradient["StartR"] + $GradientROffset * $j,
                            "G" => $BackgroundGradient["StartG"] + $GradientGOffset * $j,
                            "B" => $BackgroundGradient["StartB"] + $GradientBOffset * $j,
                            "Alpha" => $BackgroundGradient["StartAlpha"] + $GradientAlphaOffset * $j
                        ];
                        $Object->drawFilledCircle(
                            $CenterX,
                            $CenterY,
                            ($EdgeHeight / $Segments) * $j,
                            $Color
                        );
                    }
                }
            }
            $Object->Shadow = $RestoreShadow;
        }

        /* Axis to axis lines */
        $Color = ["R" => $AxisR, "G" => $AxisG, "B" => $AxisB, "Alpha" => $AxisAlpha];
        $ColorDotted = [
            "R" => $AxisR,
            "G" => $AxisG,
            "B" => $AxisB,
            "Alpha" => $AxisAlpha * .8,
            "Ticks" => 2
        ];
        if ($Layout == RADAR_LAYOUT_STAR) {
            for ($j = 1; $j <= $Segments; $j++) {
                for ($i = 0; $i < 360; $i = $i + (360 / $Points)) {
                    $EdgeX1 = cos(deg2rad($i + $AxisRotation)) * ($EdgeHeight / $Segments) * $j + $CenterX;
                    $EdgeY1 = sin(deg2rad($i + $AxisRotation)) * ($EdgeHeight / $Segments) * $j + $CenterY;
                    $EdgeX2 = cos(deg2rad($i + $AxisRotation + (360 / $Points)))
                        * ($EdgeHeight / $Segments) * $j + $CenterX
                    ;
                    $EdgeY2 = sin(deg2rad($i + $AxisRotation + (360 / $Points)))
                        * ($EdgeHeight / $Segments) * $j + $CenterY
                    ;

                    $Object->drawLine($EdgeX1, $EdgeY1, $EdgeX2, $EdgeY2, $Color);
                }
            }
        } elseif ($Layout == RADAR_LAYOUT_CIRCLE) {
            for ($j = 1; $j <= $Segments; $j++) {
                $Radius = ($EdgeHeight / $Segments) * $j;
                $Object->drawCircle($CenterX, $CenterY, $Radius, $Radius, $Color);
            }
        }

        if ($DrawAxisValues) {
            if ($LabelsBackground) {
                $Options = [
                    "DrawBox"  => true,
                    "Align"  => TEXT_ALIGN_MIDDLEMIDDLE,
                    "BoxR" => $LabelsBGR,
                    "BoxG" => $LabelsBGG,
                    "BoxB" => $LabelsBGB,
                    "BoxAlpha" => $LabelsBGAlpha
                ];
            } else {
                $Options = ["Align" => TEXT_ALIGN_MIDDLEMIDDLE];
            }
            if ($AxisBoxRounded) {
                $Options["BoxRounded"] = true;
            }

            $Options["FontName"] = $AxisFontName;
            $Options["FontSize"] = $AxisFontSize;

            $Angle = 360 / ($Points * 2);
            for ($j = 1; $j <= $Segments; $j++) {
                $Label = $j * $SegmentHeight;

                if ($Layout == RADAR_LAYOUT_CIRCLE) {
                    $EdgeX1 = cos(deg2rad($Angle + $AxisRotation)) * ($EdgeHeight / $Segments) * $j + $CenterX;
                    $EdgeY1 = sin(deg2rad($Angle + $AxisRotation)) * ($EdgeHeight / $Segments) * $j + $CenterY;
                } elseif ($Layout == RADAR_LAYOUT_STAR) {
                    $EdgeX1 = cos(deg2rad($AxisRotation)) * ($EdgeHeight / $Segments) * $j + $CenterX;
                    $EdgeY1 = sin(deg2rad($AxisRotation)) * ($EdgeHeight / $Segments) * $j + $CenterY;
                    $EdgeX2 = cos(deg2rad((360 / $Points) + $AxisRotation)) * ($EdgeHeight / $Segments)
                        * $j + $CenterX
                    ;
                    $EdgeY2 = sin(deg2rad((360 / $Points) + $AxisRotation)) * ($EdgeHeight / $Segments)
                        * $j + $CenterY
                    ;

                    $EdgeX1 = ($EdgeX2 - $EdgeX1) / 2 + $EdgeX1;
                    $EdgeY1 = ($EdgeY2 - $EdgeY1) / 2 + $EdgeY1;
                }

                $Object->drawText($EdgeX1, $EdgeY1, $Label, $Options);
            }
        }

        /* Axis lines */
        $ID = 0;
        for ($i = 0; $i < 360; $i = $i + (360 / $Points)) {
            $EdgeX = cos(deg2rad($i + $AxisRotation)) * ($EdgeHeight + $TicksLength) + $CenterX;
            $EdgeY = sin(deg2rad($i + $AxisRotation)) * ($EdgeHeight + $TicksLength) + $CenterY;

            if ($ID % $SkipLabels == 0) {
                $Object->drawLine($CenterX, $CenterY, $EdgeX, $EdgeY, $Color);
            } else {
                $Object->drawLine($CenterX, $CenterY, $EdgeX, $EdgeY, $ColorDotted);
            }

            if ($WriteLabels) {
                $LabelX = cos(deg2rad($i + $AxisRotation + $Axisoffset))
                    * ($EdgeHeight + $LabelPadding + $TicksLength) + $CenterX
                ;
                $LabelY = sin(deg2rad($i + $AxisRotation + $Axisoffset))
                    * ($EdgeHeight + $LabelPadding + $TicksLength) + $CenterY
                ;

                if ($LabelSerie) {
                    $Label = isset($Data["Series"][$LabelSerie]["Data"][$ID])
                        ? $Data["Series"][$LabelSerie]["Data"][$ID] : ""
                    ;
                } else {
                    $Label = $ID;
                }

                if ($ID % $SkipLabels == 0) {
                    if ($LabelPos == RADAR_LABELS_ROTATED) {
                        $Object->drawText(
                            $LabelX,
                            $LabelY,
                            $Label,
                            [
                                "Angle" => (360 - ($i + $AxisRotation + $Axisoffset)) - 90,
                                "Align" => TEXT_ALIGN_BOTTOMMIDDLE
                            ]
                        );
                    } else {
                        if ((floor($LabelX) == floor($CenterX)) && (floor($LabelY) < floor($CenterY))) {
                            $Object->drawText(
                                $LabelX,
                                $LabelY,
                                $Label,
                                ["Align" => TEXT_ALIGN_BOTTOMMIDDLE]
                            );
                        }
                        if ((floor($LabelX) > floor($CenterX)) && (floor($LabelY) < floor($CenterY))) {
                            $Object->drawText(
                                $LabelX,
                                $LabelY,
                                $Label,
                                ["Align" => TEXT_ALIGN_BOTTOMLEFT]
                            );
                        }
                        if ((floor($LabelX) > floor($CenterX)) && (floor($LabelY) == floor($CenterY))) {
                            $Object->drawText(
                                $LabelX,
                                $LabelY,
                                $Label,
                                ["Align" => TEXT_ALIGN_MIDDLELEFT]
                            );
                        }
                        if ((floor($LabelX) > floor($CenterX)) && (floor($LabelY) > floor($CenterY))) {
                            $Object->drawText(
                                $LabelX,
                                $LabelY,
                                $Label,
                                ["Align" => TEXT_ALIGN_TOPLEFT]
                            );
                        }
                        if ((floor($LabelX) < floor($CenterX)) && (floor($LabelY) < floor($CenterY))) {
                            $Object->drawText(
                                $LabelX,
                                $LabelY,
                                $Label,
                                ["Align" => TEXT_ALIGN_BOTTOMRIGHT]
                            );
                        }
                        if ((floor($LabelX) < floor($CenterX)) && (floor($LabelY) == floor($CenterY))) {
                            $Object->drawText(
                                $LabelX,
                                $LabelY,
                                $Label,
                                ["Align" => TEXT_ALIGN_MIDDLERIGHT]
                            );
                        }
                        if ((floor($LabelX) < floor($CenterX)) && (floor($LabelY) > floor($CenterY))) {
                            $Object->drawText(
                                $LabelX,
                                $LabelY,
                                $Label,
                                ["Align" => TEXT_ALIGN_TOPRIGHT]
                            );
                        }
                        if ((floor($LabelX) == floor($CenterX)) && (floor($LabelY) > floor($CenterY))) {
                            $Object->drawText(
                                $LabelX,
                                $LabelY,
                                $Label,
                                ["Align" => TEXT_ALIGN_TOPMIDDLE]
                            );
                        }
                    }
                }
            }
            $ID++;
        }

        /* Compute the plots position */
        $ID = 0;
        $Plot = [];
        foreach ($Data["Series"] as $SerieName => $DataS) {
            if ($SerieName != $LabelSerie) {
                $Color = [
                    "R" => $Palette[$ID]["R"],
                    "G" => $Palette[$ID]["G"],
                    "B" => $Palette[$ID]["B"],
                    "Alpha" => $Palette[$ID]["Alpha"],
                    "Surrounding" => $PointSurrounding
                ];
                foreach ($DataS["Data"] as $Key => $Value) {
                    $Angle = (360 / $Points) * $Key;
                    $Length = ($EdgeHeight / ($Segments * $SegmentHeight)) * $Value;

                    $X = cos(deg2rad($Angle + $AxisRotation)) * $Length + $CenterX;
                    $Y = sin(deg2rad($Angle + $AxisRotation)) * $Length + $CenterY;

                    $Plot[$ID][] = [$X, $Y, $Value];

                    if ($RecordImageMap) {
                        $this->pChartObject->addToImageMap(
                            "CIRCLE",
                            sprintf("%s,%s,%s", floor($X), floor($Y), floor($PointRadius)),
                            $this->pChartObject->toHTMLColor(
                                $Palette[$ID]["R"],
                                $Palette[$ID]["G"],
                                $Palette[$ID]["B"]
                            ),
                            $DataS["Description"],
                            $Data["Series"][$LabelSerie]["Data"][$Key] . " = " . $Value
                        );
                    }
                }
                $ID++;
            }
        }

        /* Draw all that stuff! */
        foreach ($Plot as $ID => $Points) {
            $Color = [
                "R" => $Palette[$ID]["R"],
                "G" => $Palette[$ID]["G"],
                "B" => $Palette[$ID]["B"],
                "Alpha" => $Palette[$ID]["Alpha"],
                "Surrounding" => $PointSurrounding
            ];

            /* Draw the polygons */
            if ($DrawPoly) {
                if ($PolyAlpha != null) {
                    $Color = [
                        "R" => $Palette[$ID]["R"],
                        "G" => $Palette[$ID]["G"],
                        "B" => $Palette[$ID]["B"],
                        "Alpha" => $PolyAlpha,
                        "Surrounding" => $PointSurrounding
                    ];
                }
                $PointsArray = [];
                for ($i = 0; $i < count($Points); $i++) {
                    $PointsArray[] = $Points[$i][0];
                    $PointsArray[] = $Points[$i][1];
                }
                $Object->drawPolygon($PointsArray, $Color);
            }

            $Color = [
                "R" => $Palette[$ID]["R"],
                "G" => $Palette[$ID]["G"],
                "B" => $Palette[$ID]["B"],
                "Alpha" => $Palette[$ID]["Alpha"],
                "Surrounding" => $PointSurrounding
            ];

            /* Bubble and labels settings */
            $TextSettings = [
                "Align"  => TEXT_ALIGN_MIDDLEMIDDLE,
                "FontName" => $ValueFontName,
                "FontSize" => $ValueFontSize,
                "R"  => $Palette[$ID]["R"],
                "G"  => $Palette[$ID]["G"],
                "B"  => $Palette[$ID]["B"]
            ];
            $InnerColor = [
                "R" => $InnerBubbleR,
                "G" => $InnerBubbleG,
                "B" => $InnerBubbleB,
                "Alpha" => $InnerBubbleAlpha
            ];
            if ($OuterBubbleR != VOID) {
                $OuterColor = [
                    "R" => $OuterBubbleR,
                    "G" => $OuterBubbleG,
                    "B" => $OuterBubbleB,
                    "Alpha" => $OuterBubbleAlpha
                ];
            } else {
                $OuterColor = [
                    "R" => $Palette[$ID]["R"] + 20,
                    "G" => $Palette[$ID]["G"] + 20,
                    "B" => $Palette[$ID]["B"] + 20,
                    "Alpha" => $Palette[$ID]["Alpha"]
                ];
            }
            /* Loop to the starting points if asked */
            if ($LineLoopStart && $DrawLines) {
                $Object->drawLine(
                    $Points[count($Points) - 1][0],
                    $Points[count($Points) - 1][1],
                    $Points[0][0],
                    $Points[0][1],
                    $Color
                );
            }

            /* Draw the lines & points */
            for ($i = 0; $i < count($Points); $i++) {
                if ($DrawLines && $i < count($Points) - 1) {
                    $Object->drawLine(
                        $Points[$i][0],
                        $Points[$i][1],
                        $Points[$i + 1][0],
                        $Points[$i + 1][1],
                        $Color
                    );
                }
                if ($DrawPoints) {
                    $Object->drawFilledCircle(
                        $Points[$i][0],
                        $Points[$i][1],
                        $PointRadius,
                        $Color
                    );
                }
                if ($WriteValuesInBubble && $WriteValues) {
                    $TxtPos = $this->pChartObject->getTextBox(
                        $Points[$i][0],
                        $Points[$i][1],
                        $ValueFontName,
                        $ValueFontSize,
                        0,
                        $Points[$i][2]
                    );
                    $Radius = floor(($TxtPos[1]["X"] - $TxtPos[0]["X"] + $ValuePadding * 2) / 2);

                    $this->pChartObject->drawFilledCircle(
                        $Points[$i][0],
                        $Points[$i][1],
                        $Radius + $OuterBubbleRadius,
                        $OuterColor
                    );
                    $this->pChartObject->drawFilledCircle(
                        $Points[$i][0],
                        $Points[$i][1],
                        $Radius,
                        $InnerColor
                    );
                }

                if ($WriteValues) {
                    $this->pChartObject->drawText(
                        $Points[$i][0] - 1,
                        $Points[$i][1] - 1,
                        $Points[$i][2],
                        $TextSettings
                    );
                }
            }
        }
    }
431564
private function _renderRadarChart($groupCount) {
		require_once('jpgraph_radar.php');

		$this->_renderRadarPlotArea();

		for($groupID = 0; $groupID < $groupCount; ++$groupID) {
			$this->_renderPlotRadar($groupID);
		}
	}
928180
public function xhrFormatAction(Image $image, $formatName, Request $request)
    {
        // retrieve format value object
        if (!$format = $this->container->get('synapse.image_format.loader')
            ->retrieveOne(array('name' => $formatName))
        ) {
            return new JsonResponse(
                array(
                    'error' => 400,
                    'error_message' => sprintf('No format found with name "%s".', $formatName),
                ),
                400
            );
        }

        // form handle
        $form = $this->container->get('form.factory')->createNamed(
            '',
            FormatType::class,
            $image,
            array(
                'format' => $format,
                'method' => 'POST',
                'csrf_protection' => false,
            )
        );
        $form->handleRequest($request);
        if (!$form->isValid()) {
            return new JsonResponse(
                array(
                    'error' => 400,
                    'error_message' => 'Invalid format data.',
                ),
                400
            );
        }

        // formatted image data
        return new JsonResponse(
            $form->getData()
                ->getFormattedImage($formatName)
                ->normalize(),
            201
        );
    }
1061675
public function render($object = false)
    {
        $output = array_merge([
            'draw'            => (int) $this->request['draw'],
            'recordsTotal'    => $this->totalRecords,
            'recordsFiltered' => $this->filteredRecords,
                ], $this->appends);


        if (isset($this->transformer)) {
            $fractal = new Manager();
            if ($this->request->get('include')) {
                $fractal->parseIncludes($this->request->get('include'));
            }

            $serializer = $this->serializer ?: Config::get('datatables.fractal.serializer', DataArraySerializer::class);
            $fractal->setSerializer(new $serializer);

            //Get transformer reflection
            //Firs method parameter should be data/object to transform
            $reflection = new \ReflectionMethod($this->transformer, 'transform');
            $parameter  = $reflection->getParameters()[0];

            //If parameter is class assuming it requires object
            //Else just pass array by default
            if ($parameter->getClass()) {
                $resource = new Collection($this->results(), new $this->transformer());
            } else {
                $resource = new Collection(
                        $this->getProcessedData($object), new $this->transformer()
                );
            }

            $collection     = $fractal->createData($resource)->toArray();
            $output['data'] = $collection['data'];
        } else {
            $output['data'] = Helper::transform($this->getProcessedData($object));
        }
        if ($this->isDebugging()) {
            $output = $this->showDebugger($output);
        }
        return new JsonResponse($output);
    }
1183317
public function drawPieLegend($X, $Y, array $Format = [])
    {
        $FontName = isset($Format["FontName"]) ? $Format["FontName"] : $this->pChartObject->FontName;
        $FontSize = isset($Format["FontSize"]) ? $Format["FontSize"] : $this->pChartObject->FontSize;
        $FontR = isset($Format["FontR"]) ? $Format["FontR"] : $this->pChartObject->FontColorR;
        $FontG = isset($Format["FontG"]) ? $Format["FontG"] : $this->pChartObject->FontColorG;
        $FontB = isset($Format["FontB"]) ? $Format["FontB"] : $this->pChartObject->FontColorB;
        $BoxSize = isset($Format["BoxSize"]) ? $Format["BoxSize"] : 5;
        $Margin = isset($Format["Margin"]) ? $Format["Margin"] : 5;
        $R = isset($Format["R"]) ? $Format["R"] : 200;
        $G = isset($Format["G"]) ? $Format["G"] : 200;
        $B = isset($Format["B"]) ? $Format["B"] : 200;
        $Alpha = isset($Format["Alpha"]) ? $Format["Alpha"] : 100;
        $BorderR = isset($Format["BorderR"]) ? $Format["BorderR"] : 255;
        $BorderG = isset($Format["BorderG"]) ? $Format["BorderG"] : 255;
        $BorderB = isset($Format["BorderB"]) ? $Format["BorderB"] : 255;
        $Surrounding = isset($Format["Surrounding"]) ? $Format["Surrounding"] : null;
        $Style = isset($Format["Style"]) ? $Format["Style"] : LEGEND_ROUND;
        $Mode = isset($Format["Mode"]) ? $Format["Mode"] : LEGEND_VERTICAL;

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

        $YStep = max($this->pChartObject->FontSize, $BoxSize) + 5;
        $XStep = $BoxSize + 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;
        }

        $Boundaries = [];
        $Boundaries["L"] = $X;
        $Boundaries["T"] = $Y;
        $Boundaries["R"] = 0;
        $Boundaries["B"] = 0;
        $vY = $Y;
        $vX = $X;
        foreach ($Data["Series"][$Data["Abscissa"]]["Data"] as $Key => $Value) {
            $BoxArray = $this->pChartObject->getTextBox(
                $vX + $BoxSize + 4,
                $vY + $BoxSize / 2,
                $FontName,
                $FontSize,
                0,
                $Value
            );

            if ($Mode == LEGEND_VERTICAL) {
                if ($Boundaries["T"] > $BoxArray[2]["Y"] + $BoxSize / 2) {
                    $Boundaries["T"] = $BoxArray[2]["Y"] + $BoxSize / 2;
                }
                if ($Boundaries["R"] < $BoxArray[1]["X"] + 2) {
                    $Boundaries["R"] = $BoxArray[1]["X"] + 2;
                }
                if ($Boundaries["B"] < $BoxArray[1]["Y"] + 2 + $BoxSize / 2) {
                    $Boundaries["B"] = $BoxArray[1]["Y"] + 2 + $BoxSize / 2;
                }
                $vY = $vY + $YStep;
            } elseif ($Mode == LEGEND_HORIZONTAL) {
                if ($Boundaries["T"] > $BoxArray[2]["Y"] + $BoxSize / 2) {
                    $Boundaries["T"] = $BoxArray[2]["Y"] + $BoxSize / 2;
                }
                if ($Boundaries["R"] < $BoxArray[1]["X"] + 2) {
                    $Boundaries["R"] = $BoxArray[1]["X"] + 2;
                }
                if ($Boundaries["B"] < $BoxArray[1]["Y"] + 2 + $BoxSize / 2) {
                    $Boundaries["B"] = $BoxArray[1]["Y"] + 2 + $BoxSize / 2;
                }
                $vX = $Boundaries["R"] + $XStep;
            }
        }
        $vY = $vY - $YStep;
        $vX = $vX - $XStep;

        $TopOffset = $Y - $Boundaries["T"];
        if ($Boundaries["B"] - ($vY + $BoxSize) < $TopOffset) {
            $Boundaries["B"] = $vY + $BoxSize + $TopOffset;
        }

        if ($Style == LEGEND_ROUND) {
            $this->pChartObject->drawRoundedFilledRectangle(
                $Boundaries["L"] - $Margin,
                $Boundaries["T"] - $Margin,
                $Boundaries["R"] + $Margin,
                $Boundaries["B"] + $Margin,
                $Margin,
                [
                    "R" => $R,
                    "G" => $G,
                    "B" => $B,
                    "Alpha" => $Alpha,
                    "BorderR" => $BorderR,
                    "BorderG" => $BorderG,
                    "BorderB" => $BorderB
                ]
            );
        } elseif ($Style == LEGEND_BOX) {
            $this->pChartObject->drawFilledRectangle(
                $Boundaries["L"] - $Margin,
                $Boundaries["T"] - $Margin,
                $Boundaries["R"] + $Margin,
                $Boundaries["B"] + $Margin,
                [
                    "R" => $R,
                    "G" => $G,
                    "B" => $B,
                    "Alpha" => $Alpha,
                    "BorderR" => $BorderR,
                    "BorderG" => $BorderG,
                    "BorderB" => $BorderB
                ]
            );
        }
        $RestoreShadow = $this->pChartObject->Shadow;
        $this->pChartObject->Shadow = false;
        foreach ($Data["Series"][$Data["Abscissa"]]["Data"] as $Key => $Value) {
            $R = $Palette[$Key]["R"];
            $G = $Palette[$Key]["G"];
            $B = $Palette[$Key]["B"];

            $this->pChartObject->drawFilledRectangle(
                $X + 1,
                $Y + 1,
                $X + $BoxSize + 1,
                $Y + $BoxSize + 1,
                ["R" => 0, "G" => 0, "B" => 0, "Alpha" => 20]
            );
            $this->pChartObject->drawFilledRectangle(
                $X,
                $Y,
                $X + $BoxSize,
                $Y + $BoxSize,
                ["R" => $R, "G" => $G, "B" => $B, "Surrounding" => 20]
            );
            if ($Mode == LEGEND_VERTICAL) {
                $this->pChartObject->drawText(
                    $X + $BoxSize + 4,
                    $Y + $BoxSize / 2,
                    $Value,
                    [
                        "R" => $FontR,
                        "G" => $FontG,
                        "B" => $FontB,
                        "Align" => TEXT_ALIGN_MIDDLELEFT,
                        "FontName" => $FontName,
                        "FontSize" => $FontSize
                    ]
                );
                $Y = $Y + $YStep;
            } elseif ($Mode == LEGEND_HORIZONTAL) {
                $BoxArray = $this->pChartObject->drawText(
                    $X + $BoxSize + 4,
                    $Y + $BoxSize / 2,
                    $Value,
                    [
                        "R" => $FontR,
                        "G" => $FontG,
                        "B" => $FontB,
                        "Align" => TEXT_ALIGN_MIDDLELEFT,
                        "FontName" => $FontName,
                        "FontSize" => $FontSize
                    ]
                );
                $X = $BoxArray[1]["X"] + 2 + $XStep;
            }
        }

        $this->Shadow = $RestoreShadow;
    }
425690
public function drawScatterScale(array $Format = [])
    {
        $Mode = isset($Format["Mode"]) ? $Format["Mode"] : SCALE_MODE_FLOATING;
        $Floating = isset($Format["Floating"]) ? $Format["Floating"] : false;
        $XLabelsRotation = isset($Format["XLabelsRotation"]) ? $Format["XLabelsRotation"] : 90;
        $MinDivHeight = isset($Format["MinDivHeight"]) ? $Format["MinDivHeight"] : 20;
        $Factors = isset($Format["Factors"]) ? $Format["Factors"] : [1, 2, 5];
        $ManualScale = isset($Format["ManualScale"])
            ? $Format["ManualScale"] : ["0" => ["Min" => -100, "Max" => 100]]
        ;
        $XMargin = isset($Format["XMargin"]) ? $Format["XMargin"] : 0;
        $YMargin = isset($Format["YMargin"]) ? $Format["YMargin"] : 0;
        $ScaleSpacing = isset($Format["ScaleSpacing"]) ? $Format["ScaleSpacing"] : 15;
        $InnerTickWidth = isset($Format["InnerTickWidth"]) ? $Format["InnerTickWidth"] : 2;
        $OuterTickWidth = isset($Format["OuterTickWidth"]) ? $Format["OuterTickWidth"] : 2;
        $DrawXLines = isset($Format["DrawXLines"]) ? $Format["DrawXLines"] : ALL;
        $DrawYLines = isset($Format["DrawYLines"]) ? $Format["DrawYLines"] : ALL;
        $GridTicks = isset($Format["GridTicks"]) ? $Format["GridTicks"] : 4;
        $GridR = isset($Format["GridR"]) ? $Format["GridR"] : 255;
        $GridG = isset($Format["GridG"]) ? $Format["GridG"] : 255;
        $GridB = isset($Format["GridB"]) ? $Format["GridB"] : 255;
        $GridAlpha = isset($Format["GridAlpha"]) ? $Format["GridAlpha"] : 40;
        $AxisRo = isset($Format["AxisR"]) ? $Format["AxisR"] : 0;
        $AxisGo = isset($Format["AxisG"]) ? $Format["AxisG"] : 0;
        $AxisBo = isset($Format["AxisB"]) ? $Format["AxisB"] : 0;
        $AxisAlpha = isset($Format["AxisAlpha"]) ? $Format["AxisAlpha"] : 100;
        $TickRo = isset($Format["TickR"]) ? $Format["TickR"] : 0;
        $TickGo = isset($Format["TickG"]) ? $Format["TickG"] : 0;
        $TickBo = isset($Format["TickB"]) ? $Format["TickB"] : 0;
        $TickAlpha = isset($Format["TickAlpha"]) ? $Format["TickAlpha"] : 100;
        $DrawSubTicks = isset($Format["DrawSubTicks"]) ? $Format["DrawSubTicks"] : false;
        $InnerSubTickWidth = isset($Format["InnerSubTickWidth"]) ? $Format["InnerSubTickWidth"] : 0;
        $OuterSubTickWidth = isset($Format["OuterSubTickWidth"]) ? $Format["OuterSubTickWidth"] : 2;
        $SubTickR = isset($Format["SubTickR"]) ? $Format["SubTickR"] : 255;
        $SubTickG = isset($Format["SubTickG"]) ? $Format["SubTickG"] : 0;
        $SubTickB = isset($Format["SubTickB"]) ? $Format["SubTickB"] : 0;
        $SubTickAlpha = isset($Format["SubTickAlpha"]) ? $Format["SubTickAlpha"] : 100;
        $XReleasePercent = isset($Format["XReleasePercent"]) ? $Format["XReleasePercent"] : 1;
        $DrawArrows = isset($Format["DrawArrows"]) ? $Format["DrawArrows"] : false;
        $ArrowSize = isset($Format["ArrowSize"]) ? $Format["ArrowSize"] : 8;
        $CycleBackground = isset($Format["CycleBackground"]) ? $Format["CycleBackground"] : false;
        $BackgroundR1 = isset($Format["BackgroundR1"]) ? $Format["BackgroundR1"] : 255;
        $BackgroundG1 = isset($Format["BackgroundG1"]) ? $Format["BackgroundG1"] : 255;
        $BackgroundB1 = isset($Format["BackgroundB1"]) ? $Format["BackgroundB1"] : 255;
        $BackgroundAlpha1 = isset($Format["BackgroundAlpha1"]) ? $Format["BackgroundAlpha1"] : 10;
        $BackgroundR2 = isset($Format["BackgroundR2"]) ? $Format["BackgroundR2"] : 230;
        $BackgroundG2 = isset($Format["BackgroundG2"]) ? $Format["BackgroundG2"] : 230;
        $BackgroundB2 = isset($Format["BackgroundB2"]) ? $Format["BackgroundB2"] : 230;
        $BackgroundAlpha2 = isset($Format["BackgroundAlpha2"]) ? $Format["BackgroundAlpha2"] : 10;

        /* Check if we have at least both one X and Y axis */
        $GotXAxis = false;
        $GotYAxis = false;
        foreach ($this->pDataObject->Data["Axis"] as $AxisID => $AxisSettings) {
            if ($AxisSettings["Identity"] == AXIS_X) {
                $GotXAxis = true;
            }
            if ($AxisSettings["Identity"] == AXIS_Y) {
                $GotYAxis = true;
            }
        }
        if (!$GotXAxis) {
            return SCATTER_MISSING_X_SERIE;
        }
        if (!$GotYAxis) {
            return SCATTER_MISSING_Y_SERIE;
        }

        /* Skip a NOTICE event in case of an empty array */
        if ($DrawYLines == NONE) {
            $DrawYLines = ["zarma" => "31"];
        }

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

        foreach ($Data["Axis"] as $AxisID => $AxisSettings) {
            if ($AxisSettings["Identity"] == AXIS_X) {
                $Width = $this->pChartObject->GraphAreaX2 - $this->pChartObject->GraphAreaX1 - $XMargin * 2;
            } else {
                $Width = $this->pChartObject->GraphAreaY2 - $this->pChartObject->GraphAreaY1 - $YMargin * 2;
            }

            $AxisMin = ABSOLUTE_MAX;
            $AxisMax = OUT_OF_SIGHT;
            if ($Mode == SCALE_MODE_FLOATING) {
                foreach ($Data["Series"] as $SerieID => $SerieParameter) {
                    if ($SerieParameter["Axis"] == $AxisID
                        && $Data["Series"][$SerieID]["isDrawable"]
                    ) {
                        $AxisMax = max($AxisMax, $Data["Series"][$SerieID]["Max"]);
                        $AxisMin = min($AxisMin, $Data["Series"][$SerieID]["Min"]);
                    }
                }
                $AutoMargin = (($AxisMax - $AxisMin) / 100) * $XReleasePercent;

                $Data["Axis"][$AxisID]["Min"] = $AxisMin - $AutoMargin;
                $Data["Axis"][$AxisID]["Max"] = $AxisMax + $AutoMargin;
            } elseif ($Mode == SCALE_MODE_MANUAL) {
                if (isset($ManualScale[$AxisID]["Min"])
                    && isset($ManualScale[$AxisID]["Max"])
                ) {
                    $Data["Axis"][$AxisID]["Min"] = $ManualScale[$AxisID]["Min"];
                    $Data["Axis"][$AxisID]["Max"] = $ManualScale[$AxisID]["Max"];
                } else {
                    throw new Exception("Manual scale boundaries not set.");
                }
            }

            /* Full manual scale */
            if (isset($ManualScale[$AxisID]["Rows"]) && isset($ManualScale[$AxisID]["RowHeight"])) {
                $Scale = [
                    "Rows" => $ManualScale[$AxisID]["Rows"],
                    "RowHeight" => $ManualScale[$AxisID]["RowHeight"],
                    "XMin" => $ManualScale[$AxisID]["Min"],
                    "XMax" => $ManualScale[$AxisID]["Max"]
                ];
            } else {
                $MaxDivs = floor($Width / $MinDivHeight);
                $Scale = $this->pChartObject->computeScale(
                    $Data["Axis"][$AxisID]["Min"],
                    $Data["Axis"][$AxisID]["Max"],
                    $MaxDivs,
                    $Factors,
                    $AxisID
                );
            }

            $Data["Axis"][$AxisID]["Margin"] = $AxisSettings["Identity"] == AXIS_X ? $XMargin : $YMargin;
            $Data["Axis"][$AxisID]["ScaleMin"] = $Scale["XMin"];
            $Data["Axis"][$AxisID]["ScaleMax"] = $Scale["XMax"];
            $Data["Axis"][$AxisID]["Rows"] = $Scale["Rows"];
            $Data["Axis"][$AxisID]["RowHeight"] = $Scale["RowHeight"];

            if (isset($Scale["Format"])) {
                $Data["Axis"][$AxisID]["Format"] = $Scale["Format"];
            }

            if (!isset($Data["Axis"][$AxisID]["Display"])) {
                $Data["Axis"][$AxisID]["Display"] = null;
            }
            if (!isset($Data["Axis"][$AxisID]["Format"])) {
                $Data["Axis"][$AxisID]["Format"] = null;
            }
            if (!isset($Data["Axis"][$AxisID]["Unit"])) {
                $Data["Axis"][$AxisID]["Unit"] = null;
            }
        }

        /* Get the default font color */
        $FontColorRo = $this->pChartObject->FontColorR;
        $FontColorGo = $this->pChartObject->FontColorG;
        $FontColorBo = $this->pChartObject->FontColorB;

        /* Set the original boundaries */
        $AxisPos["L"] = $this->pChartObject->GraphAreaX1;
        $AxisPos["R"] = $this->pChartObject->GraphAreaX2;
        $AxisPos["T"] = $this->pChartObject->GraphAreaY1;
        $AxisPos["B"] = $this->pChartObject->GraphAreaY2;

        foreach ($Data["Axis"] as $AxisID => $AxisSettings) {
            if (isset($AxisSettings["Color"])) {
                $AxisR = $AxisSettings["Color"]["R"];
                $AxisG = $AxisSettings["Color"]["G"];
                $AxisB = $AxisSettings["Color"]["B"];
                $TickR = $AxisSettings["Color"]["R"];
                $TickG = $AxisSettings["Color"]["G"];
                $TickB = $AxisSettings["Color"]["B"];
                $this->pChartObject->setFontProperties(
                    [
                        "R" => $AxisSettings["Color"]["R"],
                        "G" => $AxisSettings["Color"]["G"],
                        "B" => $AxisSettings["Color"]["B"]
                    ]
                );
            } else {
                $AxisR = $AxisRo;
                $AxisG = $AxisGo;
                $AxisB = $AxisBo;
                $TickR = $TickRo;
                $TickG = $TickGo;
                $TickB = $TickBo;
                $this->pChartObject->setFontProperties(
                    ["R" => $FontColorRo, "G" => $FontColorGo, "B" => $FontColorBo]
                );
            }

            if ($AxisSettings["Identity"] == AXIS_X) {
                if ($AxisSettings["Position"] == AXIS_POSITION_BOTTOM) {
                    if ($XLabelsRotation == 0) {
                        $LabelAlign = TEXT_ALIGN_TOPMIDDLE;
                        $LabelOffset = 2;
                    }
                    if ($XLabelsRotation > 0 && $XLabelsRotation < 190) {
                        $LabelAlign = TEXT_ALIGN_MIDDLERIGHT;
                        $LabelOffset = 5;
                    }
                    if ($XLabelsRotation == 180) {
                        $LabelAlign = TEXT_ALIGN_BOTTOMMIDDLE;
                        $LabelOffset = 5;
                    }
                    if ($XLabelsRotation > 180 && $XLabelsRotation < 360) {
                        $LabelAlign = TEXT_ALIGN_MIDDLELEFT;
                        $LabelOffset = 2;
                    }

                    if ($Floating) {
                        $FloatingOffset = $YMargin;
                        $this->pChartObject->drawLine(
                            $this->pChartObject->GraphAreaX1 + $AxisSettings["Margin"],
                            $AxisPos["B"],
                            $this->pChartObject->GraphAreaX2 - $AxisSettings["Margin"],
                            $AxisPos["B"],
                            ["R" => $AxisR, "G" => $AxisG, "B" => $AxisB, "Alpha" => $AxisAlpha]
                        );
                    } else {
                        $FloatingOffset = 0;
                        $this->pChartObject->drawLine(
                            $this->pChartObject->GraphAreaX1,
                            $AxisPos["B"],
                            $this->pChartObject->GraphAreaX2,
                            $AxisPos["B"],
                            ["R" => $AxisR, "G" => $AxisG, "B" => $AxisB, "Alpha" => $AxisAlpha]
                        );
                    }

                    if ($DrawArrows) {
                        $this->pChartObject->drawArrow(
                            $this->pChartObject->GraphAreaX2 - $AxisSettings["Margin"],
                            $AxisPos["B"],
                            $this->pChartObject->GraphAreaX2 + ($ArrowSize * 2),
                            $AxisPos["B"],
                            ["FillR" => $AxisR, "FillG" => $AxisG, "FillB" => $AxisB, "Size" => $ArrowSize]
                        );
                    }

                    $Width = ($this->pChartObject->GraphAreaX2 - $this->pChartObject->GraphAreaX1)
                        - $AxisSettings["Margin"] * 2
                    ;
                    $Step = $Width / $AxisSettings["Rows"];
                    $SubTicksSize = $Step / 2;
                    $MaxBottom = $AxisPos["B"];
                    $LastX = null;
                    for ($i = 0; $i <= $AxisSettings["Rows"]; $i++) {
                        $XPos = $this->pChartObject->GraphAreaX1 + $AxisSettings["Margin"] + $Step * $i;
                        $YPos = $AxisPos["B"];
                        $Value = $this->pChartObject->scaleFormat(
                            $AxisSettings["ScaleMin"] + $AxisSettings["RowHeight"] * $i,
                            $AxisSettings["Display"],
                            $AxisSettings["Format"],
                            $AxisSettings["Unit"]
                        );

                        if ($i % 2 == 1) {
                            $BGColor = [
                                "R" => $BackgroundR1,
                                "G" => $BackgroundG1,
                                "B" => $BackgroundB1,
                                "Alpha" => $BackgroundAlpha1
                            ];
                        } else {
                            $BGColor = [
                                "R" => $BackgroundR2,
                                "G" => $BackgroundG2,
                                "B" => $BackgroundB2,
                                "Alpha" => $BackgroundAlpha2
                            ];
                        }
                        if ($LastX != null
                            && $CycleBackground
                            && ($DrawXLines == ALL || in_array($AxisID, $DrawXLines))
                        ) {
                            $this->pChartObject->drawFilledRectangle(
                                $LastX,
                                $this->pChartObject->GraphAreaY1 + $FloatingOffset,
                                $XPos,
                                $this->pChartObject->GraphAreaY2 - $FloatingOffset,
                                $BGColor
                            );
                        }

                        if ($DrawXLines == ALL || in_array($AxisID, $DrawXLines)) {
                            $this->pChartObject->drawLine(
                                $XPos,
                                $this->pChartObject->GraphAreaY1 + $FloatingOffset,
                                $XPos,
                                $this->pChartObject->GraphAreaY2 - $FloatingOffset,
                                [
                                    "R" => $GridR,
                                    "G" => $GridG,
                                    "B" => $GridB,
                                    "Alpha" => $GridAlpha,
                                    "Ticks" => $GridTicks
                                ]
                            );
                        }
                        if ($DrawSubTicks && $i != $AxisSettings["Rows"]) {
                            $this->pChartObject->drawLine(
                                $XPos + $SubTicksSize,
                                $YPos - $InnerSubTickWidth,
                                $XPos + $SubTicksSize,
                                $YPos + $OuterSubTickWidth,
                                [
                                    "R" => $SubTickR,
                                    "G" => $SubTickG,
                                    "B" => $SubTickB,
                                    "Alpha" => $SubTickAlpha
                                ]
                            );
                        }
                        $this->pChartObject->drawLine(
                            $XPos,
                            $YPos - $InnerTickWidth,
                            $XPos,
                            $YPos + $OuterTickWidth,
                            ["R" => $TickR, "G" => $TickG, "B" => $TickB, "Alpha" => $TickAlpha]
                        );
                        $Bounds = $this->pChartObject->drawText(
                            $XPos,
                            $YPos + $OuterTickWidth + $LabelOffset,
                            $Value,
                            ["Angle" => $XLabelsRotation, "Align" => $LabelAlign]
                        );
                        $TxtBottom = $YPos + 2 + $OuterTickWidth + 2 + ($Bounds[0]["Y"] - $Bounds[2]["Y"]);
                        $MaxBottom = max($MaxBottom, $TxtBottom);

                        $LastX = $XPos;
                    }

                    if (isset($AxisSettings["Name"])) {
                        $YPos = $MaxBottom + 2;
                        $XPos = $this->pChartObject->GraphAreaX1
                            + ($this->pChartObject->GraphAreaX2 - $this->pChartObject->GraphAreaX1) / 2
                        ;
                        $Bounds = $this->pChartObject->drawText(
                            $XPos,
                            $YPos,
                            $AxisSettings["Name"],
                            ["Align" => TEXT_ALIGN_TOPMIDDLE]
                        );
                        $MaxBottom = $Bounds[0]["Y"];

                        $this->pDataObject->Data["GraphArea"]["Y2"] = $MaxBottom + $this->pChartObject->FontSize;
                    }

                    $AxisPos["B"] = $MaxBottom + $ScaleSpacing;
                } elseif ($AxisSettings["Position"] == AXIS_POSITION_TOP) {
                    if ($XLabelsRotation == 0) {
                        $LabelAlign = TEXT_ALIGN_BOTTOMMIDDLE;
                        $LabelOffset = 2;
                    }
                    if ($XLabelsRotation > 0 && $XLabelsRotation < 190) {
                        $LabelAlign = TEXT_ALIGN_MIDDLELEFT;
                        $LabelOffset = 2;
                    }
                    if ($XLabelsRotation == 180) {
                        $LabelAlign = TEXT_ALIGN_TOPMIDDLE;
                        $LabelOffset = 5;
                    }
                    if ($XLabelsRotation > 180 && $XLabelsRotation < 360) {
                        $LabelAlign = TEXT_ALIGN_MIDDLERIGHT;
                        $LabelOffset = 5;
                    }

                    if ($Floating) {
                        $FloatingOffset = $YMargin;
                        $this->pChartObject->drawLine(
                            $this->pChartObject->GraphAreaX1 + $AxisSettings["Margin"],
                            $AxisPos["T"],
                            $this->pChartObject->GraphAreaX2 - $AxisSettings["Margin"],
                            $AxisPos["T"],
                            ["R" => $AxisR, "G" => $AxisG, "B" => $AxisB, "Alpha" => $AxisAlpha]
                        );
                    } else {
                        $FloatingOffset = 0;
                        $this->pChartObject->drawLine(
                            $this->pChartObject->GraphAreaX1,
                            $AxisPos["T"],
                            $this->pChartObject->GraphAreaX2,
                            $AxisPos["T"],
                            ["R" => $AxisR, "G" => $AxisG, "B" => $AxisB, "Alpha" => $AxisAlpha]
                        );
                    }

                    if ($DrawArrows) {
                        $this->pChartObject->drawArrow(
                            $this->pChartObject->GraphAreaX2 - $AxisSettings["Margin"],
                            $AxisPos["T"],
                            $this->pChartObject->GraphAreaX2 + ($ArrowSize * 2),
                            $AxisPos["T"],
                            [
                                "FillR" => $AxisR,
                                "FillG" => $AxisG,
                                "FillB" => $AxisB,
                                "Size" => $ArrowSize
                            ]
                        );
                    }

                    $Width = ($this->pChartObject->GraphAreaX2 - $this->pChartObject->GraphAreaX1)
                        - $AxisSettings["Margin"] * 2
                    ;
                    $Step = $Width / $AxisSettings["Rows"];
                    $SubTicksSize = $Step / 2;
                    $MinTop = $AxisPos["T"];
                    $LastX = null;
                    for ($i = 0; $i <= $AxisSettings["Rows"]; $i++) {
                        $XPos = $this->pChartObject->GraphAreaX1 + $AxisSettings["Margin"] + $Step * $i;
                        $YPos = $AxisPos["T"];
                        $Value = $this->pChartObject->scaleFormat(
                            $AxisSettings["ScaleMin"] + $AxisSettings["RowHeight"] * $i,
                            $AxisSettings["Display"],
                            $AxisSettings["Format"],
                            $AxisSettings["Unit"]
                        );

                        if ($i % 2 == 1) {
                            $BGColor = [
                                "R" => $BackgroundR1,
                                "G" => $BackgroundG1,
                                "B" => $BackgroundB1,
                                "Alpha" => $BackgroundAlpha1
                            ];
                        } else {
                            $BGColor = [
                                "R" => $BackgroundR2,
                                "G" => $BackgroundG2,
                                "B" => $BackgroundB2,
                                "Alpha" => $BackgroundAlpha2
                            ];
                        }
                        if ($LastX != null
                            && $CycleBackground
                            && ($DrawXLines == ALL || in_array($AxisID, $DrawXLines))
                        ) {
                            $this->pChartObject->drawFilledRectangle(
                                $LastX,
                                $this->pChartObject->GraphAreaY1 + $FloatingOffset,
                                $XPos,
                                $this->pChartObject->GraphAreaY2 - $FloatingOffset,
                                $BGColor
                            );
                        }

                        if ($DrawXLines == ALL || in_array($AxisID, $DrawXLines)) {
                            $this->pChartObject->drawLine(
                                $XPos,
                                $this->pChartObject->GraphAreaY1 + $FloatingOffset,
                                $XPos,
                                $this->pChartObject->GraphAreaY2 - $FloatingOffset,
                                [
                                    "R" => $GridR,
                                    "G" => $GridG,
                                    "B" => $GridB,
                                    "Alpha" => $GridAlpha,
                                    "Ticks" => $GridTicks
                                ]
                            );
                        }

                        if ($DrawSubTicks && $i != $AxisSettings["Rows"]) {
                            $this->pChartObject->drawLine(
                                $XPos + $SubTicksSize,
                                $YPos - $OuterSubTickWidth,
                                $XPos + $SubTicksSize,
                                $YPos + $InnerSubTickWidth,
                                [
                                    "R" => $SubTickR,
                                    "G" => $SubTickG,
                                    "B" => $SubTickB,
                                    "Alpha" => $SubTickAlpha
                                ]
                            );
                        }
                        $this->pChartObject->drawLine(
                            $XPos,
                            $YPos - $OuterTickWidth,
                            $XPos,
                            $YPos + $InnerTickWidth,
                            ["R" => $TickR, "G" => $TickG, "B" => $TickB, "Alpha" => $TickAlpha]
                        );
                        $Bounds = $this->pChartObject->drawText(
                            $XPos,
                            $YPos - $OuterTickWidth - $LabelOffset,
                            $Value,
                            ["Angle" => $XLabelsRotation, "Align" => $LabelAlign]
                        );
                        $TxtBox = $YPos - $OuterTickWidth - 4 - ($Bounds[0]["Y"] - $Bounds[2]["Y"]);
                        $MinTop = min($MinTop, $TxtBox);

                        $LastX = $XPos;
                    }

                    if (isset($AxisSettings["Name"])) {
                        $YPos = $MinTop - 2;
                        $XPos = $this->pChartObject->GraphAreaX1
                            + ($this->pChartObject->GraphAreaX2 - $this->pChartObject->GraphAreaX1) / 2
                        ;
                        $Bounds = $this->pChartObject->drawText(
                            $XPos,
                            $YPos,
                            $AxisSettings["Name"],
                            ["Align" => TEXT_ALIGN_BOTTOMMIDDLE]
                        );
                        $MinTop = $Bounds[2]["Y"];

                        $this->pDataObject->Data["GraphArea"]["Y1"] = $MinTop;
                    }

                    $AxisPos["T"] = $MinTop - $ScaleSpacing;
                }
            } elseif ($AxisSettings["Identity"] == AXIS_Y) {
                if ($AxisSettings["Position"] == AXIS_POSITION_LEFT) {
                    if ($Floating) {
                        $FloatingOffset = $XMargin;
                        $this->pChartObject->drawLine(
                            $AxisPos["L"],
                            $this->pChartObject->GraphAreaY1 + $AxisSettings["Margin"],
                            $AxisPos["L"],
                            $this->pChartObject->GraphAreaY2 - $AxisSettings["Margin"],
                            ["R" => $AxisR, "G" => $AxisG, "B" => $AxisB, "Alpha" => $AxisAlpha]
                        );
                    } else {
                        $FloatingOffset = 0;
                        $this->pChartObject->drawLine(
                            $AxisPos["L"],
                            $this->pChartObject->GraphAreaY1,
                            $AxisPos["L"],
                            $this->pChartObject->GraphAreaY2,
                            ["R" => $AxisR, "G" => $AxisG, "B" => $AxisB, "Alpha" => $AxisAlpha]
                        );
                    }

                    if ($DrawArrows) {
                        $this->pChartObject->drawArrow(
                            $AxisPos["L"],
                            $this->pChartObject->GraphAreaY1 + $AxisSettings["Margin"],
                            $AxisPos["L"],
                            $this->pChartObject->GraphAreaY1 - ($ArrowSize * 2),
                            [
                                "FillR" => $AxisR,
                                "FillG" => $AxisG,
                                "FillB" => $AxisB,
                                "Size" => $ArrowSize
                            ]
                        );
                    }

                    $Height = ($this->pChartObject->GraphAreaY2 - $this->pChartObject->GraphAreaY1)
                        - $AxisSettings["Margin"] * 2
                    ;
                    $Step = $Height / $AxisSettings["Rows"];
                    $SubTicksSize = $Step / 2;
                    $MinLeft = $AxisPos["L"];
                    $LastY = null;
                    for ($i = 0; $i <= $AxisSettings["Rows"]; $i++) {
                        $YPos = $this->pChartObject->GraphAreaY2 - $AxisSettings["Margin"] - $Step * $i;
                        $XPos = $AxisPos["L"];
                        $Value = $this->pChartObject->scaleFormat(
                            $AxisSettings["ScaleMin"] + $AxisSettings["RowHeight"] * $i,
                            $AxisSettings["Display"],
                            $AxisSettings["Format"],
                            $AxisSettings["Unit"]
                        );

                        if ($i % 2 == 1) {
                            $BGColor = [
                                "R" => $BackgroundR1,
                                "G" => $BackgroundG1,
                                "B" => $BackgroundB1,
                                "Alpha" => $BackgroundAlpha1
                            ];
                        } else {
                            $BGColor = [
                                "R" => $BackgroundR2,
                                "G" => $BackgroundG2,
                                "B" => $BackgroundB2,
                                "Alpha" => $BackgroundAlpha2
                            ];
                        }
                        if ($LastY != null
                            && $CycleBackground
                            && ($DrawYLines == ALL || in_array($AxisID, $DrawYLines))
                        ) {
                            $this->pChartObject->drawFilledRectangle(
                                $this->pChartObject->GraphAreaX1 + $FloatingOffset,
                                $LastY,
                                $this->pChartObject->GraphAreaX2 - $FloatingOffset,
                                $YPos,
                                $BGColor
                            );
                        }

                        if (($YPos != $this->pChartObject->GraphAreaY1 && $YPos != $this->pChartObject->GraphAreaY2)
                            && ($DrawYLines == ALL || in_array($AxisID, $DrawYLines))
                        ) {
                            $this->pChartObject->drawLine(
                                $this->pChartObject->GraphAreaX1 + $FloatingOffset,
                                $YPos,
                                $this->pChartObject->GraphAreaX2 - $FloatingOffset,
                                $YPos,
                                [
                                    "R" => $GridR,
                                    "G" => $GridG,
                                    "B" => $GridB,
                                    "Alpha" => $GridAlpha,
                                    "Ticks" => $GridTicks
                                ]
                            );
                        }

                        if ($DrawSubTicks && $i != $AxisSettings["Rows"]) {
                            $this->pChartObject->drawLine(
                                $XPos - $OuterSubTickWidth,
                                $YPos - $SubTicksSize,
                                $XPos + $InnerSubTickWidth,
                                $YPos - $SubTicksSize,
                                [
                                    "R" => $SubTickR,
                                    "G" => $SubTickG,
                                    "B" => $SubTickB,
                                    "Alpha" => $SubTickAlpha
                                ]
                            );
                        }
                        $this->pChartObject->drawLine(
                            $XPos - $OuterTickWidth,
                            $YPos,
                            $XPos + $InnerTickWidth,
                            $YPos,
                            ["R" => $TickR, "G" => $TickG, "B" => $TickB, "Alpha" => $TickAlpha]
                        );
                        $Bounds = $this->pChartObject->drawText(
                            $XPos - $OuterTickWidth - 2,
                            $YPos,
                            $Value,
                            ["Align" => TEXT_ALIGN_MIDDLERIGHT]
                        );
                        $TxtLeft = $XPos - $OuterTickWidth - 2 - ($Bounds[1]["X"] - $Bounds[0]["X"]);
                        $MinLeft = min($MinLeft, $TxtLeft);

                        $LastY = $YPos;
                    }

                    if (isset($AxisSettings["Name"])) {
                        $XPos = $MinLeft - 2;
                        $YPos = $this->pChartObject->GraphAreaY1
                            + ($this->pChartObject->GraphAreaY2 - $this->pChartObject->GraphAreaY1) / 2
                        ;
                        $Bounds = $this->pChartObject->drawText(
                            $XPos,
                            $YPos,
                            $AxisSettings["Name"],
                            ["Align" => TEXT_ALIGN_BOTTOMMIDDLE, "Angle" => 90]
                        );
                        $MinLeft = $Bounds[2]["X"];

                        $this->pDataObject->Data["GraphArea"]["X1"] = $MinLeft;
                    }

                    $AxisPos["L"] = $MinLeft - $ScaleSpacing;
                } elseif ($AxisSettings["Position"] == AXIS_POSITION_RIGHT) {
                    if ($Floating) {
                        $FloatingOffset = $XMargin;
                        $this->pChartObject->drawLine(
                            $AxisPos["R"],
                            $this->pChartObject->GraphAreaY1 + $AxisSettings["Margin"],
                            $AxisPos["R"],
                            $this->pChartObject->GraphAreaY2 - $AxisSettings["Margin"],
                            ["R" => $AxisR, "G" => $AxisG, "B" => $AxisB, "Alpha" => $AxisAlpha]
                        );
                    } else {
                        $FloatingOffset = 0;
                        $this->pChartObject->drawLine(
                            $AxisPos["R"],
                            $this->pChartObject->GraphAreaY1,
                            $AxisPos["R"],
                            $this->pChartObject->GraphAreaY2,
                            ["R" => $AxisR, "G" => $AxisG, "B" => $AxisB, "Alpha" => $AxisAlpha]
                        );
                    }

                    if ($DrawArrows) {
                        $this->pChartObject->drawArrow(
                            $AxisPos["R"],
                            $this->pChartObject->GraphAreaY1 + $AxisSettings["Margin"],
                            $AxisPos["R"],
                            $this->pChartObject->GraphAreaY1 - ($ArrowSize * 2),
                            [
                                "FillR" => $AxisR,
                                "FillG" => $AxisG,
                                "FillB" => $AxisB,
                                "Size" => $ArrowSize
                            ]
                        );
                    }

                    $Height = ($this->pChartObject->GraphAreaY2 - $this->pChartObject->GraphAreaY1)
                        - $AxisSettings["Margin"] * 2
                    ;
                    $Step = $Height / $AxisSettings["Rows"];
                    $SubTicksSize = $Step / 2;
                    $MaxLeft = $AxisPos["R"];
                    $LastY = null;
                    for ($i = 0; $i <= $AxisSettings["Rows"]; $i++) {
                        $YPos = $this->pChartObject->GraphAreaY2 - $AxisSettings["Margin"] - $Step * $i;
                        $XPos = $AxisPos["R"];
                        $Value = $this->pChartObject->scaleFormat(
                            $AxisSettings["ScaleMin"] + $AxisSettings["RowHeight"] * $i,
                            $AxisSettings["Display"],
                            $AxisSettings["Format"],
                            $AxisSettings["Unit"]
                        );

                        if ($i % 2 == 1) {
                            $BGColor = [
                                "R" => $BackgroundR1,
                                "G" => $BackgroundG1,
                                "B" => $BackgroundB1,
                                "Alpha" => $BackgroundAlpha1
                            ];
                        } else {
                            $BGColor = [
                                "R" => $BackgroundR2,
                                "G" => $BackgroundG2,
                                "B" => $BackgroundB2,
                                "Alpha" => $BackgroundAlpha2
                            ];
                        }
                        if ($LastY != null
                            && $CycleBackground
                            && ($DrawYLines == ALL || in_array($AxisID, $DrawYLines))
                        ) {
                            $this->pChartObject->drawFilledRectangle(
                                $this->pChartObject->GraphAreaX1 + $FloatingOffset,
                                $LastY,
                                $this->pChartObject->GraphAreaX2 - $FloatingOffset,
                                $YPos,
                                $BGColor
                            );
                        }

                        if (($YPos != $this->pChartObject->GraphAreaY1
                            && $YPos != $this->pChartObject->GraphAreaY2)
                            && ($DrawYLines == ALL || in_array($AxisID, $DrawYLines))
                        ) {
                            $this->pChartObject->drawLine(
                                $this->pChartObject->GraphAreaX1 + $FloatingOffset,
                                $YPos,
                                $this->pChartObject->GraphAreaX2 - $FloatingOffset,
                                $YPos,
                                [
                                    "R" => $GridR,
                                    "G" => $GridG,
                                    "B" => $GridB,
                                    "Alpha" => $GridAlpha,
                                    "Ticks" => $GridTicks
                                ]
                            );
                        }

                        if ($DrawSubTicks && $i != $AxisSettings["Rows"]) {
                            $this->pChartObject->drawLine(
                                $XPos - $InnerSubTickWidth,
                                $YPos - $SubTicksSize,
                                $XPos + $OuterSubTickWidth,
                                $YPos - $SubTicksSize,
                                [
                                    "R" => $SubTickR,
                                    "G" => $SubTickG,
                                    "B" => $SubTickB,
                                    "Alpha" => $SubTickAlpha
                                ]
                            );
                        }
                        $this->pChartObject->drawLine(
                            $XPos - $InnerTickWidth,
                            $YPos,
                            $XPos + $OuterTickWidth,
                            $YPos,
                            ["R" => $TickR, "G" => $TickG, "B" => $TickB, "Alpha" => $TickAlpha]
                        );
                        $Bounds = $this->pChartObject->drawText(
                            $XPos + $OuterTickWidth + 2,
                            $YPos,
                            $Value,
                            ["Align" => TEXT_ALIGN_MIDDLELEFT]
                        );
                        $TxtLeft = $XPos + $OuterTickWidth + 2 + ($Bounds[1]["X"] - $Bounds[0]["X"]);
                        $MaxLeft = max($MaxLeft, $TxtLeft);

                        $LastY = $YPos;
                    }

                    if (isset($AxisSettings["Name"])) {
                        $XPos = $MaxLeft + 6;
                        $YPos = $this->pChartObject->GraphAreaY1
                            + ($this->pChartObject->GraphAreaY2 - $this->pChartObject->GraphAreaY1) / 2
                        ;
                        $Bounds = $this->pChartObject->drawText(
                            $XPos,
                            $YPos,
                            $AxisSettings["Name"],
                            ["Align" => TEXT_ALIGN_BOTTOMMIDDLE, "Angle" => 270]
                        );
                        $MaxLeft = $Bounds[2]["X"];

                        $this->pDataObject->Data["GraphArea"]["X2"] = $MaxLeft + $this->pChartObject->FontSize;
                    }

                    $AxisPos["R"] = $MaxLeft + $ScaleSpacing;
                }
            }
        }

        $this->pDataObject->saveAxisConfig($Data["Axis"]);
    }
828446
public function drawAreaChart(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;
        $ForceTransparency = isset($Format["ForceTransparency"]) ? $Format["ForceTransparency"] : 25;
        $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"]]);
                $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 ($YZero > $this->GraphAreaY2 - 1) {
                        $YZero = $this->GraphAreaY2 - 1;
                    }

                    $Areas = [];
                    $AreaID = 0;
                    $Areas[$AreaID][] = $this->GraphAreaX1 + $XMargin;
                    if ($AroundZero) {
                        $Areas[$AreaID][] = $YZero;
                    } else {
                        $Areas[$AreaID][] = $this->GraphAreaY2 - 1;
                    }

                    if ($XDivs == 0) {
                        $XStep = ($this->GraphAreaX2 - $this->GraphAreaX1) / 4;
                    } else {
                        $XStep = ($this->GraphAreaX2 - $this->GraphAreaX1 - $XMargin * 2) / $XDivs;
                    }
                    $X = $this->GraphAreaX1 + $XMargin;
                    $LastX = null;
                    $LastY = null;

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

                        if ($Y == VOID && isset($Areas[$AreaID])) {
                            if ($LastX == null) {
                                $Areas[$AreaID][] = $X;
                            } else {
                                $Areas[$AreaID][] = $LastX;
                            }

                            if ($AroundZero) {
                                $Areas[$AreaID][] = $YZero;
                            } else {
                                $Areas[$AreaID][] = $this->GraphAreaY2 - 1;
                            }
                            $AreaID++;
                        } elseif ($Y != VOID) {
                            if (!isset($Areas[$AreaID])) {
                                $Areas[$AreaID][] = $X;
                                if ($AroundZero) {
                                    $Areas[$AreaID][] = $YZero;
                                } else {
                                    $Areas[$AreaID][] = $this->GraphAreaY2 - 1;
                                }
                            }

                            $Areas[$AreaID][] = $X;
                            $Areas[$AreaID][] = $Y;
                        }

                        $LastX = $X;
                        $X = $X + $XStep;
                    }
                    $Areas[$AreaID][] = $LastX;
                    if ($AroundZero) {
                        $Areas[$AreaID][] = $YZero;
                    } else {
                        $Areas[$AreaID][] = $this->GraphAreaY2 - 1;
                    }

                    /* Handle shadows in the areas */
                    if ($this->Shadow) {
                        $ShadowArea = [];
                        foreach ($Areas as $Key => $Points) {
                            $ShadowArea[$Key] = [];
                            foreach ($Points as $Key2 => $Value) {
                                if ($Key2 % 2 == 0) {
                                    $ShadowArea[$Key][] = $Value + $this->ShadowX;
                                } else {
                                    $ShadowArea[$Key][] = $Value + $this->ShadowY;
                                }
                            }
                        }

                        foreach ($ShadowArea as $Key => $Points) {
                            $this->drawPolygonChart(
                                $Points,
                                [
                                    "R" => $this->ShadowR,
                                    "G" => $this->ShadowG,
                                    "B" => $this->ShadowB,
                                    "Alpha" => $this->Shadowa
                                ]
                            );
                        }
                    }

                    $Alpha = $ForceTransparency != null ? $ForceTransparency : $Alpha;
                    $Color = [
                        "R" => $R,
                        "G" => $G,
                        "B" => $B,
                        "Alpha" => $Alpha,
                        "Threshold" => $Threshold
                    ];

                    foreach ($Areas as $Key => $Points) {
                        $this->drawPolygonChart($Points, $Color);
                    }
                } else {
                    if ($YZero < $this->GraphAreaX1 + 1) {
                        $YZero = $this->GraphAreaX1 + 1;
                    }
                    if ($YZero > $this->GraphAreaX2 - 1) {
                        $YZero = $this->GraphAreaX2 - 1;
                    }

                    $Areas = [];
                    $AreaID = 0;
                    if ($AroundZero) {
                        $Areas[$AreaID][] = $YZero;
                    } else {
                        $Areas[$AreaID][] = $this->GraphAreaX1 + 1;
                    }
                    $Areas[$AreaID][] = $this->GraphAreaY1 + $XMargin;

                    if ($XDivs == 0) {
                        $YStep = ($this->GraphAreaY2 - $this->GraphAreaY1) / 4;
                    } else {
                        $YStep = ($this->GraphAreaY2 - $this->GraphAreaY1 - $XMargin * 2) / $XDivs;
                    }
                    $Y = $this->GraphAreaY1 + $XMargin;
                    $LastX = null;
                    $LastY = null;

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

                        if ($X == VOID && isset($Areas[$AreaID])) {
                            if ($AroundZero) {
                                $Areas[$AreaID][] = $YZero;
                            } else {
                                $Areas[$AreaID][] = $this->GraphAreaX1 + 1;
                            }

                            if ($LastY == null) {
                                $Areas[$AreaID][] = $Y;
                            } else {
                                $Areas[$AreaID][] = $LastY;
                            }

                            $AreaID++;
                        } elseif ($X != VOID) {
                            if (!isset($Areas[$AreaID])) {
                                if ($AroundZero) {
                                    $Areas[$AreaID][] = $YZero;
                                } else {
                                    $Areas[$AreaID][] = $this->GraphAreaX1 + 1;
                                }
                                $Areas[$AreaID][] = $Y;
                            }

                            $Areas[$AreaID][] = $X;
                            $Areas[$AreaID][] = $Y;
                        }

                        $LastX = $X;
                        $LastY = $Y;
                        $Y = $Y + $YStep;
                    }
                    if ($AroundZero) {
                        $Areas[$AreaID][] = $YZero;
                    } else {
                        $Areas[$AreaID][] = $this->GraphAreaX1 + 1;
                    }
                    $Areas[$AreaID][] = $LastY;

                    /* Handle shadows in the areas */
                    if ($this->Shadow) {
                        $ShadowArea = [];
                        foreach ($Areas as $Key => $Points) {
                            $ShadowArea[$Key] = [];
                            foreach ($Points as $Key2 => $Value) {
                                if ($Key2 % 2 == 0) {
                                    $ShadowArea[$Key][] = $Value + $this->ShadowX;
                                } else {
                                    $ShadowArea[$Key][] = $Value + $this->ShadowY;
                                }
                            }
                        }

                        foreach ($ShadowArea as $Key => $Points) {
                            $this->drawPolygonChart(
                                $Points,
                                [
                                    "R" => $this->ShadowR,
                                    "G" => $this->ShadowG,
                                    "B" => $this->ShadowB,
                                    "Alpha" => $this->Shadowa
                                ]
                            );
                        }
                    }

                    $Alpha = $ForceTransparency != null ? $ForceTransparency : $Alpha;
                    $Color = ["R" => $R, "G" => $G, "B" => $B, "Alpha" => $Alpha, "Threshold" => $Threshold];

                    foreach ($Areas as $Key => $Points) {
                        $this->drawPolygonChart($Points, $Color);
                    }
                }
            }
        }
    }
1319822
public function draw($target, $format = PlantUML::FORMAT_TXT)
    {
        /** @var ClassMetadata[] $mds */
        $mds = $this->em->getMetadataFactory()->getAllMetadata();

        // Create graph
        $g = new Graph();
        foreach ($mds as $m) {
            $ref = $m->getReflectionClass();
            $mdt = $this->validator->getMetadataFor($ref->getName());
            if ($mdt instanceof ClassMetadata) {
                $box = $g->addBox($ref->getShortName());
                $box->addPlainText(sprintf('class "%s" {', $ref->getShortName()));

                // Properties
                foreach ($mdt->getConstrainedProperties() as $property) {
                    $box->addPlainText(sprintf('.. %s ..', $property));
                    $metadata = $mdt->getPropertyMetadata($property);
                    if (is_array($metadata)) {
                        $metadata = array_shift($metadata);
                    }
                    if ($metadata instanceof PropertyMetadata) {
                        foreach ($metadata->getConstraints() as $constraint) {
                            if ($constraint instanceof Assert\Type) {
                                $box->addPlainText(sprintf('Type("%s")', $constraint->type));
                            } elseif ($constraint instanceof Assert\Length) {
                                if ($constraint->min) {
                                    $box->addPlainText(sprintf('Length(min = %u)', $constraint->min));
                                }
                                if ($constraint->max) {
                                    $box->addPlainText(sprintf('Length(max = %u)', $constraint->max));
                                }
                            } else {
                                $names = explode('\\', get_class($constraint));
                                $box->addPlainText(sprintf('%s()', array_pop($names)));
                            }
                        }
                    }
                }
                $box->addPlainText('}');
            }
        }

        return $this->plantUML->dump($g, $target, $format);
    }
179250
public function mprint($A, $format='%01.2f', $width=2)
    {
        $spacing = '';
        $m = count($A);
        $n = count($A[0]);
        for ($i = 0; $i < $width; $i++) {
            $spacing .= '&nbsp;';
        }
        for ($i = 0; $i < $m; $i++) {
            for ($j = 0; $j < $n; $j++) {
                $formatted = sprintf($format, $A[$i][$j]);
                echo $formatted . $spacing;
            }
            echo '<br />';
        }
    }
146500
public function gchartSteppedAreaChart(\Twig_Environment $env, $data, $id, $width, $height, $title = null, $config = array(), $events = array()) {
        if (!is_null($yLabel)) {
            $vAxis = isset($config['vAxis'])? $config['vAxis']: array();
            $vAxis['title'] = $yLabel;
            $config['vAxis'] = $vAxis;
        }

        return $this->renderGChart($env, $data, $id, 'SteppedAreaChart', $width, $height, $title, $config, false, $events);
    }
1008823
public function drawZoneChart($SerieA, $SerieB, array $Format = [])
    {
        $AxisID = isset($Format["AxisID"]) ? $Format["AxisID"] : 0;
        $LineR = isset($Format["LineR"]) ? $Format["LineR"] : 150;
        $LineG = isset($Format["LineG"]) ? $Format["LineG"] : 150;
        $LineB = isset($Format["LineB"]) ? $Format["LineB"] : 150;
        $LineAlpha = isset($Format["LineAlpha"]) ? $Format["LineAlpha"] : 50;
        $LineTicks = isset($Format["LineTicks"]) ? $Format["LineTicks"] : 1;
        $AreaR = isset($Format["AreaR"]) ? $Format["AreaR"] : 150;
        $AreaG = isset($Format["AreaG"]) ? $Format["AreaG"] : 150;
        $AreaB = isset($Format["AreaB"]) ? $Format["AreaB"] : 150;
        $AreaAlpha = isset($Format["AreaAlpha"]) ? $Format["AreaAlpha"] : 5;

        $this->LastChartLayout = CHART_LAST_LAYOUT_REGULAR;

        $Data = $this->DataSet->getData();
        if (!isset($Data["Series"][$SerieA]["Data"])
            || !isset($Data["Series"][$SerieB]["Data"])
        ) {
            return 0;
        }
        $SerieAData = $Data["Series"][$SerieA]["Data"];
        $SerieBData = $Data["Series"][$SerieB]["Data"];

        list($XMargin, $XDivs) = $this->scaleGetXSettings();

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

        $PosArrayA = $this->scaleComputeY($SerieAData, ["AxisID" => $AxisID]);
        $PosArrayB = $this->scaleComputeY($SerieBData, ["AxisID" => $AxisID]);
        if (count($PosArrayA) != count($PosArrayB)) {
            return 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;
            $LastX = null;
            $LastY = null;

            $LastY1 = null;
            $LastY2 = null;
            $BoundsA = [];
            $BoundsB = [];
            foreach ($PosArrayA as $Key => $Y1) {
                $Y2 = $PosArrayB[$Key];

                $BoundsA[] = $X;
                $BoundsA[] = $Y1;
                $BoundsB[] = $X;
                $BoundsB[] = $Y2;

                $LastX = $X;
                $LastY1 = $Y1;
                $LastY2 = $Y2;

                $X = $X + $XStep;
            }
            $Bounds = array_merge($BoundsA, $this->reversePlots($BoundsB));
            $this->drawPolygonChart(
                $Bounds,
                [
                    "R" => $AreaR,
                    "G" => $AreaG,
                    "B" => $AreaB,
                    "Alpha" => $AreaAlpha
                ]
            );

            for ($i = 0; $i <= count($BoundsA) - 4; $i = $i + 2) {
                $this->drawLine(
                    $BoundsA[$i],
                    $BoundsA[$i + 1],
                    $BoundsA[$i + 2],
                    $BoundsA[$i + 3],
                    [
                        "R" => $LineR,
                        "G" => $LineG,
                        "B" => $LineB,
                        "Alpha" => $LineAlpha,
                        "Ticks" => $LineTicks
                    ]
                );
                $this->drawLine(
                    $BoundsB[$i],
                    $BoundsB[$i + 1],
                    $BoundsB[$i + 2],
                    $BoundsB[$i + 3],
                    [
                        "R" => $LineR,
                        "G" => $LineG,
                        "B" => $LineB,
                        "Alpha" => $LineAlpha,
                        "Ticks" => $LineTicks
                    ]
                );
            }
        } else {
            if ($XDivs == 0) {
                $YStep = ($this->GraphAreaY2 - $this->GraphAreaY1) / 4;
            } else {
                $YStep = ($this->GraphAreaY2 - $this->GraphAreaY1 - $XMargin * 2) / $XDivs;
            }
            $Y = $this->GraphAreaY1 + $XMargin;
            $LastX = null;
            $LastY = null;

            $LastX1 = null;
            $LastX2 = null;
            $BoundsA = [];
            $BoundsB = [];
            foreach ($PosArrayA as $Key => $X1) {
                $X2 = $PosArrayB[$Key];

                $BoundsA[] = $X1;
                $BoundsA[] = $Y;
                $BoundsB[] = $X2;
                $BoundsB[] = $Y;

                $LastY = $Y;
                $LastX1 = $X1;
                $LastX2 = $X2;

                $Y = $Y + $YStep;
            }
            $Bounds = array_merge($BoundsA, $this->reversePlots($BoundsB));
            $this->drawPolygonChart(
                $Bounds,
                ["R" => $AreaR, "G" => $AreaG, "B" => $AreaB, "Alpha" => $AreaAlpha]
            );

            for ($i = 0; $i <= count($BoundsA) - 4; $i = $i + 2) {
                $this->drawLine(
                    $BoundsA[$i],
                    $BoundsA[$i + 1],
                    $BoundsA[$i + 2],
                    $BoundsA[$i + 3],
                    [
                        "R" => $LineR,
                        "G" => $LineG,
                        "B" => $LineB,
                        "Alpha" => $LineAlpha,
                        "Ticks" => $LineTicks
                    ]
                );
                $this->drawLine(
                    $BoundsB[$i],
                    $BoundsB[$i + 1],
                    $BoundsB[$i + 2],
                    $BoundsB[$i + 3],
                    [
                        "R" => $LineR,
                        "G" => $LineG,
                        "B" => $LineB,
                        "Alpha" => $LineAlpha,
                        "Ticks" => $LineTicks
                    ]
                );
            }
        }
    }
922033
public function normalize($object, $format = null, array $context = [])
    {
        $normalized = (array) parent::normalize($object, $format, $context);

        // Do not send redundant API product information to Apigee Edge, the
        // id of a referenced API product is enough.
        foreach ($normalized['product'] as $id => $data) {
            $normalized['product'][$id] = (object) ['id' => $data->id];
        }

        return (object) $normalized;
    }
603647
public function generate(string $subject, string $status, string $color, string $format)
    {
        $badge = new Badge($subject, $status, $color, $format);

        return $this->getRendererForFormat($badge->getFormat())->render($badge);
    }
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;
    }
1374439
public function output($data, $format = null)
    {
        $contentType = $this->outputContentType($format);

        try {
            $content = $this->serializeData($data, $contentType);
        } catch (\UnexpectedValueException $e) {
            if (!isset($format) && isset($this->defaultFormat) && $this->defaultFormat !== $contentType) {
                $this->output($data, $this->defaultFormat); // Try default format instead
                return;
            }
            
            throw $e;
        }

        $this->getResponse()->getBody()->write($content);
    }
890984
public function drawAreaMirror($X, $Y, $Width, $Height, array $Format = [])
    {
        $StartAlpha = isset($Format["StartAlpha"]) ? $Format["StartAlpha"] : 80;
        $EndAlpha = isset($Format["EndAlpha"]) ? $Format["EndAlpha"] : 0;

        $AlphaStep = ($StartAlpha - $EndAlpha) / $Height;

        $Picture = imagecreatetruecolor($this->XSize, $this->YSize);
        imagecopy($Picture, $this->Picture, 0, 0, 0, 0, $this->XSize, $this->YSize);

        for ($i = 1; $i <= $Height; $i++) {
            if ($Y + ($i - 1) < $this->YSize && $Y - $i > 0) {
                imagecopymerge(
                    $Picture,
                    $this->Picture,
                    $X,
                    $Y + ($i - 1),
                    $X,
                    $Y - $i,
                    $Width,
                    1,
                    $StartAlpha - $AlphaStep * $i
                );
            }
        }

        imagecopy($this->Picture, $Picture, 0, 0, 0, 0, $this->XSize, $this->YSize);
    }
719562
public function draw($target, $format = PlantUML::FORMAT_TXT, array $includes = [], array $excludes = [])
    {
        $this->files = [];
        $this->resolvedFiles = [];
        $this->excludes = $excludes;
        $this->includes = $includes;

        // List views
        $path = $this->kernel->getRootDir() . '/Resources/views';
        if ($this->fs->exists($path)) {
            /** @var SplFileInfo[] $appFiles */
            $appFiles = Finder::create()->files()->in($path)->depth('<5');
            foreach ($appFiles as $file) {
                $this->load($file);
            }
        }
        $bundles = $this->kernel->getBundles();
        foreach ($bundles as $bundle) {
            $path = $bundle->getPath() . '/Resources/views';
            if ($this->fs->exists($path)) {
                /** @var SplFileInfo[] $bundleFiles */
                $bundleFiles = Finder::create()->files()->in($path)->depth('<5');
                foreach ($bundleFiles as $file) {
                    $this->load($file, $bundle);
                }
            }
        }
        array_map([$this, 'resolve'], $this->files);

        // Create graph
        $g = new Graph();
        foreach ($this->resolvedFiles as $id => $file) {
            $box = $g->addBox($id);

            // Defined blocks
            if (0 !== count($file['defined_blocks']) || 0 !== count($file['called_blocks'])) {
                $box->addText('blocks');
                if (0 !== count($file['defined_blocks'])) {
                    $box->addText('defined', 1);
                    foreach ($file['defined_blocks'] as $block) {
                        $box->addText($block, 2);
                    }
                }
                if (0 !== count($file['called_blocks'])) {
                    $box->addText('called', 1);
                    foreach ($file['called_blocks'] as $block) {
                        $box->addText($block, 2);
                    }
                }
            }

            // Extends
            foreach ($file['extends'] as $extend) {
                $box->addExtends($extend['id']);
            }

            // Traits
            foreach ($file['uses'] as $use) {
                $box->addText(sprintf('use "%s"', $use['id']));
                if (!empty($use['defined_blocks'])) {
                    $box->addText('defined', 1);
                    foreach ($use['defined_blocks'] as $block) {
                        $box->addText($block, 2);
                    }
                }
                if (!empty($use['called_blocks'])) {
                    $box->addText('called', 1);
                    foreach ($use['called_blocks'] as $block) {
                        $box->addText($block, 2);
                    }
                }
            }

            // Includes
            foreach ($file['includes'] as $include) {
                $box->addText(sprintf('include "%s"', $include['id']));
            }
        }

        return $this->plantUML->dump($g, $target, $format);
    }