title: C# chart tools for line graph using external txt file data
body: <p>I want to plot a line graph using c# chart tool, what I have is an  external txt file with data, such as:</p>
  
  <blockquote>
    <p>1.2,1.0<br>
    1.3,1.5<br>
    1.4,2.0<br>
    1.5,2.5<br></p>
  </blockquote>
  
  <p>I want to read those data and plot a line graph, I am stuck.</p>
  
  <p>Below is my code. I am able to plot a line graph using a some automated data as shown.</p>
  
  <pre><code>OpenFileDialog openFileDialog1 = new OpenFileDialog();//creation and inialization of open file dialog 
  
  openFileDialog1.InitialDirectory = @"C:\";// object of file dialog  sent to open file to default c drive
  openFileDialog1.Title = "Browse txt File";// text to show on the bar
  
  openFileDialog1.CheckFileExists = true;// check whether file exit
  openFileDialog1.CheckPathExists = true;//check file path
  
  openFileDialog1.DefaultExt = "txt";// the file default extensio
  openFileDialog1.Filter = "Text files (*.txt)|*.txt|All files (*.*)|*.*";//filter by default to only txt files
  openFileDialog1.FilterIndex = 2;
  openFileDialog1.RestoreDirectory = true;
  
  openFileDialog1.ReadOnlyChecked = true;
  openFileDialog1.ShowReadOnly = true;
  
  if (openFileDialog1.ShowDialog() == DialogResult.OK)// prompt for a file dialog
  {
      double t, y, tIncr;
      chtSin.ChartAreas.Add("Default");
      // Add a series with some data points.
      Series sinSeries = new Series();
      sinSeries.ChartType = SeriesChartType.Line;
      tIncr = 4 * Math.PI / 500;
      for (t = 0; t &lt; 4 * Math.PI; t += tIncr)
      {
          y = Math.Sin(2 * Math.PI * t);
          sinSeries.Points.AddXY(t, y);
      }
      Series cosSeries = new Series();
      cosSeries.ChartType = SeriesChartType.Line;
      tIncr = 4 * Math.PI / 500;
      for (t = 0; t &lt; 4 * Math.PI; t += tIncr)
      {
          y = Math.Cos(2 * Math.PI * t);
          cosSeries.Points.AddXY(t, y);
      }
      chtSin.Series.Add(sinSeries);
      chtSin.Series[0].Color = Color.Black;
      chtSin.Series.Add(cosSeries);
      chtSin.Series[1].Color = Color.Red;
      chtSin.ChartAreas[0].AxisX.Title = "Time";
      chtSin.ChartAreas[0].AxisX.LabelStyle.Format = "{0.00}";
      chtSin.ChartAreas[0].AxisY.Title = "Volts";
      chtSin.ChartAreas[0].AxisY.LabelStyle.Format = "{0.00}";
  }
  </code></pre>