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

RadChart Data Not Displaying Properly

1 Answer 137 Views
Chart (Obsolete)
This is a migrated thread and some comments may be shown as answers.
kim
Top achievements
Rank 1
kim asked on 30 Jan 2013, 06:37 PM
I have a radchart:
<telerik:RadChart ID="rcProposedWaiting" runat="server" Width="750px" DataGroupColumn="Name" 
AutoTextWrap="true" Skin="Hay" ChartTitle-TextBlock-Text="Projects By Department" SeriesOrientation="Horizontal" AutoLayout="true">
<Legend><Appearance GroupNameFormat="#VALUE"></Appearance></Legend>
<PlotArea><XAxis DataLabelsColumn="Department"></XAxis></PlotArea>
</telerik:RadChart>

I am populating with a DataView:
public DataView GetProposedWaitingChart()
{
List<int> lst = new List<int>();
lst.Add( (int)ApprovalStatus.Proposed );
lst.Add( (int)ApprovalStatus.WaitingforApproval );

string listStatus =  Util.CompressList( lst, "," );

List<ITProject> projects = _dal.GetProjectByApprovalSatus( listStatus );

DataTable dt = new DataTable();
dt.Columns.Add( "Name" );
dt.Columns.Add( "Department" );
DataColumn dc = new DataColumn( "Value", Type.GetType( "System.Int32" ) );
dt.Columns.Add( dc );

var groupedStatus = from f in projects
group f by new {
f.Department,
f.ApprovalStatus
} into myGroup
orderby myGroup.Key.ApprovalStatus, myGroup.Key.Department
select new { myGroup.Key.Department, myGroup.Key.ApprovalStatus, Count = myGroup.Count() };

foreach (var obj in groupedStatus) {
string department = obj.Department;
string status = obj.ApprovalStatus;
int count = obj.Count;
dt.Rows.Add( status, department, count );
}

DataView dv = dt.DefaultView;
dv.Sort = "Name, Department";

return dv;
}
----------------------------------------------------------------------
I have verified that my datatable looks correct after the foreach loop...
? dt.Rows[0].ItemArray
{object[3]}
    [0]: "Proposed"
    [1]: "IT"
    [2]: 2
? dt.Rows[1].ItemArray
{object[3]}
    [0]: "Waiting for Approval"
    [1]: "Advisory Services"
    [2]: 1
----------------------------------------------------------------------
 but I am getting the attached output (projbad.jpg)... 


---------------------------------------------------------------------------------
If I just add dummy rows to my datatable rather than the database data, it works just fine (projgood.jpg)

dt.Rows.Add( "Proposed", "IT", 4 );
dt.Rows.Add( "Waiting", "FA", 4 );
dt.Rows.Add( "Proposed", "TA", 1 );
dt.Rows.Add( "Proposed", "FA", 2 );
dt.Rows.Add( "Waiting", "IT", 3 );
dt.Rows.Add( "Waiting", "TA", 2 );

DataView dv = dt.DefaultView;
dv.Sort = "Name, Department";
---------------------------------------------------------------------------------


Any ideas?  Thanks

1 Answer, 1 is accepted

Sort by
0
kim
Top achievements
Rank 1
answered on 30 Jan 2013, 10:50 PM
After some investigation we realized that the first sequence in the dataset needs to have a value for both groupings... so if IT has 3 proposed projects and no pending projects, it does not display properly. We have to manually add a 0 row for (IT, Pending, 0) as a work around.
Tags
Chart (Obsolete)
Asked by
kim
Top achievements
Rank 1
Answers by
kim
Top achievements
Rank 1
Share this question
or