public partial class _Default : System.Web.UI.Page |
{ |
DataTable tbl; |
protected void Page_Load(object sender, EventArgs e) |
{ |
|
tbl = new DataTable(); |
DataColumn col = new DataColumn("ProductName"); |
col.DataType = typeof(string); |
tbl.Columns.Add(col); |
col = new DataColumn("Jan"); |
col.DataType = typeof(double); |
tbl.Columns.Add(col); |
col = new DataColumn("Feb"); |
col.DataType = typeof(double); |
tbl.Columns.Add(col); |
col = new DataColumn("March"); |
col.DataType = typeof(double); |
tbl.Columns.Add(col); |
tbl.Rows.Add(new object[] { "P1", 2, 19, 11 }); |
tbl.Rows.Add(new object[] { "P2", 12, 13, 14 }); |
tbl.Rows.Add(new object[] { "P3", 22, 5, 7 }); |
tbl.Rows.Add(new object[] { "P4", 9, 6, 2 }); |
|
foreach (DataRow row in tbl.Rows) |
{ |
ChartSeries ser = new ChartSeries(row["ProductName"].ToString(), ChartSeriesType.Line); |
|
for (int i = 1; i < tbl.Columns.Count; i++) |
{ |
ChartSeriesItem item = new ChartSeriesItem((double)row[i]); |
ser.Items.Add(item); |
} |
RadChart1.Series.Add(ser); |
} |
|
RadChart1.PlotArea.XAxis.Appearance.LabelAppearance.Dimensions.AutoSize = false; |
RadChart1.PlotArea.XAxis.Appearance.LabelAppearance.Dimensions.Height = 20; |
RadChart1.PlotArea.XAxis.Appearance.LabelAppearance.Dimensions.Width = 50; |
} |
|
protected void RadChart1_PrePaint(object sender, EventArgs e) |
{ |
for (int i = 0; i < RadChart1.PlotArea.XAxis.Items.Count; i++) |
{ |
RadChart1.PlotArea.XAxis.Items[i].TextBlock.Text = tbl.Columns[i + 1].ColumnName; |
} |
} |
} |
|