|
-
Jun 7th, 2009, 09:51 AM
#1
Thread Starter
New Member
Graphing help please
I'm new to programming and trying to put together a simple charting program in VB2008 Express. The intent is that you enter x & y values in the textboxes and then click the button to plot the points. I pieced together the following, and during Debugging the basic Zedgraph chart comes up, but no data points. Can somebody help me figure out how to input values in the Textboxes and get them to plot? Thank you smart and talented people.
______________________________________________________________
Imports ZedGraph
Public Class Form1
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
End Sub
Private Sub CreateGraph(ByVal zgc As ZedGraphControl)
Dim myPane As GraphPane = zgc.GraphPane
' Set the title and axis labels
myPane.Title.Text = "PVT Properties"
myPane.XAxis.Title.Text = "Pressure (atm)"
myPane.YAxis.Title.Text = "Temperature (C)"
Dim x1, x2, y1, y2 As Single
x1 = TextBox1.Text
x2 = TextBox2.Text
y1 = TextBox3.Text
y2 = TextBox4.Text
' Enter some calculated data constants
Dim list1 As New PointPairList()
list1.Add(5, 5, 31.67)
list1.Add(10, 10, 23.34)
' Generate a red curve with diamond symbols, and "Gas Data" in the legend
Dim myCurve As LineItem = myPane.AddCurve("Gas Data", list1, Color.Red, SymbolType.Diamond)
myCurve.Symbol.Size = 12
' Set up a red-blue color gradient to be used for the fill
myCurve.Symbol.Fill = New Fill(Color.Red, Color.Blue)
' Turn off the symbol borders
myCurve.Symbol.Border.IsVisible = False
' Instruct ZedGraph to fill the symbols by selecting a color out of the
' red-blue gradient based on the Z value. A value of 19 or less will be red,
' a value of 34 or more will be blue, and values in between will be a
' linearly apportioned color between red and blue.
myCurve.Symbol.Fill.Type = FillType.GradientByZ
myCurve.Symbol.Fill.RangeMin = 19
myCurve.Symbol.Fill.RangeMax = 34
' Turn off the line, so the curve will by symbols only
myCurve.Line.IsVisible = False
' Display a text item with "MW = 34" on the graph
Dim text As New TextObj("MW = 34", 12.9F, 110, CoordType.AxisXYScale)
text.FontSpec.FontColor = Color.Blue
text.FontSpec.Border.IsVisible = False
text.FontSpec.Fill.IsVisible = False
text.FontSpec.Size = 14
myPane.GraphObjList.Add(text)
' Display a text item with "MW = 19" on the graph
text = New TextObj("MW = 19", 25, 110, CoordType.AxisXYScale)
text.FontSpec.FontColor = Color.Red
text.FontSpec.Border.IsVisible = False
text.FontSpec.Fill.IsVisible = False
text.FontSpec.Size = 14
myPane.GraphObjList.Add(text)
' Show the X and Y grids
myPane.XAxis.MajorGrid.IsVisible = True
myPane.YAxis.MajorGrid.IsVisible = True
' Set the x and y scale and title font sizes to 14
myPane.XAxis.Scale.FontSpec.Size = 14
myPane.XAxis.Title.FontSpec.Size = 14
myPane.YAxis.Scale.FontSpec.Size = 14
myPane.YAxis.Title.FontSpec.Size = 14
' Set the GraphPane title font size to 16
myPane.Title.FontSpec.Size = 16
' Turn off the legend
myPane.Legend.IsVisible = False
' Fill the axis background with a color gradient
myPane.Chart.Fill = New Fill(Color.White, Color.FromArgb(255, 255, 166), 90.0F)
' Calculate the Axis Scale Ranges
zgc.AxisChange()
End Sub
Private Sub Form1_Resize(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Resize
SetSize()
End Sub
Private Sub SetSize()
zgc.Location = New Point(10, 10)
' Leave a small margin around the outside of the control
zgc.Size = New Size(ClientRectangle.Width - 20, ClientRectangle.Height - 20)
End Sub
End Class
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|