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

Rad Chart Grouping Problem

1 Answer 91 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Atul
Top achievements
Rank 1
Atul asked on 13 Mar 2012, 01:57 PM

i  used rad chart and facing problem in grouping column .
AM4 displaying three bar values  insteadof  two values and  AM5,AM6  is showing incorrect values .

please suggest me solution.

siteStatus                                  UserName

Assigned                                     AM4                    1

Submitted For Approval              AM4                    15

To Be Assigned                           AM5                     2

To Be Assigned                           AM6                     1

To Be Assigned                           AM7                      2



            chartBarRoleWise.DataSource = siteStatus;
            chartBarRoleWise.DataGroupColumn = "SiteStatus";
            chartBarRoleWise.PlotArea.XAxis.DataLabelsColumn = "UserName";
            chartBarRoleWise.Legend.Appearance.GroupNameFormat = "#VALUE";
            chartBarRoleWise.DataBind()
            ;

1 Answer, 1 is accepted

Sort by
0
Evgenia
Telerik team
answered on 15 Mar 2012, 02:04 PM
Hi Atul,

By default RadChart places the ChartSeriesItems (in this case -- bars) consecutively. In order to instruct the chart to shift the items to the correct position along the X, you will need another numeric column, which will provide the values for XValue property of the ChartSeriesItems. Here's the code:

DataTable tbl = new DataTable();
    DataColumn col = new DataColumn("Value");
    col.DataType = typeof(int);
    tbl.Columns.Add(col);
    col = new DataColumn("fakeGroupValue");
    col.DataType = typeof(int);
    tbl.Columns.Add(col);
    col = new DataColumn("siteStatus");
    col.DataType = typeof(string);
    tbl.Columns.Add(col);
    col = new DataColumn("userName");
    col.DataType = typeof(string);
    tbl.Columns.Add(col);
    tbl.Rows.Add(new object[] { 1, 1, "Assigned", "AM4"});
    tbl.Rows.Add(new object[] { 15, 1, "Submitted For Approval", "AM4"});
    tbl.Rows.Add(new object[] { 2, 2, "To Be Assigned", "AM5"});
    tbl.Rows.Add(new object[] { 1, 3, "To Be Assigned", "AM6"});
    tbl.Rows.Add(new object[] { 2, 4, "To Be Assigned", "AM7"});
    RadChart1.DataManager.ValuesXColumn = "fakeGroupValue";
    RadChart1.DataGroupColumn = "siteStatus";
    RadChart1.DataManager.ValuesYColumns = new string[] { "Value" };
    RadChart1.PlotArea.XAxis.DataLabelsColumn = "userName";
    RadChart1.Legend.Appearance.GroupNameFormat = "#VALUE";
    RadChart1.DefaultType = Telerik.Charting.ChartSeriesType.Bar;
    RadChart1.DataSource = tbl;
    RadChart1.DataBind();
    RadChart1.AutoLayout = true;

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
General Discussions
Asked by
Atul
Top achievements
Rank 1
Answers by
Evgenia
Telerik team
Share this question
or