I have a project where I need to update a form every 60 seconds, and in the form there is a function to call the chart and when I execute the program, the form perfectly initializes the graph. I use the timer calling the function again to refresh the page the graph does not update and give an error message:
Could not find a chart element named
Series1
in SeriesCollection '. Here is the function:
DIM SQL AS STRING
SQL = SELECT TELE_MARKENTIG, VENDEDOR, TOTAL FROM PEDIDOS
Dim CArea As ChartArea = New ChartArea()
Dim LG As Legend = New Legend()
Dim Series1 As Series = New Series()
Dim Chart1 = New Chart()
Me.Controls.Add(Chart1)
CArea.Name = "ChartArea20"
Chart1.ChartAreas.Add(CArea)
''Legend1.Name = "Legend20"
Chart1.Legends.Add(LG)
Chart1.Location = New System.Drawing.Point(20, 20)
Chart1.Name = "Chart12"
Series1.ChartArea = "ChartArea20"
''Series1.Legend = "Legend20"
Series1.Name = "Vendas"
Chart1.Series.Add(Series1)
Chart1.Size = New System.Drawing.Size(300, 175)
'chtVendas.TabIndex = 0
'chtVendas.Text = "Chart1"
CArea.Position.Width = 75
CArea.Position.Height = 100
Chart1.Series("Vendas").XValueMember = "TELE_MARKETING"
Chart1.Series("Vendas").YValueMembers = "TOTAL"
Dim ds As New DataSet
Dim DATAADAPTER As New SqlClient.SqlDataAdapter(SQL, CN)
DATAADAPTER.Fill(ds, "VCTCS")
'''''''''''''''''''''''''''''
'~~> SET DATA SOURCE <~~'
'''''''''''''''''''''''''''''
Chart1.DataSource = ds.Tables("VCTCS")
Chart1.DataBind()