Hello, I know it’s been a while since you posted and warned me via face but only now I could really look at it.
In this example you are creating a new graphic and adding in the collection, you could check if there is already an instance of the class in the Controls collection and pick it up but tried to do some experiments and it is very boring so my suggestion is the following.
An object you add to the collection keeps its reference as long as the scope it was created is still active, what you can do is the following.
Declare variable in form scope
public partial class Form1 : Form
{
System.Windows.Forms.DataVisualization.Charting.Chart cht_MacroOndas;
Check when updating the chart if the variable has not already been instantiated and only create a new case need
private void button1_Click(object sender, EventArgs e)
{
if (cht_MacroOndas == null)
{
cht_MacroOndas = new Chart();
this.Controls.Add(cht_MacroOndas);
}
ConfigurarChat(cht_MacroOndas);
}
Remember to clean the collections when using the previous Chart object, I put this Configurarchat method just to make it clear that at this point you would set the graph, in it you would have to reset the Series collections, Legends, Chartareas or any other you add when filling in the data.