I'm trying to build a chart using the columnSeries from the wpf toolkit and I appear to be having trouble with the data binding. Here is the xaml:
<Grid>
<chartingToolkit:ColumnSeries Height="18" HorizontalAlignment="Left" Margin="188,169,0,0" Name="columnSeries1" VerticalAlignment="Top" Width="18" IndependentValueBinding="{Binding Path=Date}" DependentValueBinding="{Binding Path=Value}" />
</Grid>
In the code behind, I'm calling a stored procedure and putting the result in a datatable like this:
string connString = ConfigurationManager.ConnectionStrings["string"].ConnectionString;
using (SqlConnection cn = new SqlConnection(connString))
{
DataTable dt = new DataTable("T1");
cn.Open();
SqlCommand cmd = new SqlCommand("T1_sp", cn);
cmd.CommandType = CommandType.StoredProcedure;
SqlDataAdapter da = new SqlDataAdapter(cmd);
da.Fill(dt);
columnSeries1.ItemsSource = dt.DefaultView;
cn.Close();
}
No error is being generated but I'm not getting a column chart either. If I take the same command and put it into a datagrid, it works fine. What do I need to do to get this into my column chart?
If it helps, the data comming back in the data tables looks like this:
Date, type, Value
2009-10-09, abc, 12.23
2009-10-10, def, 13.35
The date should be the Independent value binding and the value should be the dependent value binding.