Thursday, February 9, 2012

Microsoft Chart Tool 3.5 guide

To display a chart similar to the one below
 
 
Three easy steps to do the chart:
  1. Create a DataTable with columns equal to number of bars needed for each week and a column for week itself. Populate table data.
  2. 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();
            }
        }
  1. Your are done, just bind the chart with the datatable
 
 
 

No comments: