Click here to Skip to main content
16,007,779 members
Please Sign up or sign in to vote.
3.00/5 (1 vote)
See more:
Hi all,

I have a 5*5 matrix through which I am trying to draw a Line Plot.

How can we access all the series (say 5 series in this case)?
C#
chart1.Series["Default"].Points.AddY(array[i]);


Actually this line can access only a particular series. I want to know how to access all the series using these features. If possible show me code snippet.
-- Thanks in advance friends -----
Posted
Updated 3-Feb-11 12:55pm
v2
Comments
#realJSOP 3-Feb-11 7:40am    
What chart library are you using? What platform are you using? Winforms, WPF, Silverlight, ASP.NET?
Henry Minute 3-Feb-11 18:55pm    
The OP has replied:
arunmj - 10 hrs ago
visual studio ,,c# ,, .net 4.0,,,, winforms

1 solution

You should add each row of your matrix as an additional series. Here is my code from an application I wrote a while back:

chart.ChartAreas.Add(new System.Windows.Forms.DataVisualization.Charting.ChartArea("BidAsk"));
chart.Series.Add(new System.Windows.Forms.DataVisualization.Charting.Series("Bid"));
chart.Series.Add(new System.Windows.Forms.DataVisualization.Charting.Series("Ask"));

chart.Series["Bid"].ChartType = SeriesChartType.StepLine;
chart.Series["Bid"].Points.DataBindXY(dView, "Timestamp", dView, "BidPrice");
chart.Series["Bid"].ChartArea = "BidAsk";
chart.Series["Ask"].ChartType = SeriesChartType.StepLine;
chart.Series["Ask"].Points.DataBindXY(dView, "Timestamp", dView, "AskPrice");
chart.Series["Ask"].ChartArea = "BidAsk";


The DataBindXY line is where you will set the values for Y. You will probably just use DataBindY.
 
Share this answer
 

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