Click here to Skip to main content
14,384,769 members

How to increase space between bars in VB chart and give name for every bar?

Amranullah Hassanzada asked:

Open original thread
 I have a chart in my windows form which X-axis linked whit text box, containing names of elements and Y-axis linked whit text-boxes, containing numeric values.
when I debug the form columns (bars) are close together and from 5 columns just one column takes a name.
Also when the same names come in text-boxes the program gives the message " A chart element with the name "......." already exists in the SeriseCollection". how to solve this issue?


I have tried the following code:


What I have tried:

Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
        Try
            Me.Chart1.Series.Clear()
            Me.Chart1.Series.Add(Form3.TextBox6.Text)
            Me.Chart1.Series.Add(Form3.TextBox17.Text)
            Me.Chart1.Series.Add(Form3.TextBox23.Text)
            Me.Chart1.Series.Add(Form3.TextBox29.Text)
            Me.Chart1.Series.Add(Form3.TextBox35.Text)

            Me.Chart1.Series(Form3.TextBox6.Text).Points.AddXY(Form3.TextBox6.Text, Val(Form3.txtpi1.Text))
            Me.Chart1.Series(Form3.TextBox17.Text).Points.AddXY(Form3.TextBox17.Text, Val(Form3.txtpi2.Text))
            Me.Chart1.Series(Form3.TextBox23.Text).Points.AddXY(Form3.TextBox23.Text, Val(Form3.txtpi3.Text))
            Me.Chart1.Series(Form3.TextBox29.Text).Points.AddXY(Form3.TextBox29.Text, Val(Form3.txtpi4.Text))
            Me.Chart1.Series(Form3.TextBox35.Text).Points.AddXY(Form3.TextBox35.Text, Val(Form3.txtpi5.Text))

        Catch ex As Exception
            MessageBox.Show(ex.Message)
        Finally
            Beep()
        End Try
    End Sub
Tags: VB.NET

Preview



When answering a question please:
  1. Read the question carefully.
  2. Understand that English isn't everyone's first language so be lenient of bad spelling and grammar.
  3. If a question is poorly phrased then either ask for clarification, ignore it, or edit the question and fix the problem. Insults are not welcome.
  4. Don't tell someone to read the manual. Chances are they have and don't get it. Provide an answer or move on to the next question.
Let's work to help developers, not make them feel stupid.
Please note that all posts will be submitted under the The Code Project Open License (CPOL).




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