I've just started playing around with the Binding_to_a_Collection sample using the XAMChart and changing the 'Chart Type' is simple enough but when trying to modify it so for example I'm plotting 'weight' on the X axis with everything else on the Y axis I'm a bit lost.
I'm planning on using a line or spline type chart and databinding my observable collection to it. So if someone could show me how to make the modification with the sample below I'd really appreciate it.
MainWindow.xaml------------------
<Window x:Class="MainWindow" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:igCA="http://infragistics.com/Chart" xmlns:local="clr-namespace:SampleChart.Binding_to_a_Collection" Title="MainWindow" Height="350" Width="525"> <Window.Resources> <ObjectDataProvider x:Key="PatientData" ObjectType="{x:Type local:PatientBusinessLogic}" MethodName="GetPatients"/> </Window.Resources> <Grid> <igCA:XamChart View3D="False"> <igCA:XamChart.Series> <igCA:Series Label="Patient Height" ChartType="Column" DataSource ="{Binding Source={StaticResource PatientData}}" DataMapping="Value = Height" /> <igCA:Series Label="Patient Weight" ChartType="Column" DataSource="{Binding Source={StaticResource PatientData}}" DataMapping="Value = Weight" /> <igCA:Series Label="Patient Systolic A.P." ChartType="Column" DataSource="{Binding Source={StaticResource PatientData}}" DataMapping="Value = SystolicPressure" /> <igCA:Series Label="Patient Dyastolic A.P." ChartType="Column" DataSource="{Binding Source={StaticResource PatientData}}" DataMapping="Value = DiastolicPressure" /> </igCA:XamChart.Series> </igCA:XamChart> </Grid></Window>
Patient.vb class-------------------------------
Imports System.ComponentModelImports System.Collections.ObjectModelNamespace Binding_to_a_Collection Public Class Patient Implements INotifyPropertyChanged Private patient_nameID As Integer Public Property NameID() As Integer Get Return patient_nameID End Get Set(ByVal value As Integer) If patient_nameID <> value Then patient_nameID = value NotifyPropertyChanged("Name") End If End Set End Property Private patient_height As Integer Public Property Height() As Integer Get Return patient_height End Get Set(ByVal value As Integer) If patient_height <> value Then patient_height = value NotifyPropertyChanged("Height") End If End Set End Property Private patient_weight As Integer Public Property Weight() As Integer Get Return patient_weight End Get Set(ByVal value As Integer) If patient_weight <> value Then patient_weight = value NotifyPropertyChanged("Weight") End If End Set End Property Private patient_systolic_pressure As Integer Public Property SystolicPressure() As Integer Get Return patient_systolic_pressure End Get Set(ByVal value As Integer) If patient_systolic_pressure <> value Then patient_systolic_pressure = value NotifyPropertyChanged("SystolicPressure") End If End Set End Property Private patient_diastolic_pressure As Integer Public Property DiastolicPressure() As Integer Get Return patient_diastolic_pressure End Get Set(ByVal value As Integer) If patient_diastolic_pressure <> value Then patient_diastolic_pressure = value NotifyPropertyChanged("DiastolicPressure") End If End Set End Property Public Sub New(ByVal nameID As Integer, ByVal weight As Integer, ByVal height As Integer, ByVal systolicPressure As Integer, ByVal diastolicPressure As Integer) Me.NameID = nameID Me.Weight = weight Me.Height = height Me.SystolicPressure = systolicPressure Me.DiastolicPressure = diastolicPressure End Sub#Region "INotifyPropertyChanged Members" 'Public Event PropertyChanged As PropertyChangedEventHandler Private Sub NotifyPropertyChanged(ByVal propertyName As String) RaiseEvent PropertyChanged(Me, New PropertyChangedEventArgs(propertyName)) End Sub Public Event PropertyChanged(ByVal sender As Object, ByVal e As System.ComponentModel.PropertyChangedEventArgs) _ Implements System.ComponentModel.INotifyPropertyChanged.PropertyChanged#End Region End ClassEnd Namespace
PatientBusinessLogic.vb class------------------------------------
Imports System.ComponentModelImports System.Collections.ObjectModelNamespace Binding_to_a_Collection Public Class PatientBusinessLogic Public Function GetPatients() As ObservableCollection(Of Patient) Dim patients As New ObservableCollection(Of Patient)() Dim p As New Patient(1008, 160, 70, 105, 70) patients.Add(p) p = New Patient(1007, 145, 66, 111, 77) patients.Add(p) p = New Patient(1009, 190, 71, 90, 60) patients.Add(p) Return patients End Function End ClassEnd Namespace
Hello rsgyde,
It has been a while since you made this post, you still need any support on the matter I will be glad to help. I was looking into this issue and I can suggest you change the DataMapping for the series. If you want the Weight to be displayed on the X axis and everything else on Y you can specify the mapping so the Label=Weight for all of the series.:
<igCA:Series Label="Patient Height" ChartType="Line" DataSource ="{Binding Source={StaticResource PatientData}}" DataMapping="Value = Height; Label=Weight" />
<igCA:Series Label="Patient Systolic A.P." ChartType="Line" DataSource="{Binding Source={StaticResource PatientData}}" DataMapping="Value = SystolicPressure; Label=Weight" />
<igCA:Series Label="Patient Dyastolic A.P." ChartType="Line" DataSource="{Binding Source={StaticResource PatientData}}" DataMapping="Value = DiastolicPressure; Label=Weight" />
For further reference, please have a look at the attached sample, also you can check the following link from our documentation where you can find detail information about the data mapping:
http://help.infragistics.com/Help/NetAdvantage/WPF/2011.1/CLR4.0/html/xamChart_DataMapping_for_xamChart.html .
If you still need any further assistance on the matter, please do not hesitate to ask.