public static void AddPieChart(Group elements, float x, float y)
        {
            AddCaptionAndRectangle(elements, "Pie Chart", x, y, 225, 225);

            // Create a chart
            Chart chart = new Chart(x + 10, y + 25, 200, 200, Font.Helvetica, 10, RgbColor.Black);

            // Add a plot area to the chart
            PlotArea plotArea = chart.PlotAreas.Add(50, 50, 300, 300);

            // Create the Header title and add it to the chart
            Title tTitle = new Title("Website Visitors (in millions)");

            chart.HeaderTitles.Add(tTitle);

            // Create a scalar datalabel
            ScalarDataLabel da = new ScalarDataLabel(true, false, false);

            // Create autogradient colors
            AutoGradient autogradient1 = new AutoGradient(90f, CmykColor.Red, CmykColor.IndianRed);
            AutoGradient autogradient2 = new AutoGradient(90f, CmykColor.Green, CmykColor.YellowGreen);
            AutoGradient autogradient3 = new AutoGradient(90f, CmykColor.Blue, CmykColor.LightBlue);

            // Create a pie series
            PieSeries pieSeries = new PieSeries();

            // Set scalar datalabel to the pie series
            pieSeries.DataLabel = da;

            // Add series to the plot area
            plotArea.Series.Add(pieSeries);

            //Add pie series elements to the pie series
            pieSeries.Elements.Add(27, "Website A");
            pieSeries.Elements.Add(19, "Website B");
            pieSeries.Elements.Add(21, "Website C");

            // Assign autogradient colors to series elements
            pieSeries.Elements[0].Color = autogradient1;
            pieSeries.Elements[1].Color = autogradient2;
            pieSeries.Elements[2].Color = autogradient3;
            chart.Legends[0].Visible    = false;
            elements.Add(chart);
        }
        public void AddPieChart(float x, float y, float width, float height, List<Tuple<double, string, string>> piedataseries)
        {
            if (piedataseries == null || piedataseries.Count == 0)
                return;
            y = y - 20;
            var ploatwidth = 250;
            var ploatheight = 250;
            Chart chart = new Chart(x, y, width, height);
            PlotArea plotArea = chart.PlotAreas.Add((width - ploatwidth) / 2 + 50, y, ploatwidth, ploatheight);
            ScalarDataLabel da = new ScalarDataLabel(false, true, false);
            da.FontSize = 7;
            //
            //
            //
            var legendwidth = 300;
            var legendheight = 100;
            chart.AutoLayout = false;
            var legend = chart.Legends.Add(35 + (plotArea.Width - legendheight) / 2, y + ploatheight, legendwidth, legendheight);
            legend.FontSize = 8;
            legend.LabelSpacing = 3;
            chart.Legends.Placement = LegendPlacement.BottomRight;            
            //
            //
            //           
            PieSeries pieSeries = new PieSeries();
            pieSeries.DataLabel = da;
            pieSeries.DataLabelPosition = ScalarDataLabelPosition.OutsideWithConnectors;
            pieSeries.StartAngle = 90;
            pieSeries.PercentageFormat = "0.### %";
            plotArea.Series.Add(pieSeries);
            //
            //
            //

            Action<PieSeriesElement, string, string> paddincenter = (serie, serielabel, serievalue) =>
            {
                if (serie.LegendLabel == null)
                    return;
                var escapewidth = 2.224;
                var const_width = 250;
                if (serie.LegendLabel.RequiredWidth < const_width)
                {
                    var width_requiered = const_width - serie.LegendLabel.RequiredWidth;
                    var escape_requiered = width_requiered / escapewidth;

                    var padright = serielabel.PadRight((int)escape_requiered + serielabel.Length, ' ');
                    serie.LegendLabel.Text = string.Format("{0}{1} €", padright, serievalue);
                }
            };

            piedataseries = piedataseries.OrderByDescending(x1 => x1.Item1).ToList();

            foreach (var tuplepieserie in piedataseries)
            {
                var labelserie = tuplepieserie.Item2.Length > 40 ? tuplepieserie.Item2.Substring(0, 40) : tuplepieserie.Item2;
                PieSeriesElement serieelt =
                    new PieSeriesElement(
                    (float)tuplepieserie.Item1, string.Format("{0}{1}",
                    labelserie, tuplepieserie.Item1.ToString("n", new System.Globalization.NumberFormatInfo { NumberGroupSeparator = " " })),
                    new WebColor(tuplepieserie.Item3));
                
                pieSeries.Elements.Add(serieelt);
                paddincenter(serieelt, labelserie, tuplepieserie.Item1.ToString("n", new System.Globalization.NumberFormatInfo { NumberGroupSeparator = " " }));
                var _width = pieSeries.Elements[0].PlotArea.Width;
            }
            
            _currentPage.Elements.Add(chart);
        }