CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 5 of 5
  1. #1
    Join Date
    Jan 2000
    Location
    NC, USA
    Posts
    56

    PLOTTING X,Y VALUES??

    Can anyone tell me what would be the best control to use to plot x,y values on an axis. I have tried the graph control, but I can't get it to relate the x to the y and I can't seem to find a way with the mschart control either. Please help!!!


  2. #2
    Join Date
    Nov 1999
    Location
    Sacramento
    Posts
    9

    Re: PLOTTING X,Y VALUES??

    Any picture or form control will work just fine. You just need to establish the coordinate system you want, as the default is in TWIPS and uses the "origin at upper left, Y increases downward" Windows standard rather than the Cartesian "Y+=up" direction. But you can change the direction using SCALE. One tip: if you try to do graphics in the Form Load, make sure that you make the form visible before you do the graphics.



    Dave Straayer
    Varatouch, Inc.

  3. #3
    Join Date
    Nov 1999
    Location
    Sacramento
    Posts
    9

    Re: PLOTTING X,Y VALUES??

    Try this:
    Option Explicit

    Private Sub Form_Load()
    Dim x As Single
    Dim y As Single
    Form1.Visible = True
    Scale (-20, 20)-(20, -20)
    Line (-20, 0)-(20, 0)
    Line (0, -20)-(0, 20)
    x = -20
    y = f(x)
    Line (x, y)-(x, y)
    For x = -20 To 20 Step 0.1
    y = f(x)
    Line -(x, y), vbRed
    Next x
    End Sub
    Function f(x As Single) As Single
    f = 0.05 * x ^ 2 - 2 * x - 4
    End Function


    Dave Straayer
    Varatouch, Inc.

  4. #4
    Join Date
    Jan 2000
    Location
    NC, USA
    Posts
    56

    Re: PLOTTING X,Y VALUES??

    Mr. Straayer,
    I just received your reply to my question. I will definitely try your solution to see if it will work. Thank you for taking the time to reply.

    What will be the easiest way to draw an x and y axis with labels?

    Thanks
    Heidi Hauser


  5. #5
    Join Date
    Jul 1999
    Location
    Athens, Hellas
    Posts
    769

    Re: PLOTTING X,Y VALUES??

    I have no answer to your question but I have a suggestion: I've used MSChart control in past and it had a bug with logarithmic charts. This bug was corrected with ServicePack3. So, maybe there are more bugs in this control except this I met. So, I suggest you to install Service Pack 3 before continue with your project. Good luck!

    Michael Vlastos
    Automation Engineer
    Company SouthGate Hellas SA
    Development Department
    Athens, Greece

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured