Datasource of type dataset Not bind with the radchart.databind event.

Thread is closed for posting
2 posts, 0 answers
  1. Mandy
    Mandy avatar
    33 posts
    Member since:
    Mar 2010

    Posted 24 May 2010 Link to this post

     

    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..
     

  2. Ves
    Admin
    Ves avatar
    2879 posts

    Posted 27 May 2010 Link to this post

    Hi Mandeep,

    I can see the chart series type is line, while the attached image shows bars. I am not really sure about the reason for such behavior, do you alter the chart series and datasource elsewhere in the code?. I created a small example, which follow basically the same structure -- a single line series within the chart and the chart is populated by a dataset. It works correctly for me, you can find it attached.

    Best regards,
    Ves
    the Telerik team

    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
  3. UI for ASP.NET Ajax is Ready for VS 2017
Back to Top