none
Help with Creating a Chart using WPF and VB.NET

    Question

  • I have a table with 3 bits of information. 1) The resource name column, 2) A date column, 3) The percentage that resource is utilized on that day. I would like to display this information in a chart, but my attempts thus far have failed.

    Here is the XAML code I have:

    <charting:Chart HorizontalAlignment="Left" 
                                   Margin="12,0,0,0" 
                                   Name="chtResource" 
                                   Title="Resource Overview" 
                                   VerticalAlignment="Bottom" 
                                   Height="588" Width="776">
                <charting:Chart.Axes>
                    <charting:DateTimeAxis Name="Xaxis" Orientation="X" ShowGridLines="True" Height="100">
                        <charting:DateTimeAxis.AxisLabelStyle>
                            <Style TargetType="charting:DateTimeAxisLabel">
                                <Setter Property="StringFormat" Value="{}{0:MM/dd/yyyy}"/>
                                <Setter Property="VerticalContentAlignment" Value="Bottom"/>
                                <Setter Property="HorizontalContentAlignment" Value="Center"/>
                                <Setter Property="RenderTransformOrigin" Value="1,0.5"/>
                                <Setter Property="RenderTransform">
                                    <Setter.Value>
                                        <RotateTransform Angle="-90"/>
                                    </Setter.Value>
                                </Setter>
                            </Style>
                        </charting:DateTimeAxis.AxisLabelStyle>
                    </charting:DateTimeAxis>
                    
                    <charting:CategoryAxis Name="Yaxis" Orientation="Y" ShowGridLines="True"/>
                </charting:Chart.Axes>
    
                <charting:Chart.Series>
                    <charting:BubbleSeries Name="BubbleCht"
                                           ItemsSource="{Binding}" 
                                           DependentValuePath="Name"
                                           DependentRangeAxis="{Binding ElementName=Yaxis}"
                                           IndependentValuePath="Date"
                                           IndependentAxis="{Binding ElementName=Xaxis}"
                                           IsSelectionEnabled="True"/>
                </charting:Chart.Series>
                
            </charting:Chart>
    

    Here is a snippit of the VB.NET code behind this:

    BubbleCht.DataContext = chtTable.DefaultView
    Xaxis.Minimum = chtTable.Select(Nothing, "Date").First.Field(Of Date)("Date")
    Xaxis.Maximum = chtTable.Select(Nothing, "Date DESC").First.Field(Of Date)("Date")
    
    BubbleCht.UpdateLayout()
    

    Any help would be much appreciated.

    Thursday, October 13, 2011 12:55 PM

All replies