Click here to Skip to main content
15,901,373 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
am trying to draw graph in visual basic 2010 in windows form using arrays am notable to read values.so plz help me how do i write code to draw graph.plzzz
Posted
Comments
Sergey Alexandrovich Kryukov 6-Jun-12 23:25pm    
You need to tag "Forms". Always tag application tag or UI library to be used when it comes to UI.
--SA

You would need a third party tool that would allow you to do the plot for you.
Assuming you are using C#, you can take a look at this library available at A simple C# library for graph plotting[^].
 
Share this answer
 
Comments
Sergey Alexandrovich Kryukov 6-Jun-12 23:24pm    
Well, one library or another, but I never saw a perfect one... My 5.
--SA
Abhinav S 6-Jun-12 23:32pm    
Thank you SA.

Yes there are a few paid ones that might be ok. But still, there always are bugs.
VJ Reddy 6-Jun-12 23:53pm    
Good reference. 5!
Abhinav S 7-Jun-12 1:45am    
Thanks VJ.
The Zedgraph library given in this CodeProject article A flexible charting library for .NET[^] By JChampion is a very good charting library which has options to draw graphs.

A Test graph is explained in the article.

A VB Sample project is also included in the article.

Download this sample project and to test with arrays replace the CreateGraph method in this project with the following code.
VB
Private Sub CreateGraph(ByVal zgc As ZedGraphControl)
    Dim myPane As GraphPane = zgc.GraphPane

    ' Set the titles and axis labels
    myPane.Title.Text = "My Test Date Graph"
    myPane.XAxis.Title.Text = "X Value"
    myPane.YAxis.Title.Text = "My Y Axis"

    ' Make up some data points with arrays
    ' or populate the arrays from a DataSource
    Dim x As Double() = New Double() {1, 2, 3, 4, 5, 6, 7, 8, 9, 10}
    Dim y As Double() = New Double() {10, 20, 30, 50, 30, 20, 100, 60, 40, 20}

    ' Generate a blue curve with circle symbols, and "My Curve 2" in the legend
    Dim myCurve As LineItem = myPane.AddCurve("My Curve", x, y, Color.Blue, SymbolType.Circle)
    ' Make the symbols opaque by filling them with white
    myCurve.Symbol.Fill = New Fill(Color.White)
    ' Fill the axis background with a color gradient
    myPane.Chart.Fill = New Fill(Color.White, Color.LightGoldenrodYellow, 45.0F)
    ' Fill the pane background with a color gradient
    myPane.Fill = New Fill(Color.White, Color.FromArgb(220, 220, 255), 45.0F)
    ' Calculate the Axis Scale Ranges
    zgc.AxisChange()
End Sub

and run the application to test the graph drawn with arrays.
 
Share this answer
 
Comments
Member 8953292 7-Jun-12 1:06am    
Thank u..
VJ Reddy 7-Jun-12 2:20am    
You're welcome and thank you for the response :)
If the solution is useful to you then you may vote and accept the solution.
Regards.
VJ
VJ Reddy 7-Jun-12 4:37am    
Thank you for accepting the solution :)
Abhinav S 7-Jun-12 1:45am    
5. Zedgraph is a good approach.
VJ Reddy 7-Jun-12 2:19am    
Thank you, Abhinav :)

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