To display a chart similar to the one below
Three easy steps to do the chart:
- Create a DataTable with columns equal to number of bars needed for each week and a column for week itself. Populate table data.
- Create a chart with series based on the datatable columns as below
for (int i = 1; i < chartData.Columns.Count; i++)
{
if (isFirstColumn)
{
Chart1.Series[0].XValueMember = chartData.Columns[0].ToString();
Chart1.Series[0].YValueMembers = chartData.Columns[i].ToString();
isFirstColumn = false;
}
else
{
Chart1.Series.Add(Convert.ToString(i));
Chart1.Series[Convert.ToString(i)].XValueMember = chartData.Columns[0].ToString();
Chart1.Series[Convert.ToString(i)].YValueMembers = chartData.Columns[i].ToString();
}
}
- Your are done, just bind the chart with the datatable
No comments:
Post a Comment