Click here to Skip to main content
15,880,796 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
i have two list of object in cllect points. i have to plot two lines each for a list during run time. i have tried creating new series for each through looping and adding data points. but only single line is generated that is iterated last in the loop. how it can be done.

What I have tried:

i have tried creating new series for each through looping and adding data points. but only single line is generated that is iterated last in the loop. how it can be done.
var chart = chart1.ChartAreas[0];
chart.AxisX.IntervalType = DateTimeIntervalType.Number;

chart.AxisX.Interval = 1;
chart.AxisY.Interval = 10;

chart.AxisX.Minimum = 0;
chart.AxisY.Minimum = 0;

chart.AxisX.Maximum = 10;

chart.AxisX.LabelStyle.Format = "";
chart.AxisY.LabelStyle.Format = "";
chart1.Series.Clear();
Random random = new Random();


foreach (var list in collectpoints)
{
Series series = new Series(list.key) { ChartType = SeriesChartType.Line, BorderWidth = 2, MarkerSize = 5, MarkerStyle = MarkerStyle.Square };
chart1.Series.Add(list.key);
chart1.Series[list.key].IsValueShownAsLabel = true;
chart1.Series[list.key].ChartType = SeriesChartType.Line;
chart1.Series[list.key].Color = Color.FromArgb(random.Next(256), random.Next(256), random.Next(256));
chart1.DataSource =list.point ;
chart1.Series[list.key].YValueMembers = "values";
Posted
Updated 31-Oct-21 19:42pm
v2
Comments
Richard MacCutchan 31-Oct-21 10:15am    
Without seeing your code it is impossible to guess what may be wrong.
[no name] 31-Oct-21 13:17pm    
https://www.aspsnippets.com/Articles/Create-Multi-Series-Line-Chart-Graph-in-Windows-Forms-Application-using-C-and-VBNet.aspx


This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900