MultiSeries Line Chart from data of datagridview

  • Thread starter Thread starter exernon
  • Start date Start date
E

exernon

Guest
Hello!

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.IO;
using System.Windows.Forms.DataVisualization.Charting;
using iTextSharp.text;
using iTextSharp.text.pdf;

namespace linkchartgraph
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}

private void Form1_Load(object sender, EventArgs e)
{
// TODO: This line of code loads data into the 'database.Sensors' table. You can move, or remove it, as needed.
this.sensorsTableAdapter.Fill(this.database.Sensors);

}

private void btnSave_Click(object sender, EventArgs e)
{
try
{
sensorsBindingSource.EndEdit();
sensorsTableAdapter.Update(database.Sensors);
MessageBox.Show("Your data has been successfully saved.","Message",MessageBoxButtons.OK,MessageBoxIcon.Information );

}
catch(Exception ex)
{
MessageBox.Show(ex.Message, "Message", MessageBoxButtons.OK, MessageBoxIcon.Error);
}


private void btnLoad_Click(object sender, EventArgs e)
{
chart1.Series["A"].XValueMember = "V (V)";
chart1.Series["A"].YValueMembers = "I (A)";
chart1.DataSource = database.Sensors;
chart1.DataBind();
}
}
}

I have this code where i have a datagridview, chart, and a button.

Currently if I press the button, it will plot the data from selected columns in the datagridview to be the x and y in the line graph. Everytime I press the button, it will only show one line graph.

What I wanted to do is whenever I press the button, it will display another line on the chart. So there will be 2 line graph on the chart.

Can you help me with this problem? Thank you!

Continue reading...
 

Similar threads

Back
Top