Hi all
Below is my chart window xaml code
<Window x:Class="GraphWin"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="Graph" Height="560" Width="630" xmlns:chartingToolkit="clr-namespace:System.Windows.Controls.DataVisualization.Charting;assembly=System.Windows.Controls.DataVisualization.Toolkit" Loaded="Window_Loaded">
<Grid>
<chartingToolkit:Chart DataContext="1,10 2,20 3,30 4,40" HorizontalAlignment="Left" Margin="12,12,0,0" Name="Chart1" Title="Chart Title" VerticalAlignment="Top" Height="352" Width="584">
<chartingToolkit:ColumnSeries DependentValuePath="X" IndependentValuePath="Y" ItemsSource="{Binding}" />
<chartingToolkit:PieSeries Name="PieChart" DependentValuePath="Value" IndependentValuePath="Key" ItemsSource="{Binding}"
IsSelectionEnabled="True" />
</chartingToolkit:Chart>
</Grid>
</Window>
and this is the back end code
Imports System.Data
Imports System.Data.SqlClient
Imports System.Configuration
Imports System
Imports System.Globalization
Imports System.Collections.ObjectModel
Imports System.Runtime.Remoting.Contexts
Public Class GraphWin
Private con As New SqlConnection("Data Source=501013-PC;Database=nand00132013;User Id=sa;Password=1234")
Sub ShowChart()
Dim MyValue As New List(Of KeyValuePair(Of String, Integer))()
Dim cmd As New SqlCommand("select top(5) AgencyName, Amount from SuppReport", con)
Dim da As New SqlDataAdapter(cmd)
Dim dt As New DataTable
da.Fill(dt)
For Each item As DataRow In dt.Rows
MyValue.Add(New KeyValuePair(Of String, Integer)(dt.Rows(0)("AgencyName"), dt.Rows(0)("Amount")))
Next
PieChart.DataContext = MyValue
End Sub
Private Sub Window_Loaded(ByVal sender As System.Object, ByVal e As System.Windows.RoutedEventArgs)
ShowChart()
End Sub
End Class
At this main window i have a button and on click the graph window will open
Dim g As New GraphWin
g.ShowChart()
but it's showing this
http://i40.tinypic.com/2jbqh69.png[
^]
Please tell me how to do this..