protected void btnSearch_Click(object sender, EventArgs e)
{
getChart();
}
protected void getChart()
{
DateTime today = RadDatePicker1.SelectedDate.Value;
DateTime _lastDate = RadDatePicker2.SelectedDate.Value;
// Setup chart orientation
this.radChart1.SeriesOrientation = ChartSeriesOrientation.Vertical;
// Setup XAxis
this.radChart1.PlotArea.XAxis.IsZeroBased = false;
this.radChart1.PlotArea.XAxis.Appearance.ValueFormat = Telerik.Charting.Styles.ChartValueFormat.ShortDate;
this.radChart1.PlotArea.XAxis.AutoScale = false;
this.radChart1.PlotArea.XAxis.AddRange(today.ToOADate(), _lastDate.ToOADate(), 7);
this.radChart1.PlotArea.XAxis.LayoutMode = Telerik.Charting.Styles.ChartAxisLayoutMode.Inside;
// Setup YAxis
this.radChart1.PlotArea.YAxis.IsZeroBased = false;
this.radChart1.PlotArea.YAxis.Appearance.ValueFormat = Telerik.Charting.Styles.ChartValueFormat.Percent;
this.radChart1.PlotArea.YAxis.AutoScale = false;
this.radChart1.PlotArea.YAxis.AddRange(0, 1, 0.1);
// Setup Series
this.radChart1.Series[0].Type = ChartSeriesType.Line;
this.radChart1.Series[0].DataXColumn = "X";
this.radChart1.Series[0].DataYColumn = "Y";
this.radChart1.Series[0].Appearance.LabelAppearance.Visible = false;
this.radChart1.DataSource = GenerateSource("Table");
this.radChart1.DataMember = "Table";
this.radChart1.DataBind();
}
private DataSet GenerateSource(string tableName)
{
DateTime startDate = Convert.ToDateTime(RadDatePicker1.SelectedDate.Value);
DateTime NewStartDate = Convert.ToDateTime(Projects.GetStartDayOfWeek(startDate));
DateTime EndDate = Convert.ToDateTime(RadDatePicker2.SelectedDate.Value);
DataTable _oData = new DataTable();
DateTime _sdate = startDate;
for (DateTime i = startDate; i <= EndDate; i.AddDays(7))
{
string[] SplitAction = i.ToString().Split(new Char[] { '/' });
string columnName = SplitAction[0] + "/" + SplitAction[1];
DataColumn oDataColoumn = new DataColumn(Convert.ToString(columnName), System.Type.GetType("System.String"));
i = i.AddDays(7);
_oData.Columns.Add(oDataColoumn);
}
DataTable table = new DataTable(tableName);
table.Columns.Add(
"X", typeof(double));
table.Columns.Add(
"Y", typeof(double));
DataTable oDataTable = Platforms.GetAllPlatforms();
DataRow dr1 = oDataTable.NewRow();
dr1[
"PlatformName"] = "Multiple";
dr1[
"PlatformID"] = 0;
oDataTable.Rows.Add(dr1);
DataRow dr = _oData.NewRow();
double total = 0;
NewStartDate =
Convert.ToDateTime(Projects.GetStartDayOfWeek(startDate));
for (int oCount = 0; oCount <= _oData.Columns.Count - 1; oCount++)
{
string i = _oData.Columns[oCount].ToString();
string[] SplitAction = i.ToString().Split(new Char[] { '/' });
string columnName = SplitAction[0] + "/" + SplitAction[1] + "/" + "2010";
DateTime dt = Convert.ToDateTime(columnName);
string ss = GetCountForQuotesTimelines(NewStartDate, Convert.ToInt64(oDataTable.Rows[1][0].ToString()));
string[] SplitAction1 = ss.ToString().Split(new Char[] { '%' });
string columnName1 = SplitAction1[0];
if (ss != null)
{
DataRow dr2 = table.NewRow();
dr2[
"X"] = dt.ToOADate();
if (columnName1 == "")
{
dr2[
"Y"] = 0;
}
else
{
dr2[
"Y"] = Convert.ToDouble(columnName1);
}
table.Rows.Add(dr2);
}
else
{
}
NewStartDate = NewStartDate.AddDays(7);
}
DataSet dataSet = new DataSet();
dataSet.Tables.Add(table);
return dataSet;
}
}
///---------------------------
hello ,
I have created a radchart series items dynamically according to the date range selected.My logic show me the proper dataset in the datasource returned but it's not attach with radchart databind event .and don't show any error.all the fields are generated at runtime.
please see the attach file i.e screen shot what i want to do.
Please help me to get out of this error as soon as possible.
Thanks in advance..