I have a collection of objects that contain everything that I need to create a series and I want to use a DataTemplate to create series for however many objects are in the collection. Unfortunately, it seems that there are no DataTemplate examples in any of your explanations and I don't know if this is even possible.
Is it possible to create a number of series at runtime using DataTempates?
Hello Ed,
I am just checking the progress of this issue and was wondering if you managed to achieve your goal or if you need any further assistance on the matter.
After reviewing the multiple series examples, I was forced to change from a MVVM ViewModel which contained the data, to the less desirable data code behind. I am almost finished with the changeover, but I feel this is far from ideal.
I was also hoping I could place all of my Series into the SeriesCollection and have them automatically displayed, but I don't see how to bind the SeriesCollection with the XamDataSource or ItemsSource.
Additionally, the documentation link for SeriesCollection is broken, so I can't review any code samples about this.
Here is a working link for the SeriesCollection class:
http://help.infragistics.com/NetAdvantage/WPF/CLR4.0/?page=InfragisticsWPF4.Controls.Charts.XamDataChart.v12.2~Infragistics.Controls.Charts.SeriesCollection_members.html
Thank you for the working link. Unfortunately, there aren't any examples of how I can use the SeriesCollection to bind my data to a Chart.
Let me describe my data structure to you and see if you can help me graph the data within it. I have a collection of objects that have collections with the data to be visualized. The object is called CustomData as shown below.
public CodeBehind : INotifyPropertChanged
{
private ObservableCollection<CustomData> masterData = new ObservableCollection<CustomData>();
public CodeBehind()
CustomData dat1 = new CustomData();
dat1.Header = "Thermo1";
dat1.Data.Add(11.053);
dat1.Data.Add(12.41);
dat1.Data.Add(14.38);
dat1.Data.Add(15.89);
CustomData dat2 = new CustomData();
dat2.Header = "Thermo2";
dat2.Data.Add(17.09);
dat2.Data.Add(12.41);
dat2.Data.Add(13.038);
dat2.Data.Add(19.879);
MasterData.Add(dat1);
MasterData.Add(dat2);
}
public ObservableCollection<CustomData> MasterData
get
{ return masterData;}
public class CustomData
private string header; private List<double> data = new List<double>();
public string Header
{ get
{return header;}
public List<double> Data
{return data;}
Now my XAML, reduced for brevity:
<ig:XamDataChart Grid.Column="1" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Name="Chart" DataContext="{Binding MasterData}"> <ig:XamDataChart.Axes> <ig:NumericXAxis Name="xAxis" Visibility="Visible" > <ig:NumericXAxis.LabelSettings > <ig:AxisLabelSettings Location="OutsideBottom" Extent="20" /> </ig:NumericXAxis.LabelSettings> </ig:NumericXAxis> <ig:NumericYAxis Name="y1Axis" Visibility="Visible"> <ig:NumericYAxis.LabelSettings > <ig:AxisLabelSettings Location="OutsideLeft" Extent="20" /> </ig:NumericYAxis.LabelSettings> </ig:NumericYAxis> <ig:NumericYAxis Name="y2Axis" Visibility="Visible"> <ig:NumericYAxis.LabelSettings > <ig:AxisLabelSettings Location="OutsideRight" Extent="20" /> </ig:NumericYAxis.LabelSettings> </ig:NumericYAxis> </ig:XamDataChart.Axes> <ig:XamDataChart.Series> <ig:ScatterLineSeries Thickness="5" ItemsSource="{Binding}" XAxis="{Binding ElementName=xAxis}" YAxis="{Binding ElementName=y1Axis}" XMemberPath="MasterCollection[0].Data" YMemberPath="MasterCollection[1].Data"/> </ig:XamDataChart.Series> </ig:XamDataChart>
I was using a tool from another vendor which had no trouble working out the path for the IEnumerable element in the collection to graph the data. However, I really would like to standardize on just using Infragistic's tools as I am already using your XamDataGrid tool. Is it possible you can help?
I have been looking into your Data model and I can say that our DataChart is not designed to work with that kind if data. Both X and Y values should be Proeprties of one class. If you modifiy your data that way it will be easy to display it using our chart.
Hope this helps you.
Is there a way to bind a Series of the XamDataChart to a Column in a DataTable like you did in this how to article ? This would work well for my needs, but it seems like you have used a different kind of chart for this example.
The link you provided is a step by step guidance for WindowsForms UltraChart. I have used a similar approach with DataTabel bound to WPF’s XamDataChart to create a sample project for you with the same functionality.
Hi Team,
Can we display dynamic multiple series in bar chart type.Do you have any sample to do that.
Regards,
Sridhar
Thank you for your feedback. I am glad that you resolved your issue and I believe that other community members may benefit from this as well.
Thanks again.
Thanks Stefan, I will use this information moving forward!
Ed
Our developers said that this behavior is expected since the DataTable doesn't implement INotifyPropertyChanged interface and the XamDataChart cannot be notified when the DT changes, so I can suggest you use reset the DataContext like this in the timer_Tick event handler:
private void timer_Tick(object sender, EventArgs e) { int x, y; x = rand.Next(3, 23); y = rand.Next(3, 26); table.Rows.Add(new object[] { "Point", x, y }); this.DataContext = null; this.DataContext = table.DefaultView; }
Hope this heslp you.
Thank you much for your help Stefan!