Add Multiple series to a chart dynamically in asp.net
asp.net, c#-4.0
Solution
foreach(DataRow row in myDataSet.Tables["Query"].Rows)
{
// For each Row add a new series
string seriesName = row["SalesRep"].ToString();
Chart1.Series.Add(seriesName);
Chart1.Series[seriesName].ChartType = SeriesChartType.Line;
Chart1.Series[seriesName].BorderWidth = 2;
for(int colIndex = 1; colIndex < myDataSet.Tables["Query"].Columns.Count; colIndex++)
{
// For each column (column 1 and onward) add the value as a point
string columnName = myDataSet.Tables["Query"].Columns[colIndex].ColumnName;
int YVal = (int) row[columnName];
Chart1.Series[seriesName].Points.AddXY(columnName, YVal);
}
}
Problem
I want to add dynamic series in the chart. I have a data like date,totalamount. i would like to plot those points on chart. I get the data from sql database and bind. i want to plot the data from datatable which will update dynamically. ``` Series newSeries=new Series(); newseries.ChartType=SeriesChartType.Line; newSeries.BorderWidth = 3; Chart1.Series.Add(newSeries); newSeries.XValueMember = "date1"; newSeries.YValueMembers = "total"; Chart1.DataBind(); ``` this is plotting at last series of the tree view. please help me on this?