Quantcast
Viewing all articles
Browse latest Browse all 18858

WPF Toolkit Chart Bound to XMLDataProvider

I am trying to chart some data which is in an XML file.  I have downloaded and installed the 2010 WPF Toolkit.  Here is a snippet of the XML file.

<Profiles xmlns="" ActiveProfile="3">
<Profile Id="3" Desc="Test" Port="2" Baud="9600" DataBits="8" Parity="2" StopBits="1" CmdDelay="50" ReadTimeout="250" ProcInterval="10" SetInterval="5000" DecInterval="30000" ChartInterval="3000" SaveInterval="0"><PIDs><PID Address="1" ProcVal="-147.4" SetPoint="410" DecPlaces="1" /><PID Address="2" ProcVal="-1454" SetPoint="4200" DecPlaces="0" /><PID Address="3" ProcVal="-1462" SetPoint="4300" DecPlaces="0" /><PID Address="4" ProcVal="-1462" SetPoint="4400" DecPlaces="0" /></PIDs></Profile>
</Profiles>

Here is some relevant (I hope) XAML:

xmlns:charting="clr-namespace:System.Windows.Controls.DataVisualization.Charting;assembly=System.Windows.Controls.DataVisualization.Toolkit"<XmlDataProvider x:Name="PIDData" x:Key="PIDData" Source ="Settings.xml" XPath="Settings/Profiles"/><charting:Chart Name="LineChart" HorizontalAlignment="Left" VerticalAlignment="Top" Margin="480,140,0,0" Width="270"><charting:LineSeries Title="1" DataContext="{Binding Source={StaticResource PIDData}}" ItemsSource="{Binding XPath=Profile[@Id\=../@ActiveProfile]/PIDs/PID}" 
                         DependentValueBinding="{Binding XPath=@ProcVal}" IndependentValueBinding="{Binding XPath=@Address}" IsSelectionEnabled="True"></charting:LineSeries></charting:Chart>

I think I totally jacked up the XAML definition for my line chart.  What I want is to graph the "ProcVal" value from each of the 4 XML items above.  There may be more, this is dependent upon a data-gathering thread.  I keep getting the error: "no suitable axis is available for plotting the dependent value".

I would like the graph updated every so often, the interval hopefully obtained from the "ChartInterval" value of the parent XML element.

I've never used the toolkit, so this is my first try at mapping the line chart to my XML data.  Can anybody help with example code?  If a combination of XAML and code-behind is needed, could you please provide an example?

Thanks...



Ron Mittelman




Viewing all articles
Browse latest Browse all 18858

Trending Articles