Rad Chart doesnt shows record if I use RadChart1.PlotArea.XAxis.DataLabelsColumn = "Column Name";

Thread is closed for posting
2 posts, 0 answers
  1. Hasibul
    Hasibul avatar
    2 posts
    Member since:
    Oct 2012

    Posted 08 Dec 2011 Link to this post

    I have a problem with Rad Chart. My chart shows properly if i dont use following line of code
    RadChart1.PlotArea.XAxis.DataLabelsColumn = "BranchName";

    Consider if have used following data table
    private DataTable GeneratedData()
            {
                DataTable dt = new DataTable();
                dt.Columns.Add("Asset");
                dt.Columns.Add("Liability");
                dt.Columns.Add("Income");
                dt.Columns.Add("BranchId");
                dt.Columns.Add("BranchName");
     
                DataRow dr = dt.NewRow();
                dr[0] = "052";
                dr[1] = "-25";
                dr[2] = "45";
                dr[3] = "1001";
                dr[4] = "Corporate";
                dt.Rows.Add(dr);
                dr = dt.NewRow();
     
                dr[0] = "161";
                dr[1] = "29";
                dr[2] = "35";
                dr[3] = "1002";
                dr[4] = "IDB";
                dt.Rows.Add(dr);
     
                return dt;
            }

    And i used following code to generate rad chart
    RadChart1.DataSource = GeneratedData();
                RadChart1.DataManager.ValuesYColumns = new string[3] { "Asset", "Liability", "Income" };
                RadChart1.DataManager.ValuesXColumn = "BranchId";
                RadChart1.PlotArea.XAxis.DataLabelsColumn = "BranchName";
                RadChart1.PlotArea.XAxis.AddRange(1001,1002,1);
                RadChart1.PlotArea.XAxis.AutoScale = false;
     
                RadChart1.DataBind();

    If I dont define DatalabelsColumn then chart shows correctly. but I want to show Lable from BranchName column. How i can do this. Need your help.


  2. Evgenia
    Admin
    Evgenia avatar
    1407 posts

    Posted 12 Dec 2011 Link to this post

    Hello Hasibul,

    The way ValuesXColumn property works is connected with the strict mode of the chart. Since you have provided your own XValues (1001 and 1002) the strict mode is disabled and the chart gets "confused". I suggest that you set the values of the BranchId column to start from 1 as they would start by default (when the strict mode is turned on) and remove the manual range of the Axis. Your code should look like this:

    protected void Page_Load(object sender, EventArgs e)
       {
           RadChart1.DataSource = GeneratedData();
           RadChart1.DataManager.ValuesYColumns = new string[3] { "Asset", "Liability", "Income" };
           RadChart1.DataManager.ValuesXColumn = "BranchId";
           RadChart1.PlotArea.XAxis.DataLabelsColumn = "BranchName";
           RadChart1.DataBind();
       }
       private DataTable GeneratedData()
       {
           DataTable dt = new DataTable();
           dt.Columns.Add("Asset");
           dt.Columns.Add("Liability");
           dt.Columns.Add("Income");
           dt.Columns.Add("BranchId");
           dt.Columns.Add("BranchName");
           DataRow dr = dt.NewRow();
           dr[0] = "052";
           dr[1] = "-25";
           dr[2] = "45";
           dr[3] = 1;
           dr[4] = "Corporate";
           dt.Rows.Add(dr);
           dr = dt.NewRow();
           dr[0] = "161";
           dr[1] = "29";
           dr[2] = "35";
           dr[3] = 2;
           dr[4] = "IDB";
           dt.Rows.Add(dr);
           return dt;
       }

    Kind regards,
    Evgenia
    the Telerik team
    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now
  3. UI for ASP.NET Ajax is Ready for VS 2017
Back to Top