2
I have a project where I need to update a form every 60 seconds, and in the form there is a function to call Chart (graphic) and when I run the program the form perfectly initializes the graph but when I use the timer calling the function again to refresh the page the chart does not refresh and give an error message:
Could not find a chart widget named
Series1
in Seriescollection'. Follows 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()
Thanks for trying to help. Analyzing the error well I found that I had to remove Chart to solve the problem and I used the following code: Chart1.Series.Remove(Series1)
– rogerio.engineer
@Rogerio.Ngineer have you found your own solution? Post it as an answer and accept it. This can even help you gain a reputation and leave it out to other people.
– Maniero
thanks. thanks. .
– rogerio.engineer