Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
405
Stacking column segments over an XAxis of type date, based on a dynamic number of stacked segments
posted

I am attempting to create stacked columns in an MVC4 project wherein I would like to have multiple stacked series per given day along the xAxis. The YAxis is a numerical value. The goal is to show the combined resource usage of an individual for a given point in time. I've created the following model to represent the data:

public class PercentUtilizedModel {
    public DateTime Day { get; set; }
    public string TeamMember { get; set; }         
    public string PercentUtilized { get; set; }         
    public string ProjectName { get; set; }
}

And a view model that will return the data to the Infragistics DataChart as a list:
public class PMViewModel {
     public IEnumerable<PercentUtilizedModel> PercentUtilized { get; set; }
     public IEnumerable<ReleaseModel> Releases { get; set; }
}

 

To test the ability to generate the stacked chart, I'm using the following mock data:
List<PercentUtilizedModel> Data = new List<PercentUtilizedModel> {
new PercentUtilizedModel(){ Day=DateTime.Today, TeamMember = "Sylvester", PercentUtilized = "25", ProjectName = "Project A" },
new PercentUtilizedModel(){ Day=DateTime.Today, TeamMember = "Sylvester", PercentUtilized = "50", ProjectName = "Project B" },
new PercentUtilizedModel(){ Day=DateTime.Today, TeamMember = "Sylvester", PercentUtilized = "25", ProjectName = "Project C" },
new PercentUtilizedModel(){ Day=DateTime.Today, TeamMember = "Tweety", PercentUtilized = "50", ProjectName = "Project A" },
new PercentUtilizedModel(){ Day=DateTime.Today, TeamMember = "Tweety", PercentUtilized = "50", ProjectName = "Project B" } };

So in this example, I would want the chart to display 3 segments of a stack for Sylvester over a point on the xAxis representing today's date, followed by a 2 segment stacked series for Tweety. Can this viewmodel be charted like I am describing as is, or do I need to manipulate the data before attempting to create the chart? I have not been able to think of a way to build the fragments for a dynamic number of potential PercentUtilized values falling on the same Day. My starting point is:

 @(Html.Infragistics().DataChart(Model.PercentUtilized.AsQueryable())                            
.ID("chart1")                            
.Axes(axes =>                            
{                                
   axes.CategoryX("catX").Label(x => x.Day).LabelAngle(45).LabelExtent(100);                                
   axes.NumericY("numY").MaximumValue(1500).MinimumValue(0).Interval(100);                            
})                            
.Series(series =>{                                
   series.StackedColumn("parent")                                
   .XAxis("catX")                                
   .YAxis("numY")                                
   .Series((build) =>{                                        
      build.Fragment("TeamMember").Title("PercentUtilized").ValueMemberPath("PercentUtilized");                                    
   });                            
})                            
.DataBind()                            
.Render() )