Click here to Skip to main content
15,878,048 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
How to clear values in MSchart when click button
VB
con.Open()
        '********************************************************************
        Dim startDate As DateTime = DirectCast(dtpStart.Value, DateTime)
        Dim endDate As DateTime = DirectCast(dtpEnd.Value, DateTime)
        Dim ts As TimeSpan = endDate.Subtract(startDate)

        Dim days As Integer = ts.Days

        Try


            Dim str As String = "select distinct empfullname from employee where department='Transcription' and designation='" + cmbDesig.Text + "' order by designation, empfullname "
            Dim ds As DataSet

            ds = cnn.ExecuteDataset(str)


            Dim ds2 As New DataSet
            For i As Integer = 0 To ds.Tables(0).Rows.Count - 1

                Dim cn As Integer = 0
                cmd.CommandText = "select sum(actuallinecount), designation from linecountdetails where (dateoflinecount between '" + Format(Convert.ToDateTime(dtpStart.Value), "yyyy-MM-dd") + "' and '" + Format(Convert.ToDateTime(dtpEnd.Value), "yyyy-MM-dd") + "') and empfullname='" + ds.Tables(0).Rows(i).ItemArray(0).ToString() + "' "
                cmd.Connection = con
                dr = cmd.ExecuteReader()
                While dr.Read()
                    If dr(0) Is DBNull.Value Then
                        cn = 0
                    Else
                        cn = dr(0)
                    End If

                End While
                dr.Close()

                Dim lc As Double = cn
                Chart1.Series("Series1").Points.Add(lc).AxisLabel = ds.Tables(0).Rows(i).ItemArray(0).ToString()

                Chart1.ChartAreas("ChartArea1").AxisY.Title = "Line Count"
                Chart1.ChartAreas("ChartArea1").AxisX.Title = "Employee"

                Chart1.ChartAreas("ChartArea1").AxisX.Interval = 1
                Chart1.ChartAreas("ChartArea1").AxisX.IntervalOffset = 1

                Chart1.Series("Series1").Points(i).ToolTip() = lc
            Next
            'End If

            Chart1.DataSource = ds.Tables("linecountdetails")
            Chart1.DataBind()

            con.Close()

        Catch ex As Exception

        End Try
Posted
Updated 9-Mar-16 7:38am
v2

You'll need to clear the values from each of your Series.
VB
chart.Series["Series1"].Points.Clear();

I hope it will help you. :)
 
Share this answer
 
Comments
anjali2 29-Nov-11 7:18am    
Thanks
RaisKazi 29-Nov-11 7:24am    
My 5.
Manoj K Bhoir 29-Nov-11 7:25am    
Thanks RaisKazi!
.Clear() method will clear all points of given series.
chart.Series[0].Points.Clear();
 
Share this answer
 
Comments
RaisKazi 29-Nov-11 7:24am    
My 5.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900