I am getting values from Listarray and want to create a chart from those values. Right now i have two Listarrays and they both have data. My requirement is that the Data in first Arraylist should be Xaxis values and Data in second arraylist should be yaxis values.Please help me out in this regards. My code is given below.
**These are the List arrays.**
List<string> lines = new List<string>();
List<string> lines1 = new List<string>();
**This is my code but the values are hard code**
DataSet dataSet = new DataSet();
DataTable dt = new DataTable();
dt.Columns.Add("Name", typeof(string));
dt.Columns.Add("Counter", typeof(int));
DataRow r1 = dt.NewRow();
r1[0] = "Demo"; //code should get r1[0] values from listarray 1
r1[1] = 8; //code should get r1[1] values from listarray 2
dt.Rows.Add(r1);
DataRow r2 = dt.NewRow();
r2[0] = "Second";
r2[1] = 15;
dt.Rows.Add(r2);
dataSet.Tables.Add(dt);
Chart chart1 = new Chart();
chart1.DataSource = dataSet.Tables[0];
i did some changes in my code but it shows only x axis values not y axis.
DataSet dataSet = new DataSet();
DataTable dt = new DataTable();
dt.Columns.Add("Name", typeof(string));
dt.Columns.Add("Counter", typeof(int));
foreach (string str in lines1)
{
DataRow r1 = dt.NewRow();
// Here you will get an actual instance of a DataRow
r1["Name"] = str; // Assign values
dt.Rows.Add(r1);
//Console.WriteLine(str);
//Console.ReadKey();
}
foreach (string str1 in lines)
{
DataRow r2 = dt.NewRow();
r2["Counter"] = str1; // Assign values
dt.Rows.Add(r2);
//Console.WriteLine(str1);
//Console.ReadKey();
}
//DataRow r1 = dt.NewRow();
//r1[0] = "Demo";
//r1[1] = 8;
//dt.Rows.Add(r1);
//DataRow r2 = dt.NewRow();
//r2[0] = "Second";
//r2[1] = 15;
//dt.Rows.Add(r2);
dataSet.Tables.Add(dt);
Chart chart1 = new Chart();
chart1.DataSource = dataSet.Tables[0];