Creating a line graph in VB.NET? 
Author Message
 Creating a line graph in VB.NET?

I want to create a line graph displaying the results of a SQL Server
query series. Does anyone have any examples of doing this using the
system.drawing functions in vb.net they can share to help me get
started?

Thanks

Steve



Sat, 11 Dec 2004 00:32:32 GMT  
 Creating a line graph in VB.NET?
I'm working on the same type of thing.  Except my values
are coming from a text field.  I'm using vb to create SVG
files.  Here is an example on creating SVG charts:

http://www.hendersonpetrophysics.com/SVG_Main.html

Here is how to plot the x, y values, getting them to line
up with your chart
Left = left edge of chart (pixels)
xValue = the x value you want to plot
minX = the unit value of the left edge of your chart (min
x value)
maxX= the max unit value (max x value)
chartWidth = the pixel width of the chart you draw

x = Left + ((xValue - minX) / (maxX - minX)) * chartWidth

Pretty much the same thing for the y-values
y = Top + ((yValue - minY) / (maxY- minY)) * chartHeight

Hope this helps... I think it is the best way to chart w/
vb.  I've had absolutely no luck with the chart controls.

Quote:
>-----Original Message-----
>I want to create a line graph displaying the results of a
SQL Server
>query series. Does anyone have any examples of doing this
using the
>system.drawing functions in vb.net they can share to help
me get
>started?

>Thanks

>Steve
>.



Sat, 11 Dec 2004 01:06:18 GMT  
 Creating a line graph in VB.NET?
A sample to get you started in the graphics department:

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
    Dim mygraph As Graphics = Me.CreateGraphics
    Dim mySolidPen As Pen = New Pen(Color.Black, 2)
    Dim myDottedPen As Pen = New Pen(Color.Blue, 2)
    myDottedPen.DashStyle = Drawing2D.DashStyle.DashDot
    mygraph.DrawLine(mySolidPen, 10, 10, 100, 100)
    mygraph.DrawLine(myDottedPen, 20, 10, 110, 100)
    mygraph.DrawString("Text", Me.Font, Brushes.Black, 200, 200)
End Sub

This will generate two lines, one solid black and one dotted blue, and will
print a string in the form

Hope that helps

Alexandre Moura [MS VB QA]

--
This posting is provided "AS IS" with no warranties, and confers no rights.

Quote:
> I want to create a line graph displaying the results of a SQL Server
> query series. Does anyone have any examples of doing this using the
> system.drawing functions in vb.net they can share to help me get
> started?

> Thanks

> Steve



Sat, 11 Dec 2004 04:57:21 GMT  
 Creating a line graph in VB.NET?
I can create and easily see the CreateGraphics method for a Windows
Application. But, if I am creating a Web Forms application, it tells
me that "CreateGraphics is not a member of..."

So, is this not allowed for web-based forms?


Quote:
> A sample to get you started in the graphics department:

> Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
> System.EventArgs) Handles Button1.Click
>     Dim mygraph As Graphics = Me.CreateGraphics
>     Dim mySolidPen As Pen = New Pen(Color.Black, 2)
>     Dim myDottedPen As Pen = New Pen(Color.Blue, 2)
>     myDottedPen.DashStyle = Drawing2D.DashStyle.DashDot
>     mygraph.DrawLine(mySolidPen, 10, 10, 100, 100)
>     mygraph.DrawLine(myDottedPen, 20, 10, 110, 100)
>     mygraph.DrawString("Text", Me.Font, Brushes.Black, 200, 200)
> End Sub

> This will generate two lines, one solid black and one dotted blue, and will
> print a string in the form

> Hope that helps

> Alexandre Moura [MS VB QA]

> --
> This posting is provided "AS IS" with no warranties, and confers no rights.


> > I want to create a line graph displaying the results of a SQL Server
> > query series. Does anyone have any examples of doing this using the
> > system.drawing functions in vb.net they can share to help me get
> > started?

> > Thanks

> > Steve



Sat, 11 Dec 2004 23:51:21 GMT  
 Creating a line graph in VB.NET?
Great question, Yes! this is possible by creating a bitmap and either:
a) streaming binary contents to the client
b) saving a temporary bitmap and adding an img link to your page.
Here is an article that shows how to do this:
"Create Snazzy Web Charts and Graphics On the Fly with the .NET Framework"
http://msdn.microsoft.com/msdnmag/issues/02/02/ASPDraw/ASPDraw.asp

Alex + Ed
Visual Basic .NET
--
This posting is provided "AS IS" with no warranties, and confers no rights.

Quote:
> I can create and easily see the CreateGraphics method for a Windows
> Application. But, if I am creating a Web Forms application, it tells
> me that "CreateGraphics is not a member of..."

> So, is this not allowed for web-based forms?




Quote:
> > A sample to get you started in the graphics department:

> > Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
> > System.EventArgs) Handles Button1.Click
> >     Dim mygraph As Graphics = Me.CreateGraphics
> >     Dim mySolidPen As Pen = New Pen(Color.Black, 2)
> >     Dim myDottedPen As Pen = New Pen(Color.Blue, 2)
> >     myDottedPen.DashStyle = Drawing2D.DashStyle.DashDot
> >     mygraph.DrawLine(mySolidPen, 10, 10, 100, 100)
> >     mygraph.DrawLine(myDottedPen, 20, 10, 110, 100)
> >     mygraph.DrawString("Text", Me.Font, Brushes.Black, 200, 200)
> > End Sub

> > This will generate two lines, one solid black and one dotted blue, and
will
> > print a string in the form

> > Hope that helps

> > Alexandre Moura [MS VB QA]

> > --
> > This posting is provided "AS IS" with no warranties, and confers no
rights.


> > > I want to create a line graph displaying the results of a SQL Server
> > > query series. Does anyone have any examples of doing this using the
> > > system.drawing functions in vb.net they can share to help me get
> > > started?

> > > Thanks

> > > Steve



Sun, 12 Dec 2004 03:58:56 GMT  
 
 [ 5 post ] 

 Relevant Pages 

1. Crystal Report Graph Problem (No Zero and No Lines attached in Line Graph)

2. VB3 Graph Control for Line graph

3. VB.NEt Beginner: Creating a COM+ Object in VB.net

4. line graph in vb (canned routine)

5. what create table using ADO.NET to VB.NET

6. Making graphs with VB .net

7. Custom Graph Control using PictureBox using VB.NET

8. Plotting Graph in VB.Net and windows Form

9. Creating Graphs On VB and access

10. create Graph in Access using VB 5.0

11. Creating MS Excel Graphs With VB

12. VB Creating Reports/Graphs In An Access Database

 

 
Powered by phpBB® Forum Software