Dynamic series binding

Not Answered This post has 0 verified answers and 2 replies

Not Ranked
Posts: 16
jasedwards Posted: Tue May 11, 2010 @ 2:05 PM
I am going to do a stacked bar chart with many series.  I won't know the number of series until run time so I will need to create them dynamically.  For example, my x-axis will be year (2008,2009,2010) and y-axis will be a double (i.e. $1200.00).  Each series will be an insurance coverage (i.e. Auto, Liability...) and I will need the legend to tell the user what color matches each coverage.  Since I won't know the available coverages at run time I am having trouble implementing this.  Is there a way to bind the chart and series to a collection of objects like the one below to create a series for each different coverage that is in the list?

public class Data
{
     public string Year {get;set;}   <-- x-axis
     public string Coverage {get;set;} <-- series data (i.e. Auto, Liability, collision...)
     public string Amount {get;set;} <-- y-axis
}

All Replies

Top 10 Contributor
Posts: 1,603
harish Posted: Tue Jun 1, 2010 @ 7:21 AM

Hello,

 

Thank you for submitting your query with ComponentArt forum.

 

Please find the attached sample application for binding the WPF Chart with Collections.

 

Hope it will help you.

 

Thank you.

 

Harish Malhotra

Not Ranked
Posts: 6
StephenDT Posted: Wed Jan 26, 2011 @ 10:23 AM
This solution does not answer the question that jasedwards asked.  You've only represented "Year" as "X" and "Amount" as "Y" in your example.  You're missing the Y series named "Coverage".  

As a result of this incompleteness, there is no indication of how to bind the "Coverage" to a chart so that it displays as individual dynamically created Y series. 

Please update your solution model to include this extra complication.  Thanks.
Page 1 of 1 (3 items)