This is a migrated thread and some comments may be shown as answers.

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

1 Answer 56 Views
Chart (Obsolete)
This is a migrated thread and some comments may be shown as answers.
Hasibul
Top achievements
Rank 1
Hasibul asked on 08 Dec 2011, 07:27 AM
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.


1 Answer, 1 is accepted

Sort by
0
Evgenia
Telerik team
answered on 12 Dec 2011, 02:50 PM
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
Tags
Chart (Obsolete)
Asked by
Hasibul
Top achievements
Rank 1
Answers by
Evgenia
Telerik team
Share this question
or