public static void AddMultiTypeSeriesChart(Group elements, float x, float y)
        {
            AddCaptionAndRectangle(elements, "Plot Area With Different Kinds of Series and Multiple Axis ", x, y, 650, 410);

            // Create a chart
            Chart chart = new Chart(x + 25, y + 37, 600, 350);

            // Create a Auto gradient and set it to chart back ground color
            AutoGradient autogradient = new AutoGradient(90f, CmykColor.LightYellow, CmykColor.LightSkyBlue);

            chart.BackgroundColor = autogradient;

            // Create a plot area
            PlotArea plotArea = chart.PrimaryPlotArea;

            // Create header titles and add it to the chart
            Title title1 = new Title("Company Sales and Website Visitors ");

            title1.Align = Align.Left;
            chart.HeaderTitles.Add(title1);

            // Create a indexed line series and add values to it
            IndexedLineSeries lineSeries1 = new IndexedLineSeries("Website A Visitors");

            lineSeries1.Values.Add(new float[] { 1.5f, 8, 7.5f, 5.5f });
            lineSeries1.Color = RgbColor.DarkBlue;
            IndexedLineSeries lineSeries2 = new IndexedLineSeries("Website B Visitors");

            lineSeries2.Color = RgbColor.LimeGreen;
            lineSeries2.Values.Add(new float[] { 4, 3, 7, 7.5f });

            // Create markers and add it to the series
            Marker marker1 = Marker.GetTriangle(7);

            lineSeries1.Marker = marker1;
            Marker marker2 = Marker.GetCircle(7);

            lineSeries2.Marker = marker2;

            // Add indexed line series to the plot area
            plotArea.Series.Add(lineSeries1);
            plotArea.Series.Add(lineSeries2);

            // Create a NumericYAxis and a title to it
            NumericYAxis numericyaxis1 = new NumericYAxis();

            numericyaxis1.AnchorType = YAxisAnchorType.Right;
            numericyaxis1.Titles.Add(new Title("Sales (in $ millions)"));
            numericyaxis1.Interval = 1;

            // Create a indexed column series and add values to it
            IndexedColumnSeries columnSeries1 = new IndexedColumnSeries("Company A Sales", numericyaxis1);

            columnSeries1.Values.Add(new float[] { 2, 10, 14, 17 });
            columnSeries1.Color = RgbColor.Blue;
            IndexedColumnSeries columnSeries2 = new IndexedColumnSeries("Company B Sales", numericyaxis1);

            columnSeries2.Color = RgbColor.Lime;
            columnSeries2.Values.Add(new float[] { 7, 4, 10, 15 });

            // Create a bar column value position data label
            BarColumnValuePositionDataLabel barColumnValuePositionDataLabel = new BarColumnValuePositionDataLabel(true, true, false);

            columnSeries1.DataLabel = barColumnValuePositionDataLabel;
            barColumnValuePositionDataLabel.FontSize = 7;
            columnSeries1.DataLabel.Prefix           = "(";
            columnSeries1.DataLabel.Suffix           = ")";
            columnSeries2.DataLabel = barColumnValuePositionDataLabel;

            // Add indexed column series to the plot area
            plotArea.Series.Add(columnSeries1);
            plotArea.Series.Add(columnSeries2);
            YAxisGridLines minorGridLines = new YAxisGridLines();

            minorGridLines.LineStyle = LineStyle.Dots;
            plotArea.YAxes.DefaultNumericAxis.MajorGridLines = new YAxisGridLines();
            plotArea.YAxes.DefaultNumericAxis.MinorGridLines = minorGridLines;
            plotArea.XAxes.DefaultIndexedAxis.MajorGridLines = new XAxisGridLines();
            plotArea.YAxes.DefaultNumericAxis.MinorTickMarks = new YAxisTickMarks();
            plotArea.YAxes.DefaultNumericAxis.MajorTickMarks = new YAxisTickMarks();

            // Add title to Yaxis
            lineSeries1.YAxis.Titles.Add(new Title("Visitors (in millions)"));

            //Adding AxisLabels to the XAxis
            columnSeries1.XAxis.Labels.Add(new IndexedXAxisLabel("Q1", 0));
            columnSeries1.XAxis.Labels.Add(new IndexedXAxisLabel("Q2", 1));
            columnSeries1.XAxis.Labels.Add(new IndexedXAxisLabel("Q3", 2));
            columnSeries1.XAxis.Labels.Add(new IndexedXAxisLabel("Q4", 3));
            chart.Legends[0].BorderStyle     = LineStyle.Dots;
            chart.Legends[0].BorderColor     = RgbColor.Black;
            chart.Legends[0].BackgroundColor = CmykColor.Lavender;
            elements.Add(chart);
        }
        public string AddLineChart(
            float x,
            ref float y,
            float width,
            float height,
            string[] seriename,
            SortedDictionary<DateTime, double> valorisationdata,
            Dictionary<DateTime, Tuple<double, double>> investissementandretraitdata = null,
            System.Action afficheLabelFunction = null,
            string datereleve=""
            )
        {
            const string axeformat = "0.### 'K€'";
            var logdata = string.Empty;
            var labelFont = 9;

            if ((valorisationdata == null || valorisationdata.Count == 0) &&
                (investissementandretraitdata == null || investissementandretraitdata.Count == 0))
            {
                return logdata;
            }
            var sumvalorisation = valorisationdata.Sum(c => c.Value);
            var summvt = investissementandretraitdata == null || investissementandretraitdata.Count == 0 ? 0 : investissementandretraitdata.Sum(d => d.Value.Item1 + d.Value.Item2);
            if (sumvalorisation == 0 && summvt == 0)
                return logdata;

            if (afficheLabelFunction != null)
                afficheLabelFunction();
            y += 40;
            Chart chart = new Chart(x, y, width, height);
            chart.Legends.Placement = LegendPlacement.TopCenter;

            PlotArea plotArea = chart.PrimaryPlotArea;
            Legend legend = chart.Legends.Add(2, 3, 10, 10);
            legend.Visible = false;

            var legendwidth = 100;
            chart.LeftPadding = -45;
            //
            //
            //
            var colorValorisation = "#094DEE";//9FCECE
            //var colorInvestissement = "#983298";
            //var colorRetrait = "#E0B64B";

            //
            //
            //
            var yAxisValorisation = new NumericYAxis();
            yAxisValorisation.AnchorType = YAxisAnchorType.Left;

            plotArea.YAxes.Add(yAxisValorisation);
            plotArea.YAxes.DefaultNumericAxis = yAxisValorisation;
            //
            //
            //


            IndexedLineSeries lineValorisation = new IndexedLineSeries(seriename[0], null, yAxisValorisation, new WebColor(colorValorisation));
            var _abs = x - 20;
            AddRectangle(_abs, y - 15, 10, 2, colorValorisation);
            AddLabelArialBold(seriename[0], _abs + 15, y - 20, 200, 50, labelFont);
            //
            //
            //
            IndexedColumnSeries lineInvestisstement = null;
            IndexedColumnSeries lineRetrait = null;
            plotArea.Series.Add(lineValorisation);
            //
            //
            //
            var dateReleve = valorisationdata.Keys.Last();
            DateTime.TryParseExact(datereleve, "dd/MM/yyyy",
                   CultureInfo.InvariantCulture,
                   DateTimeStyles.None, out dateReleve);
            //
            if (datereleve != "")
            {
                var tmpDictionnary = valorisationdata.Where(x1 => x1.Key <= dateReleve).ToDictionary(xa => xa.Key, xa => xa.Value);
                if (tmpDictionnary.Count > 0)
                {
                    valorisationdata.Clear();
                    foreach (var newVal in tmpDictionnary)
                    {
                        valorisationdata.Add(newVal.Key, newVal.Value);
                    }
                }
            }
            //
            //
            //
            #region Legend
            var dateabcisses = new List<DateTime>();
            if (seriename.Length == 3 && investissementandretraitdata != null && investissementandretraitdata.Count > 0)
            {               
                //
                //si le montant de l'investissement et de retrait est inferieur à 10% de la valeur de compte
                //
                var valorisationmax10pourcent = valorisationdata.Values.Max() * 10 / 100;
                var invesorretraitmax = Math.Max(investissementandretraitdata.Values.Max(x1 => x1.Item1), investissementandretraitdata.Values.Max(x2 => x2.Item2));
                var legendinvestX = x + 425;

                var greenColor = new RgbColor(1, 126, 3);
                var redColor = new RgbColor(254, 2, 1);

                AddRectangle(legendinvestX, y - 18, 10, 10, greenColor);
                AddLabelArialBold(seriename[1], legendinvestX + 15, y - 19, 200, 50, labelFont);
                AddRectangle(legendinvestX, y, 10, 10, redColor);
                AddLabelArialBold(seriename[2], legendinvestX + 15, y - 1, 200, 50, labelFont);

                if (invesorretraitmax < valorisationmax10pourcent)
                {
                    //Investissement = #983298
                    //Retrait = #E0B64B
                    //Valorisation = #9FCECE
                    //
                    var yAxisInvestiRetrait = new NumericYAxis();
                    yAxisInvestiRetrait.AnchorType = YAxisAnchorType.Right;
                    plotArea.YAxes.Add(yAxisInvestiRetrait);

                    lineInvestisstement = new IndexedColumnSeries(seriename[1], null, yAxisInvestiRetrait, greenColor);
                    lineRetrait = new IndexedColumnSeries(seriename[2], null, yAxisInvestiRetrait, redColor);
                    //
                    //
                    //
                    lineInvestisstement.YAxis.Labels.Font = RobotoLightBold;
                    lineInvestisstement.YAxis.Labels.FontSize = 7;
                }
                else
                {
                    lineInvestisstement = new IndexedColumnSeries(seriename[1], greenColor);
                    lineRetrait = new IndexedColumnSeries(seriename[2], redColor);
                }


                //
                //
                //
                if (investissementandretraitdata != null && investissementandretraitdata.Count > 0)
                {
                    //foreach (var line in investissementandretraitdata)
                    //{
                    //    dateabcisses.Add(line.Key);
                    //}
                }

                plotArea.Series.Add(lineInvestisstement);
                plotArea.Series.Add(lineRetrait);

                lineInvestisstement.YAxis.LabelOffset = 8;
                lineRetrait.YAxis.LabelOffset = 8;
                lineInvestisstement.YAxis.LabelFormat = axeformat;
                lineRetrait.YAxis.LabelFormat = axeformat;
                //
                //
                //
            }
            #endregion
            //
            //
            //
            #region Add Values
            var affichageparmois = false;
            var diffMonths = 0;
            var max_Month = 36;
            if (valorisationdata != null && valorisationdata.Count > 0)
            {
                var dtDebut = valorisationdata.Keys.First();
                var dtFin = dateReleve == DateTime.MinValue ? valorisationdata.Keys.Last() : dateReleve;
                diffMonths = (dtFin.Month + dtFin.Year * 12) - (dtDebut.Month + dtDebut.Year * 12) + 1;
                if (diffMonths >= max_Month)
                {
                    affichageparmois = true;
                    //si nombre de mois > max_Month , on affiche les données des max_Month mois le plus proche de nos jour
                    #region par mois
                    //
                    //
                    //
                    if (diffMonths > max_Month)
                    {
                        dtDebut = dtFin.AddMonths(-max_Month);
                    }
                    //
                    //Limiter à max_Month mois
                    //
                    dtDebut = new DateTime(dtDebut.Year, dtDebut.Month, 1);
                    while (dtDebut.Year != dtFin.Year || dtDebut.Month != dtFin.Month)
                    {
                        if (!dateabcisses.Contains(dtDebut))
                            dateabcisses.Add(dtDebut);
                        dtDebut = dtDebut.AddMonths(1);
                    }
                    if (!dateabcisses.Contains(dtDebut))
                        dateabcisses.Add(dtDebut);
                    #endregion
                }
                else
                {

                    if (diffMonths == 1)
                    {

                        if (valorisationdata.Keys.Count > 4)
                            dateabcisses.AddRange(valorisationdata.Keys);
                        else
                        {
                            var date_temp = valorisationdata.Keys.ToList();
                            var days_apresenter = date_temp.Select(x5 => x5.Day).ToList();
                            var rd = new Random();
                            for (var j = days_apresenter.Count; j < 5; j++)
                            {
                                int day = days_apresenter[0];
                                while (days_apresenter.Contains(day))
                                {
                                    day = rd.Next(1, 28);
                                }
                                days_apresenter.Add(day);

                                var dt = new DateTime(date_temp[0].Year, date_temp[0].Month, day);
                                if (!dateabcisses.Contains(dt))
                                    dateabcisses.Add(dt);
                            }
                            dateabcisses.AddRange(date_temp);//5 points
                        }
                    }
                    else
                    {
                        //si nombre de mois < max_Month (ex : 7), on regarde combien de point dans un mois on doit afficher pour avoir max_Month
                        var nbrePointafficherparmois = (diffMonths < 4) ? 12 : (int)max_Month / diffMonths;
                        var restePointafficher = (diffMonths < 4) ? 0 : max_Month % diffMonths;
                        //
                        //Recuperer les mois qui n'ont pas de valorisation
                        //
                        var date_temp = valorisationdata.Keys.ToList();
                        for (var k = 0; k < diffMonths; k++)
                        {
                            var currentdate = dtDebut.AddMonths(k);
                            var firstdatemonth = valorisationdata.Keys.FirstOrDefault(x1 => x1.Year == currentdate.Year && x1.Month == currentdate.Month);
                            if (firstdatemonth == DateTime.MinValue)
                            {
                                date_temp.Add(new DateTime(currentdate.Year, currentdate.Month, 1));
                            }
                        }
                        //
                        //
                        //
                        var rd = new Random();
                        date_temp = date_temp.OrderByDescending(x2 => x2).ToList();
                        for (var k = 0; k < diffMonths; k++)
                        {
                            var pt_aafficher = (k < diffMonths - restePointafficher) ? nbrePointafficherparmois : nbrePointafficherparmois + 1;
                            var date_apresenter = date_temp.Where(x1 => x1.Year == dtDebut.Year && x1.Month == dtDebut.Month).Take(pt_aafficher).ToList();

                            if (date_apresenter.Count < pt_aafficher)
                            {
                                var days_apresenter = date_apresenter.Select(x5 => x5.Day).ToList();
                                for (var j = date_apresenter.Count; j < pt_aafficher; j++)
                                {
                                    int day = days_apresenter[0];
                                    while (days_apresenter.Contains(day))
                                    {
                                        day = rd.Next(1, 28);
                                    }
                                    days_apresenter.Add(day);

                                    var dt = new DateTime(date_apresenter[0].Year, date_apresenter[0].Month, day);
                                    if (!date_apresenter.Contains(dt))
                                        date_apresenter.Add(dt);
                                }
                            }
                            //Ajouter valorisation
                            dateabcisses.AddRange(date_apresenter);
                            dtDebut = dtDebut.AddMonths(1);
                        }
                    }
                }
                diffMonths = dateabcisses.Count;
            }

            var showcustomdate = (dateabcisses.Count < 9);
            if (dateabcisses.Count > 0)
            {
                lineValorisation.XAxis.Labels.AutoLabels = false;
                lineValorisation.YAxis.Labels.Font = RobotoLightBold;
                lineValorisation.YAxis.Labels.FontSize = 7;

                if (lineInvestisstement != null)
                    lineInvestisstement.XAxis.Labels.AutoLabels = false;
                if (lineRetrait != null)
                    lineRetrait.XAxis.Labels.AutoLabels = false;

                var index = 0;

                dateabcisses = dateabcisses.OrderBy(z => z).ToList();
                var culture = new CultureInfo("fr-Fr");
                var intervalcount = dateabcisses.Count - 1;
                var graphwidth = chart.Width - legendwidth + 50;

                var pas = dateabcisses.Count / 12;
                var rest = dateabcisses.Count % 12;
                pas += (rest > 0) ? 1 : 0;

                var keysOrderDesc = valorisationdata.Keys.OrderByDescending(x1 => x1).ToList();
                var defaulkey = keysOrderDesc.FirstOrDefault(x1 => x1 <= dateabcisses[0]);
                if (defaulkey == DateTime.MinValue)
                    defaulkey = keysOrderDesc.Last();

                double currentvalorisation = valorisationdata[defaulkey];

                var investKeys = investissementandretraitdata != null ? investissementandretraitdata.Keys.OrderByDescending(x1 => x1).ToList() : null;

                if (affichageparmois)
                {
                    //si nombre de mois > max_Month , on affiche les données des max_Month mois le plus proche de nos jour
                    foreach (var dateabs in dateabcisses)
                    {
                        var akey = keysOrderDesc.FirstOrDefault(x1 => x1.Year == dateabs.Year && x1.Month == dateabs.Month);

                        currentvalorisation = (valorisationdata.ContainsKey(akey)) ? valorisationdata[akey] : currentvalorisation;
                        lineValorisation.Values.Add(Convert.ToSingle(currentvalorisation) / 1000);

                        logdata += string.Format(" ({0},{1}) ", dateabs.ToString("MM/yyyy"), currentvalorisation);

                        if (investissementandretraitdata != null && investissementandretraitdata.Count > 0)
                        {
                            var key = investKeys.FirstOrDefault(x1 => x1.Month == dateabs.Month && x1.Year == dateabs.Year);
                            if (key != DateTime.MinValue)
                            {
                                if (lineInvestisstement != null)
                                    lineInvestisstement.Values.Add(Convert.ToSingle(investissementandretraitdata[key].Item1) / 1000);
                                if (lineRetrait != null)
                                    lineRetrait.Values.Add(Convert.ToSingle(investissementandretraitdata[key].Item2) / 1000);
                            }
                            else
                            {
                                if (lineInvestisstement != null)
                                    lineInvestisstement.Values.Add(0);
                                if (lineRetrait != null)
                                    lineRetrait.Values.Add(0);
                            }
                        }
                        //var monthname = culture.DateTimeFormat.GetMonthName(dateabs.Month);
                        //var monthyear = monthname.Length > 3 ?
                        //    string.Format("{0} {1}", culture.DateTimeFormat.GetMonthName(dateabs.Month).Substring(0, 4), dateabs.Year) :
                        //    string.Format("{0} {1}", culture.DateTimeFormat.GetMonthName(dateabs.Month).Substring(0, 3), dateabs.Year);
                        if (!showcustomdate)
                        {
                            if (pas == 0 || (pas > 0 && index % pas == 0) || index == diffMonths - 1)
                            {
                                var xLabel = new IndexedXAxisLabel(FormatIndexedLabel(dateabs), index, RobotoLightBold, 6, RgbColor.Black);
                                lineValorisation.XAxis.Labels.Add(xLabel);
                            }
                        }
                        else
                        {
                            lineValorisation.XAxis.Labels.Add(new IndexedXAxisLabel(FormatIndexedLabel(dateabs), index, RobotoLightBold, 6, RgbColor.Black));
                        }
                        index++;
                    }
                }
                else
                {
                    var monthyear = string.Empty;
                    index = 0;
                    var month_eltindex = 0;
                    foreach (var dateabs in dateabcisses)
                    {

                        currentvalorisation = (valorisationdata.ContainsKey(dateabs)) ? valorisationdata[dateabs] : currentvalorisation;
                        lineValorisation.Values.Add(Convert.ToSingle(currentvalorisation) / 1000);

                        var monthname = culture.DateTimeFormat.GetMonthName(dateabs.Month);
                        var dateabs_afficher = monthname.Length > 3 ?
                            string.Format("{0} {1}", culture.DateTimeFormat.GetMonthName(dateabs.Month).Substring(0, 4), dateabs.Year) :
                            string.Format("{0} {1}", culture.DateTimeFormat.GetMonthName(dateabs.Month).Substring(0, 3), dateabs.Year);

                        if (monthyear != dateabs_afficher)
                        {
                            month_eltindex = 0;
                        }

                        if (investissementandretraitdata != null && investissementandretraitdata.Count > 0)
                        {
                            var investmonth = investKeys.Where(x1 => x1.Month == dateabs.Month && x1.Year == dateabs.Year).ToList();
                            if (investmonth.Count > month_eltindex)
                            {
                                var key = investmonth[month_eltindex];
                                //var key = investKeys.FirstOrDefault(x1 => x1.Month == dateabs.Month && x1.Year == dateabs.Year);
                                if (key != DateTime.MinValue)
                                {
                                    if (lineInvestisstement != null)
                                        lineInvestisstement.Values.Add(Convert.ToSingle(investissementandretraitdata[key].Item1) / 1000, index);
                                    if (lineRetrait != null)
                                        lineRetrait.Values.Add(Convert.ToSingle(investissementandretraitdata[key].Item2) / 1000, index);
                                }
                                else
                                {
                                    if (lineInvestisstement != null)
                                        lineInvestisstement.Values.Add(0);
                                    if (lineRetrait != null)
                                        lineRetrait.Values.Add(0);
                                }
                            }
                        }
                        if (month_eltindex == 0)
                        {
                            if (dateabcisses.Count == max_Month)
                            {
                                lineValorisation.XAxis.Labels.Add(new IndexedXAxisLabel(FormatIndexedLabel(dateabs), index, RobotoLightBold, 6, RgbColor.Black));
                            }
                            else
                                lineValorisation.XAxis.Labels.Add(new IndexedXAxisLabel(dateabs_afficher, index, RobotoLightBold, 6, RgbColor.Black));
                        }
                        monthyear = dateabs_afficher;
                        index++;
                        month_eltindex++;
                    }
                }
    
            }
            #endregion

            // Create a numeric x axis and Xaxis gridlines
            var axeColor = new Gradient(0, 0, 200, 200, new RgbColor(235, 235, 235), new RgbColor(220, 220, 220));
            var yGrid = new YAxisGridLines();
            var xGrid = new XAxisGridLines();

            yGrid.Color = axeColor;
            xGrid.Color = axeColor;

            plotArea.YAxes.DefaultNumericAxis.MajorGridLines = yGrid;
            lineValorisation.XAxis.MajorGridLines = xGrid;
            lineValorisation.YAxis.LabelOffset = 8;
            ////
            ////
            ////
            lineValorisation.YAxis.LabelFormat = axeformat;
            if (lineRetrait != null && lineRetrait.YAxis != null)
            {
                lineRetrait.YAxis.LabelFormat = axeformat;
                lineInvestisstement.YAxis.LabelFormat = axeformat;
            }
            //
            //
            //
            y += height;
            _currentPage.Elements.Add(chart);
            lineValorisation.XAxis.Labels.Angle = 25;

            return logdata;
        }