Hi Infragistics, as a helloworld exercise, I've got a line series , databound dynamically to a datastructure as follows:
public class MyDataCollection : ObservableCollection {
xaml:
works fine, all is well.
However, my goal -- What I am trying to do -- is databind to a member property , and not a single object, so as to support multple series:
public class MyDataCollection {
public ObservableCollection series1;
public ObservableCollection series2;
public ObservableCollection bubble1;
and in the xaml
<ig:LineSeries x:Name="line1" ItemsSource="{Binding Path=series1}" ValueMemberPath="myvalue" ...
<ig:LineSeries x:Name="line2" ItemsSource="{Binding Path=series2}" ValueMemberPath="myvalue" ...
<ig:BubbleSeries x:Name="bubble1" ItemsSource="{Binding Path=bubble1}" XMemberPath="week" ....
The binding path doesn't appear to be working. What's up with this? do you have a sample ( simple sample ) with dynamic databinding of multiple series ?
This is 15.2
Hello Martin,
From the sample code that you have provided, I wouldn't expect that you would be able to bind to your ObservableCollections series1, series2, or bubble1, as you are missing the get and set declarations to actually make them properties. Binding to multiple collections in this case may not actually help you, though, especially if your CategoryXAxis or CategoryDateTimeXAxis is shared between your two LineSeries. You would need to have the same number of categories, with the same values in your series1 and series2 collection as in the collection that is bound to the shared CategoryXAxis, otherwise, you would not see anything in the XamDataChart.
Instead, I would probably recommend a separate property on your MyDataPoint class so that you can modify the ValueMemberPath in each of your LineSeries, but keep them bound to the same collection. If you wanted to do this dynamically, and possibly "add a property" at runtime, I would recommend using a DataTable for this, as each of the Columns could serve as its own property, and you could add columns and series corresponding to those columns at runtime.
For more about hosting multiple series in the XamDataChart at one time, I would recommend that you see the following article in our online documentation: http://help.infragistics.com/doc/WPF/2015.2/CLR4.0/?page=DataChart_Multiple_Series.html.
I hope this helps you. Please let me know if you have any other questions or concerns on this matter.
Sincerely,AndrewAssociate Developer
THanks for getting back with me,
here's actual code ( not pseudo code ). The sample multiseries is overly complicated IMO.
private void Chart_Loaded(object sender, RoutedEventArgs e) { MyDataCollection myData = new MyDataCollection(100); HelloChart.DataContext = myData; }
namespace GraphCreator{ public class MyDataCollection { public ObservableCollection<MyDataPoint> Upper { get; set; }
public MyDataCollection(int points) { Upper = new ObservableCollection<MyDataPoint>(); DateTime dtStart = DateTime.Now.AddDays(-points); for (int i = 1; i < points; i++) { double value = Math.Log(2 * i); dtStart = dtStart.AddDays(i); Upper.Add(new MyDataPoint(value, dtStart)); }
}
public MyDataCollection() { Upper = new ObservableCollection<MyDataPoint>(); DateTime dtStart = DateTime.Now.AddDays(-5); for (int i = 1; i < 5; i++) { double value = Math.Log(2 * i);
dtStart = dtStart.AddDays(i); Upper.Add(new MyDataPoint(value, dtStart)); } }
public class MyDataPoint : INotifyPropertyChanged { public double myvalue { get; set; } public DateTime week { get; set; } public MyDataPoint() { myvalue = 0; week = DateTime.Now; }
public MyDataPoint(double val, DateTime wk) { myvalue = val; week = wk; if (PropertyChanged != null) this.PropertyChanged(this, new PropertyChangedEventArgs("myvalue")); }
public event PropertyChangedEventHandler PropertyChanged; }
xaml
<ig:XamDataChart x:Name="HelloChart" HorizontalAlignment="Left" Margin="20,25,0,0" VerticalAlignment="Top" Height="275" Width="470" Loaded="Chart_Loaded"> <ig:XamDataChart.DataContext> <local:MyDataCollection/> </ig:XamDataChart.DataContext> <ig:SyncManager.SyncSettings> <ig:SyncSettings SyncChannel="syncDynamicCharts" SynchronizeHorizontally="True" SynchronizeVertically="False" /> </ig:SyncManager.SyncSettings> <ig:XamDataChart.Axes> <ig:CategoryXAxis x:Name="VolumeXAxis" ItemsSource="{Binding}" Label="{}{Date:MMM yyyy}" /> <ig:NumericYAxis x:Name="VolumeYAxis" /> </ig:XamDataChart.Axes> <ig:XamDataChart.Series> <ig:LineSeries x:Name="upper" ItemsSource="{Binding Path=Upper}" ValueMemberPath="myvalue" Foreground="#FF1CD435" XAxis="{Binding ElementName=VolumeXAxis}" YAxis="{Binding ElementName=VolumeYAxis}" />
so what am I missing here?
I figured it out , the xaxis databinding hadn't been changed
<ig:XamDataChart.Axes> <ig:CategoryXAxis x:Name="VolumeXAxis" ItemsSource="{Binding Upper}" Label="{}{Date:MMM yyyy}" />
Thank you for your response. I am glad you were able to work out why the XamDataChart was not displaying your series.
Please let me know if you have any other questions or concerns on this matter.