Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Graphs

Status
Not open for further replies.

AmyLynn

MIS
Jun 19, 2001
2
US
Hi, I need some help. I am trying to find out how to print a graph into a picture box (or some type of box) from points that are generated from a program I wrote. I only have the learning edition so I am not sure if I can even do this. Any help will be greatly appreciated. THANKS
 
You can use the MSChart control (similar to excel plots).
Or you can do all the work yourself. Something like:

'First set the plot scale by setting min and max
'values for x and y axis in Xmin, Xmax, Ymin and Ymax

'find scale
xs = dbplot.ScaleWidth
ys = dbplot.ScaleHeight

'Oregon definition
xo = LeftMarg
yo = ys - BotMarg

'plot scale definition
xps = xs - RightMarg - LeftMarg
yps = ys - TopMarg - BotMarg


'The data is stored in the array 'DataArr' which is
'a userdefined type:
'type MyPoint
'X as single
'Y as Single
'end type
'
'MarkStyle defines if you want to plot points or lines or circles.

dbplot.ForeColor = MarkColor
dbplot.DrawWidth = MarkThick

For t = 0 To UBound(DataArr) 'loop throug all the points
'Calculate where to plot the point
Xtmp = xo + ((DataArr(t).X - Xmin) / (Xmax - Xmin)) * xps
Ytmp = TopMarg + yps - ((DataArr(t).Y - Ymin) / (Ymax - Ymin)) * yps
If Xtmp >= LeftMarg And Xtmp <= (xs - RightMarg) And _
Ytmp >= TopMarg And Ytmp <= (ys - BotMarg) Then
Select Case MarkStyle
Case 0
dbplot.PSet (Xtmp, Ytmp)
Case 1
dbplot.Circle (Xtmp, Ytmp), MarkSize
Case 2
dbplot.Line (Xtmp - MarkSize, Ytmp - MarkSize) _
-(Xtmp + MarkSize, Ytmp + MarkSize)
dbplot.Line (Xtmp + MarkSize, Ytmp - MarkSize) _
-(Xtmp - MarkSize, Ytmp + MarkSize)
End Select
End If
Next t


Good luck :)
Sunaj
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top