Unneeded line after drawing graph on picture box

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Mas Juliza Alias
    New Member
    • Aug 2010
    • 67

    Unneeded line after drawing graph on picture box

    Hi,
    I have a problem with the graph I drawn on a picture box for quite a while. I have two curves, elevation-storage and elevation-area curves which need to be drawn on a single graph. I managed to draw it nicely if the curves are drawn separately, but somehow when the curves are merged together (by merging the same codes as they are drawn separately) there is an unneeded line appears diagonally from min value to the max value of x,y. How can I eliminated it? Attached is the project I coded so far. Your help is highly appreciated. Thank You.
    Attached Files
  • Guido Geurs
    Recognized Expert Contributor
    • Oct 2009
    • 767

    #2
    You are using the command = picture1.line -(...) !
    The string "-" is for the function=

    Step= Optional.Keywor d specifying that the starting point coordinates are relative to the CURRENT graphics position given by the CurrentX and CurrentY properties.

    The last thing you have done BEFORE to start drawing the graphic line is setting the X line for "Area".
    So the last coordinates are in the right-upper corner.
    The first point of the data = (0,0).
    With the command .line -(0,0) you are drawing a line from the upper-right corner to 0,0.

    So before you start drawing the curves, you have to reset the CurrentX and CurrentY.

    Code:
    Sub AreaGraph()
    Dim j As Integer
       'area curve
       With Form1.Picture1
          .CurrentX = 0
          .CurrentY = 0
       End With
       With Form1.MSFlexGrid1
          For j = 1 To .Rows - 1
             Form1.Picture1.Line -(.TextMatrix(j, 1), .TextMatrix(j, 0)), vbGreen
          Next
       End With
    End Sub
    Also attached is your code with some modifications in calling the subroutines.
    Attached Files

    Comment

    • Mas Juliza Alias
      New Member
      • Aug 2010
      • 67

      #3
      problem solved. Thank YOU!

      Comment

      Working...