beltrams Posted August 13, 2010 Report Share Posted August 13, 2010 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. Quote Link to comment Share on other sites More sharing options...
JuanC Posted August 13, 2010 Report Share Posted August 13, 2010 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 Quote Link to comment Share on other sites More sharing options...
JuanC Posted August 13, 2010 Report Share Posted August 13, 2010 You can also set those properties in XAML xmlns:cfxData="clr-namespace:ChartFX.WPF.Data;assembly=ChartFX.WPF.Data"<cfx:Chart.DataTransforms> <cfxData:ListTransform ColumnPath="AxisYList" SeriesPath="AxisX"/></cfx:Chart.DataTransforms> JuanC Quote Link to comment Share on other sites More sharing options...
beltrams Posted August 18, 2010 Author Report Share Posted August 18, 2010 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!) Quote Link to comment Share on other sites More sharing options...
beltrams Posted August 18, 2010 Author Report Share Posted August 18, 2010 I also dont know how many years... Quote Link to comment Share on other sites More sharing options...
JuanC Posted August 18, 2010 Report Share Posted August 18, 2010 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 Quote Link to comment Share on other sites More sharing options...
beltrams Posted August 23, 2010 Author Report Share Posted August 23, 2010 Thanks! Actually I am not very sure why I was looking for that coplicated solution Thanks! Simone Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.