WPF Chart binding to the CSV/TXT file

Jun 20, 2013 at 2:06 PM
Edited Jun 20, 2013 at 2:07 PM
How to bind the WPF Chart to the text file with tab separated values?

my first attempt does not show any data:
<chartingToolkit:Chart Name="myChart" Title="my Data">
        private void myWindow_Loaded(object sender, RoutedEventArgs e)
        {
            DataSet myDataSet = new DataSet1();
            myChart.DataContext = myDataSet;

            LineSeries myLineSerie1 = new LineSeries();
            myLineSerie1.Title = "Speed";
            
            myLineSerie1.ItemsSource = myDataSet.Tables[0].AsEnumerable();
            myLineSerie1.IndependentValueBinding = new Binding(myDataSet.Tables[0].Columns[0].Caption);
            myLineSerie1.DependentValueBinding = new Binding(myDataSet.Tables[0].Columns[1].Caption);

            LinearAxis myLinearAxisY = new LinearAxis();
            myLinearAxisY.Orientation = AxisOrientation.Y;
            myLinearAxisY.Title = "[km/hod]";
            myLineSerie1.DependentRangeAxis = myLinearAxisY;

            myChart.Series.Add(myLineSerie1);

            LinearAxis myLinearAxisX = new LinearAxis();
            myLinearAxisX.Orientation=AxisOrientation.X;
            myLinearAxisX.Title="Time";
            myLinearAxisX.Minimum=0;
            myLinearAxisX.Maximum=10;
            myLinearAxisX.ShowGridLines = true;
            myChart.Axes.Add(myLinearAxisX);

            myChart.UpdateLayout();
        }
Jun 21, 2013 at 9:44 AM
partially solved
            LinearAxis myLinearAxisX = new LinearAxis();
            myLinearAxisX.Orientation = AxisOrientation.X;
            myLinearAxisX.Title = "Time";
            //myLinearAxisX.Minimum = 0;
            //myLinearAxisX.Maximum = 100;
            myLinearAxisX.Location = AxisLocation.Bottom;
            myLinearAxisX.ShowGridLines = true;
            myChart.Axes.Add(myLinearAxisX);

            DataSet myDataSet = new DataSet1();

            myChartTest.DataSet1TableAdapters.simpleTab_txtTableAdapter myAdapter = new myChartTest.DataSet1TableAdapters.simpleTab_txtTableAdapter();
            DataSet1.simpleTab_txtDataTable myTable = new DataSet1.simpleTab_txtDataTable();
            myAdapter.Fill(myTable);

            myDataGrid.ItemsSource = myTable;

            LineSeries myLineSerie1 = new LineSeries();
            myLineSerie1.Title = "Speed";
            myLineSerie1.ItemsSource = myTable.AsEnumerable();
            myLineSerie1.IndependentValueBinding = new Binding(myTable.Columns[0].Caption);
            myLineSerie1.DependentValueBinding = new Binding(myTable.Columns[1].Caption);

            LinearAxis myLinearAxisY = new LinearAxis();
            myLinearAxisY.Orientation = AxisOrientation.Y;
            myLinearAxisY.Title = "[km/hod]";
            myLineSerie1.DependentRangeAxis = myLinearAxisY;
            myLineSerie1.DependentRangeAxis.Orientation = AxisOrientation.Y;

            myChart.Series.Add(myLineSerie1);

            myChart.UpdateLayout();