Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: VB.NET
How to clear values in MSchart when click button
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 29-Nov-11 0:51am
anjali21.3K
Edited 29-Nov-11 1:11am
v2
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

You'll need to clear the values from each of your Series.
chart.Series["Series1"].Points.Clear();
I hope it will help you. Smile | :)
  Permalink  
Comments
anjutlya at 29-Nov-11 7:18am
   
Thanks
RaisKazi at 29-Nov-11 7:24am
   
My 5.
Manoj K Bhoir at 29-Nov-11 7:25am
   
Thanks RaisKazi!
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

.Clear() method will clear all points of given series.
chart.Series[0].Points.Clear();
  Permalink  
Comments
RaisKazi at 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)

  Print Answers RSS
0 Sergey Alexandrovich Kryukov 520
1 OriginalGriff 339
2 ChintanShukla 305
3 Richard Deeming 235
4 RyanDev 230
0 Sergey Alexandrovich Kryukov 8,858
1 OriginalGriff 7,451
2 CPallini 2,603
3 Richard MacCutchan 2,095
4 Abhinav S 1,893


Advertise | Privacy | Mobile
Web01 | 2.8.140827.1 | Last Updated 29 Nov 2011
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100