When I click the button, a line is created, and the method is called regularly to add points.
The line will be recreated when the button is clicked again.
The core code is as follows.
First add a line to the chart through the following code:
Code: Select all
private void btn_Click(object sender, EventArgs e)
{
tChart1.Series.Clear();
line = new Line(tChart1.Chart)
{
Title = "line1",
VertAxis = VerticalAxis.Both,
HorizAxis = HorizontalAxis.Both,
Color = colorBtn.BackColor
};
}
Code: Select all
public void AddPoint(double x, double y)
{
line.Add(x, y);
}