Click here to Skip to main content
15,892,072 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello,

i found some code to fill a chartcontrole with data from textboxes.
Works , but .

The second time there are not 2 but 3 panes.
The data is new but a new pane is coming , and so on .

I only need to clear the chartcontrole and not 3 or 4 etc.
I need to clear the chartcontrole , on google i found.

VB
ChartControl1.Series.Clear()



But it is not working how i want ? It clear the series but ad a new one

This is the code
VB
Try

           ChartControl1.Series.Clear()

           Dim series4 As New Series("Home", ViewType.Bar)
           Dim series5 As New Series("Work", ViewType.Line)

           ''   With ChartControl1.Series(0)




           ''  .IsVisibleInLegend = False



           series4.Points.Add(New SeriesPoint(TextBox1.Text, TextBox2.Text))
           series4.Points.Add(New SeriesPoint(TextBox3.Text, TextBox4.Text))

           series5.Points.Add(New SeriesPoint(TextBox1.Text, TextBox2.Text))
           series5.Points.Add(New SeriesPoint(TextBox3.Text, TextBox4.Text))

           ' Add both series to the chart.
           ChartControl1.Series.AddRange(New Series() {series4, series5})

           ' Hide the legend (optional).
           ChartControl1.Legend.Visible = True

           ' Cast the chart's diagram to the XYDiagram type,
           ' to access its axes and panes.
           Dim diagram As XYDiagram = CType(ChartControl1.Diagram, XYDiagram)

           ' Add secondary axes to the diagram, and adjust their options.
           diagram.SecondaryAxesX.Add(New SecondaryAxisX("My Axis X"))
           diagram.SecondaryAxesY.Add(New SecondaryAxisY("My Axis Y"))
           diagram.SecondaryAxesX(0).Alignment = AxisAlignment.Near
           diagram.SecondaryAxesY(0).Alignment = AxisAlignment.Near

           ' Add a new additional pane to the diagram.
           diagram.Panes.Add(New XYDiagramPane("My Pane"))

           ' Assign both the additional pane and, if required,
           ' the secondary axes to the second series.
           Dim myView As LineSeriesView = CType(series5.View, LineSeriesView)
           myView.AxisX = diagram.SecondaryAxesX(0)
           myView.AxisY = diagram.SecondaryAxesY(0)
           ' Note that the created pane has the zero index in the collection,
           ' because the existing Default pane is a separate entity.
           myView.Pane = diagram.Panes(0)

           ' Customize the layout of the diagram's panes.
           diagram.PaneDistance = 10
           diagram.PaneLayoutDirection = PaneLayoutDirection.Vertical
           diagram.DefaultPane.SizeMode = PaneSizeMode.UseWeight
           diagram.DefaultPane.Weight = 1.2
           ''
           '' End With

       Catch ex As Exception

       End Try

       'setup the chart
Posted
Comments
BASSIES 20-Dec-15 6:37am    
Or anyone has another code to fill the chartcontrol with data from textboxes

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