如何在MSchart中清除数据(点,系列)? [英] How to clear Data(Points, Series) in MSchart?

查看:207
本文介绍了如何在MSchart中清除数据(点,系列)?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在单击按钮时清除MSchart中的值

 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 作为 整数 = ts.Days

尝试


Dim < /跨度> str 作为 字符串 = 从员工中选择不同的empfullname,其中department ='Transcription'和designation =' + cmbDesig.Text + '按指定排序,empfullname
Dim ds As DataSet

ds = cnn.ExecuteDataset(str)


Dim ds2 作为 DataSet
对于 i < span class =code-keyword> As
整数 = 0 ds.Tables( 0 )。Rows.Count - 1

Dim cn 作为 整数 = 0
cmd.CommandText = select sum(actuallinecount) ,linecountdetails的指定where(dateoflinecount'' +格式(Convert.ToDateTime(dtpStart.Value), yyyy-MM-dd)+ '和' +格式(转换.ToDateTime(dtpEnd.Value), yyyy-MM-dd)+ ')和empfullname =' + ds.Tables( 0 )。行(i).ItemArray( 0 )。ToString()+
cmd.Connectio n = con
dr = cmd.ExecuteReader()
while dr.Read()
如果 dr( 0 DBNull.Value 然后
cn = 0
其他
cn = dr( 0
结束 如果

结束
dr。关闭()

Dim lc 作为 Double = cn
Chart1.Series( Series1)。Points.Add(lc).AxisLabel = ds.Tables( 0 )。行(i).ItemArray( 0 )。ToString()

Chart1.ChartAreas( ChartArea1)。AxisY.Title = 行数
Chart1.ChartAreas( ChartArea1)。AxisX.Title = 员工

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 异常

结束 尝试

解决方案

您需要清除每个系列中的值。

 chart.Series [  Series1]。Points.Clear(); 



我希望它会帮助你。 :)


.Clear()方法将清除给定系列的所有点。

 chart.Series [0] .Points.Clear (); 


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

解决方案

You'll need to clear the values from each of your Series.

chart.Series["Series1"].Points.Clear();


I hope it will help you. :)


.Clear() method will clear all points of given series.

chart.Series[0].Points.Clear();


这篇关于如何在MSchart中清除数据(点,系列)?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆