Quantcast
Channel: VBForums - Visual Basic .NET
Viewing all articles
Browse latest Browse all 27382

VS 2010 remove series from chart series collection

$
0
0
Hi
i'm trying to plot a point on a chart. If a point already exists, i want it deleted before plotting the new point. The point is stored in "Series2".
I tried the following code. it plots the first point OK. If i then try to replace the first point with a second i get a error saying series2 already exists. the error is at line "mychart.Series.Add("Series2")"
can anyone see the issue here? thank you

Code:

  Sub plotpoint(xy(,) As Double, mychart As DataVisualization.Charting.Chart)
        'test if series already exists and if so delete it
        'Dim seriesname As New DataVisualization.Charting.Series("Series2")
        If mychart.Series.Contains("Series2") Then
            mychart.Series.Remove(seriesname)
        End If
        'add point to chart
        mychart.Series.Add("Series2")
        mychart.Series("Series2").ChartType = DataVisualization.Charting.SeriesChartType.Point
        mychart.Series("Series2").MarkerColor = Color.Red

        'Plot data point
        mychart.Series("Series2").Points.AddXY(Math.Round(xy(0, 0), 5), xy(0, 1))
    End Sub


Viewing all articles
Browse latest Browse all 27382

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>