Legend showing multiple times

I have a log file that contains (IP, datetime, pingtime).  I read the data from the log.txt file, I group them and after that I create the chart series.
The problem: the legend shows multiple times the name of IP.
How can I correct this problem?

PS: I attached a screenshot too.

Screenshot:
https://imgur.com/a/uBEFnGJ

thanks advanced,
istvan

        public void getSeries()
        {
            string path = mainform.path + "log.txt";
            int counter = 0;
            string line;

            List<IPList> listIPs = new List<IPList>();
            chartControlHistory.Series.Clear();

            FileStream fs = new FileStream(path, FileMode.Open, FileAccess.Read, FileShare.Read);
            StreamReader file = new StreamReader(fs);
            while ((line = file.ReadLine()) != null)
            {
                System.Console.WriteLine(line);
                string[] newline = line.Split(';');

                if (newline.Length > 7)
                {
                    IPList ips = new IPList();
                    ips.IPAddress = newline[2];
                    ips.datetime = Convert.ToDateTime(newline[1].ToString());
                    ips.pingtime = Convert.ToDouble(newline[5].ToString());

                    listIPs.Add(ips);
                }
                counter++;
            }

            file.Close();

            var groupedList = (from s in listIPs group s by s.IPAddress.Trim() into grp where !grp.Key.Contains("IPPINGER") select grp.Key).ToList();

            ChartSeries[] chartSeries = new ChartSeries[listIPs.Count];


            foreach (var ips in groupedList.ToList())
            {
                for (int i = 0; i < listIPs.Count; i++)
                {
                    if (ips == listIPs[i].IPAddress)
                    {
                        chartSeries[i] = new ChartSeries(listIPs[i].IPAddress, ChartSeriesType.Bubble);
                        chartSeries[i].Points.Add(Convert.ToDateTime(listIPs[i].datetime.ToString()), Convert.ToDouble(listIPs[i].pingtime.ToString()));
                        chartSeries[i].PointsToolTipFormat = "DateTime:{3}";
                    }
                }
            }

            string ip = "";
            foreach (var ips in groupedList.ToList())
            {
                foreach (ChartSeries ch in chartSeries)
                {
                    if (ch != null)
                    {
                        chartControlHistory.Series.Add(ch);
                    }
                }
            }
            this.chartControlHistory.ImprovePerformance = true;

            this.chartControlHistory.CalcRegions = false;

            this.chartControlHistory.NeedPerformance = true;

            this.chartControlHistory.Crosshair.Visible = true;

            this.chartControlHistory.PrimaryXAxis.ShowCrosshairTooltip = true;

            this.chartControlHistory.PrimaryYAxis.ShowCrosshairTooltip = true;

            this.chartControlHistory.Series3D = true;

            this.chartControlHistory.ZoomType = ZoomType.Selection;
        }

5 Replies 1 reply marked as answer

YP Yuvaraj Palanisamy Syncfusion Team August 2, 2020 11:41 PM UTC

Hi Molnar Istvan, 
 
Currently we are validating your query and we will update you the status on or before 4th August 2020. 
 
Regards, 
Yuvaraj 



YP Yuvaraj Palanisamy Syncfusion Team August 5, 2020 05:44 PM UTC

Hi Molnar Istvan,  
 
Our development team is working on this with high priority, since this approach is related with chart legend placement and takes more time than expected, we will update you the status of this in 2 business days 7th August 2020. We deeply regret for the inconvenience caused.   
 
Regards,  
Yuvaraj  



YP Yuvaraj Palanisamy Syncfusion Team August 7, 2020 02:57 PM UTC

 
Thank you for your patience.  
   
We have analyzed your query and code; we suspect that you can resolve this by using following code example. In that, we have created the chart series from groupedList instead of you have created listIPs. And legend items created based on the series count. Please find the following code example.  
 
 
Code Snippet: 
 
 
foreach (var ips in int m = 0; m < groupedList.ToList().Count; m++)
            {
 
                 var ips = groupedList[m]; 
                 chartSeries[m] = new ChartSeries(ips, ChartSeriesType.Bubble); 

                for (int i = 0; i < listIPs.Count; i++)
                {
                    if (ips == listIPs[i].IPAddress)
                    {
                        chartSeries[i] = new ChartSeries(listIPs[i].IPAddress, ChartSeriesType.Bubble);
                        chartSeries[m].Points.Add(Convert.ToDateTime(listIPs[i].datetime.ToString()), Convert.ToDouble(listIPs[i].pingtime.ToString()));
                        chartSeries[m].PointsToolTipFormat = "DateTime:{3}";
                    }
                }
            }
 
 
 
Regards, 
Yuvaraj 
  


Marked as answer

MI Molnár István August 8, 2020 11:52 AM UTC

It's working.
Thanks very much for your help.



HM Hemalatha Marikumar Syncfusion Team August 10, 2020 08:26 AM UTC

Hi Molnar Istvan, 
 
Thanks for your valuable feedback.  
 
Please let us know if you need any further assistance.  
 
Regards,
Hemalatha M. 


Loader.
Up arrow icon