Java 刷新图表而不复制数据

Java 刷新图表而不复制数据,java,vb.net,Java,Vb.net,我有一个图表,刷新时会重复 事实上,我用以下代码清除了图表: chrt.Series.Clear() chrt.Titles.Clear() 然后我再次调用chart函数来显示图表中的值 当我这样做时,它只是复制调色板 代码: 您需要一步一步地浏览代码,以查看图表是如何填充的。从您提供的详细信息中,我们无法猜测为什么会发生这种情况。strotsplit的定义在哪里? connection = New MySqlConnection("server=localhost;userid=root;p

我有一个图表,刷新时会重复

事实上,我用以下代码清除了图表:

chrt.Series.Clear()
chrt.Titles.Clear()
然后我再次调用chart函数来显示图表中的值

当我这样做时,它只是复制调色板

代码:


您需要一步一步地浏览代码,以查看图表是如何填充的。从您提供的详细信息中,我们无法猜测为什么会发生这种情况。strotsplit的定义在哪里?
connection = New MySqlConnection("server=localhost;userid=root;password='';database= inventory_control")

        connection.Open()
        Dim cmdstring1 As String = "SELECT COUNT(DISTINCT(quantity)) from inventory"
        Dim cmdstring As String = "SELECT category, quantity from inventory"
        command = New MySqlCommand(cmdstring, connection)
        command1 = New MySqlCommand(cmdstring1, connection)

        Dim intResult As Integer = command.ExecuteNonQuery

        MsgBox(intResult)
        Dim reader As MySqlDataReader
        reader = command.ExecuteReader(CommandBehavior.CloseConnection)
        'Read data from column
        While reader.Read()
            strTosplit += reader("category") & " "
            strQty += reader("quantity") & ", "
        End While
        'Remove empty string from array
        Dim xValues() As String = strTosplit.Split(New Char() {" "}, StringSplitOptions.RemoveEmptyEntries).Where(
            Function(s) Not String.IsNullOrWhiteSpace(s)
                ).ToArray()
        Dim zValues() As String = strQty.Split(New Char() {","})


        ' Dim xValues() As String =  

        Dim yValues() As Integer = (From str In zValues
                                    Let isInt = Int32.TryParse(str, value)
                                    Where isInt
                                    Select Int32.Parse(str)).ToArray


        connection.Close()

        Dim seriesName As String = Nothing


        ' Note 1 : Clear chart before fill - VERY IMPORTANT and can generate exception if you are generating
        '          multiple charts in loop and have not included below lines !

        chrt.Series.Clear()
        chrt.Titles.Clear()

        ' Give unique Series Name
        seriesName = "Articles in Store"

        chrt.Series.Add(seriesName)

        ' Bind X and Y values
        chrt.Series(seriesName).Points.DataBindXY(xValues, yValues)


        chrt.ChartAreas("ChartArea1").Area3DStyle.Enable3D = False


        ' If you want to show Chart Legends
        chrt.Legends(0).Enabled = True


        ' If you don't want to show data values and headings as label inside each Pie in chart
        chrt.Series(seriesName)("PieLabelStyle") = "Disabled"
        chrt.Series("Articles in Store").IsValueShownAsLabel = False

        ' If you want to show datavalues as label inside each Pie in chart
        chrt.Series("Articles in Store").IsValueShownAsLabel = True