Jump to content
Software FX Community

Binding to aclass with a List of Y-Series inside


beltrams

Recommended Posts

I bind my chart (ItemsSource="{Binding Path=ReportData, Mode=OneWay}) to a List<Row> where Row is the following object:

public

ChartReportRow(ReportRow reportRow)

{

  public

List<Field> Columns { get; set; }

  public string AxisX {get {return  sfield = Columns[0].fieldValue;}

  public List<decimal?> AxisYList {

get { List<decimal?> axisYList = new List<decimal?>();

     foreach (DecimalField field in Columns) { axisYList.Add(field.fieldValue); }   return axisYList;

  }

}

 

Basically I would like to have on the Axis X AxisX field while on the Axis Y all the series AxisYList.

Is it possible to do this in XAML (as I have a View and a ViewModel).

Thanks.

Link to comment
Share on other sites

It seems you might need to use the ListTransform if you want one series per row in your model, I am not sure what the list of fields would do, also not sure what to do with the AxisX string given the fact that there is only one X axis, do you want this string to be the name of the series? (e.g. showing it in the legend box).

If these assumptions are correct this code should generate the chart you need.

ListTransform listTransform = new ListTransform();listTransform.ColumnPath = "AxisYList";listTransform.SeriesPath = "AxisX";chart1.DataTransforms.Add(listTransform);

If this does not do what you expect you might want to post a sample app along with a description of the how the data should be plotted.

JuanC

 

Link to comment
Share on other sites

Ok,m I have tried this wothout success,

Let me do another example:

in the Programmer's Guide & Example session in the website under ListTrasform we have this class

public class Country
{
    public string Name { get; set; }
    public string Capital { get; set; }
    public int Area { get; set; }
    public List<GDPData> GDPInfo { get; set; }}
public class GDPData
{
    public int Year { get; set; }
    public int GDP { get; set; }
}
and the example shows how to create a graph with the Year in the axis X, and 3 series (Countries) of GDP in the axis Y. (Correct this if I am expressing it wrong)
What I would like ti have in the same example is  graph with the Countries in the axis X, and 3 series (Years) of GDP in the axis Y, is it possible? (I dont know how many Countries I have, this is the reason I have to use a list!)
Link to comment
Share on other sites

Unfortunately the ListTransform will not help you in the chart you are trying to achieve, the list transform should only be used when you have a list of X and each X will be represented by a different series.

Note that if you could have the data like this

public class MyData

{

  public string Country {get;set;}

  public string Year {get; set;}

  public double Value {get;set;}

}

You could use the CrossDataTransform to create either a chart with countries in the X axis and as many series as Years or viceversa, years in the X axis and as many series as countries.

JuanC

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...