0

I create a small program for data analysis, I download data from the SQL database, sortering and display it on the dataGridView, and then, based on the data from the dataGridView, I create a chart1. I'm having trouble adding a trendline to this chart1. I'm creates a chart1 using code:

chart1.ChartAreas.Add("WY");
        chart1.ChartAreas.Add("ZA");
        for (int i = 0; i < dataGridView1.Rows.Count - 1; i++)
        {
            this.chart1.Series["WY"].Points.AddXY(dataGridView1.Rows[i].Cells[0].Value.ToString(), Convert.ToDouble(dataGridView1.Rows[i].Cells["WY"].Value.ToString()));
            this.chart1.Series["ZA"].Points.AddXY(dataGridView1.Rows[i].Cells[0].Value.ToString(), Convert.ToDouble(textBox4.Text.ToString()));

Unfortunately, I am looking for a good solution on the web, but I cannot cope with it. Does anyone know a good solution to add trend lines optionally on the chart?

  • A first search found these links [1](https://www.codeproject.com/Questions/224097/How-to-draw-trendline-in-graph-using-Windows-Forms), [2](https://social.msdn.microsoft.com/Forums/en-US/ce9e1f8c-147b-401a-a59e-29fb23283271/how-to-add-a-linear-trendline-to-a-single-series-vb-chart?forum=vbgeneral), [3](https://stackoverflow.com/questions/9969331/add-trendline-to-asp-net-chart), [4](https://social.msdn.microsoft.com/Forums/en-US/2c2740f2-22d0-41ec-873d-6c275a0afecb/trend-lines?forum=MSWinWebChart) – TaW Oct 27 '21 at 09:10
  • I saw these articles but they did not help me solve my problem – Mlody_pb Oct 27 '21 at 11:04

0 Answers0