Hi,
I have a radchart and want to show multiple lines using datatable(I know datatable is not supported , but im adding series mannually). User selects thae date from calendar and I query the database for those range. so here is my code how I add the series I get one datatable at time and assign it to chart, i get datatable in this format :
Now I am doing the if statement in above code so that the line doesn't come back to 1 axis once the dtmonthno is more than 12.
My question is how do I show these month names in x-axis i have tried setting the autoscale to false and trying to set the x-axis but simply doesnt work here is my code for it that i add in the above foreach loop:
radBrands.PlotArea.XAxis.AddRange(1, 16, 1);
int dtMonth = Convert.ToInt32(dr["dtMonthno"]);
radBrands.PlotArea.XAxis[dtMonth - 1].TextBlock.Text = dr["dtMonthBrand"].ToString();
Your help would be greatly appreciated.
Thanks
I have a radchart and want to show multiple lines using datatable(I know datatable is not supported , but im adding series mannually). User selects thae date from calendar and I query the database for those range. so here is my code how I add the series I get one datatable at time and assign it to chart, i get datatable in this format :
Tours | agencyname | dtMonthno | dtMonthBrand | dtYear | |
6 | agents | 5 | May | 2011 | |
8 | agents | 6 | June | 2011 | |
2 | agents | 7 | July | 2011 | |
23 | agents | 8 | August | 2011 | |
126 | agents | 9 | September | 2011 | |
101 | agents | 10 | October | 2011 | |
85 | agents | 11 | November | 2011 | |
92 | agents | 12 | December | 2011 | |
115 | agents | 1 | January | 2012 | |
102 | agents | 2 | February | 2012 | |
48 | agents | 3 | March | 2012 |
foreach
(
string
aId
in
aAgency)
{
DataTable dtBrands = count.GetBrandsChartData(Convert.ToDateTime(txtStartDate.Text), Convert.ToDateTime(txtEndDate.Text), Convert.ToInt32(aId));
bool
morethenTwelve =
false
;
if
(dtBrands.Rows.Count > 0)
{
ChartSeries brandChartSeries =
new
ChartSeries();
brandChartSeries.Name = dtBrands.Rows[0][1].ToString();
brandChartSeries.Type = ChartSeriesType.Line;
foreach
(DataRow dr
in
dtBrands.Rows)
{
ChartSeriesItem chartitem =
new
ChartSeriesItem();
chartitem.YValue = Convert.ToDouble(dr[
"Tours"
]);
if
(morethenTwelve ==
false
)
{
dtMontno = Convert.ToInt32(dr[
"dtMonthno"
]);
}
if
(dtMontno == 12)
{
chartitem.XValue = Convert.ToDouble(dr[
"dtMonthno"
]);
morethenTwelve =
true
;
dtMontno = 13;
}
else
if
(dtMontno > 12)
{
chartitem.XValue = Convert.ToDouble(dtMontno += 1);
morethenTwelve =
true
;
}
else
{
chartitem.XValue = Convert.ToDouble(dr[
"dtMonthno"
]);
morethenTwelve =
false
;
}
brandChartSeries.AddItem(chartitem);
radBrands.PlotArea.XAxis[dtMonth - 1].TextBlock.Text = dr[
"dtMonthBrand"
].ToString();
}
radBrands.PlotArea.XAxis.LayoutMode = Telerik.Charting.Styles.ChartAxisLayoutMode.Inside;
radBrands.ChartTitle.TextBlock.Text =
"Brands"
;
radBrands.PlotArea.XAxis.AutoScale =
false
;
radBrands.AddChartSeries(brandChartSeries);
radBrands.Series.Add(brandChartSeries);
}
}
Now I am doing the if statement in above code so that the line doesn't come back to 1 axis once the dtmonthno is more than 12.
My question is how do I show these month names in x-axis i have tried setting the autoscale to false and trying to set the x-axis but simply doesnt work here is my code for it that i add in the above foreach loop:
radBrands.PlotArea.XAxis.AddRange(1, 16, 1);
int dtMonth = Convert.ToInt32(dr["dtMonthno"]);
radBrands.PlotArea.XAxis[dtMonth - 1].TextBlock.Text = dr["dtMonthBrand"].ToString();
Your help would be greatly appreciated.
Thanks