I have 2 column from a datatable that i want to bind to chart. Visifire sample shows example using observablecollection but i dont know how to relate datatable to observablecollection(which i think is my problem). I created a sample to visualize. I am using visifire for the charts.
public MainWindow()
{
InitializeComponent();
dtBandwidth = dsBandwidth.Tables.Add();
dtBandwidth.Columns.Add("ID", typeof(int));
dtBandwidth.Columns.Add("Time", typeof(double));
dtBandwidth.Columns.Add("Value", typeof(double));
dataGrid1.ItemsSource = dtBandwidth.DefaultView;
DataSeries ds = new DataSeries();
ds.RenderAs = RenderAs.Line;
ds.DataSource = dtBandwidth???; //i know this is wrong. what should i do?
DataMapping dm = new DataMapping();
dm.MemberName = "XValue";
dm.Path = "Time";
ds.DataMappings.Add(dm);
dm = new DataMapping();
dm.MemberName = "YValue";
dm.Path = "Value";
ds.DataMappings.Add(dm);
chart1.Series.Add(ds);
chart1.DataContext = dtBandwidth???; //i know this is wrong. what should i do?
}
private void button1_Click(object sender, RoutedEventArgs e)
{
dtBandwidth.Rows.Add(1, 1.0, 5.2);
dtBandwidth.Rows.Add(2, 2.1, 5.1);
dtBandwidth.Rows.Add(3, 3.2, 5.3);
dtBandwidth.Rows.Add(4, 4.3, 5.4);
dtBandwidth.Rows.Add(5, 5.4, 5.5);
}
and here are the xaml.
<Grid>
<DataGrid AutoGenerateColumns="True" Height="311" HorizontalAlignment="Left" Name="dataGrid1" VerticalAlignment="Top" Width="143" />
<my:Chart HorizontalAlignment="Left" Margin="149,0,0,0" Name="chart1" VerticalAlignment="Top" Height="311" Width="354" />
<Button Content="Button" Height="23" HorizontalAlignment="Left" Margin="186,328,0,0" Name="button1" VerticalAlignment="Top" Width="75" Click="button1_Click" />
</Grid>
I did try ask on the official visifire forum but the support guy was just plain lazy(which told me to look at the sample when i did told them i already look at the sample. plus, portion of the code are copied from the sample).
this kind of things makes me want to ditch visifire and look for alternative preferably with good documentation and support. any suggestion are welcome.