How to put an interactive line on a chart?

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

    How to put an interactive line on a chart?

    Hi,

    I am developing a program that have a 2d line chart of Depth vs Volume. Below the chart there is a textbox where user can enter a depth value. Is it possible to have a line along the depth on the chart? The line should be at 0m depth by default. Plus, if possible, how to highlight the bounded region by the line and volume at that depth with any color different from its background?

    Attached is the program i have so far. The depth to be entered by user is the txtRTimeDepth. Your help is highly appreciated.

    TQ.
    Attached Files
  • Guido Geurs
    Recognized Expert Contributor
    • Oct 2009
    • 767

    #2
    Please can you attach ALL the files?
    I get an error on loading the VBP: some files are missing in the ZIP.

    Comment

    • Mas Juliza Alias
      New Member
      • Aug 2010
      • 67

      #3
      Here they are. All I need is an interactive line on the chart representing the real time depth as entered by user in the text box at the bottom of the form (frmMainMenu).

      Can you take a look at my frmCommPort also? I am stuck at the code to receive data from comm port.

      TQ.
      Attached Files

      Comment

      • Guido Geurs
        Recognized Expert Contributor
        • Oct 2009
        • 767

        #4
        Add a command button (ComDraw) with the code= (this will put the line to the coordinates (0,0) in the chart)

        Code:
        Private Sub ComDraw_Click()
           With ChartFraTESCalc
              FrameGraphRTL.Left = .Left + 970
              FrameGraphRTL.Top = .Top + .Height - 1040
              With .Plot.LocationRect
                 FrameGraphRTL.Width = .Max.X - .Min.X - 970
              End With
           End With
        End Sub
        Still to code:
        - When the form resizes: replace the line
        - calculate the Y value of the line when a user enters a value in txtRTimeDepth box.

        Comment

        • Guido Geurs
          Recognized Expert Contributor
          • Oct 2009
          • 767

          #5
          Attached is the code for the Depth line in the Graph.
          I have searched for a definition for a "drop-line" in the chart but nothing found.
          So I have used a Fram as line and calculated the coordinates.
          Attached Files

          Comment

          • Mas Juliza Alias
            New Member
            • Aug 2010
            • 67

            #6
            I tried to run your code using the attached data. However, when I enter a value in the real time level box, the message "The Value of Real Time Value is TOO HIGH" appears, even though the value I entered is still in the range.

            Can we use the chart (ChartFraTESCal c) to draw the real time level line? For instance, if I enter -3.00 in the Real Time Level box, a new line along the -3.00 will be drawn on the graph. And when we enter another value, the line will be moved to that value line. Is it possible?

            TQ...
            Attached Files

            Comment

            • Guido Geurs
              Recognized Expert Contributor
              • Oct 2009
              • 767

              #7
              Sorry, my mistake.
              I was still using the data from "cubic.txt" in which the MAX. value was positive.
              In the data from "volumeTrapeziu m.txt", the MAX. is still negative.
              So the code for the error trap of the maximum value should also be:
              Code:
              ...
                    If txtRTimeDepth > CDbl(ARRAYGRAPH(UBound(ARRAYGRAPH), 2)) Then
              ...
              PS: I have also modified the DIM in "dlgTableTerram odel"

              Code:
              ...Public Sub cmdNext_Click()
              Dim ARRAYDATAidx [B]As Double[/B]...
              Attached Files

              Comment

              • Mas Juliza Alias
                New Member
                • Aug 2010
                • 67

                #8
                That works nicely! Thanks for the notes, they really helps my understanding of your codes.

                However is it possible if the line stops at the graph line? My supervisor suggested for a horizontal line from the Y axis to the curve and a vertical line from X axis to the curve, to show the real time depth and volume by using the graph. But I don't have idea how to do this. Thank You in advance.

                Comment

                • Guido Geurs
                  Recognized Expert Contributor
                  • Oct 2009
                  • 767

                  #9
                  Sorry for this late response but there were a lot of problems to solve.
                  I have found a lot of questions on the web about drawing drop-lines but never an answer.
                  So I have written my own drop-lines.
                  I have also added a tool FOR THE DEVELOPER ONLY = "Calibratio n".
                  You can activate it with the red button on the graph frame.
                  You can hide it by setting the line
                  Code:
                     frmMainMenu.ComCalibrate.Visible = True
                  to comment in the FrmSplash.
                  You can also run the program in his original form (for the user) by comment or delete the other lines:(this is only for the developer to go directly to the chart)
                  Code:
                     Call frmMainMenu.mnuDownloadTerramodel_Click
                     DoEvents
                     With dlgBrowseTerramodel
                        .txtFile.Text = App.Path & "\" & "volumeTrapezium.txt"
                        Call .cmdNext_Click
                     End With
                     DoEvents
                     Call dlgContentTerramodel.cmdNext_Click
                     DoEvents
                     Call dlgTableTerramodel.cmdNext_Click
                     DoEvents
                  The tool "calibratio n" let you see where the boundaries are of the Chart element.
                  The green buttons are only information.
                  The red buttons and according scrollbars must be set because these values can't be retrieved from the element Chart.
                  These values are needed to calculate the coordinates of the drop-lines.
                  These values are also set by clicking "Apply" and saved when the program is closed with the message "Save the settings ?" in the settings.ini.
                  Attached Files

                  Comment

                  • Mas Juliza Alias
                    New Member
                    • Aug 2010
                    • 67

                    #10
                    I am sorry but I don't understand how to use the calibration tool. I look through it and also the code but somehow I don't get it. When I import a volume file, the lines do not lie in the place they should be as the value I entered in the text box. I think it has something to do with the calibration, right? Can you explain how to use it?
                    Also, you have changed the graph axis, Depth and Volume. I prefer Depth in Y-axis and Volume in X-axis. I tried to change it but somehow it effects other calculation though.
                    Sorry again for my limited VB knowledge. I really appreciate your time on helping me on this. Thank YOU.

                    Comment

                    • Guido Geurs
                      Recognized Expert Contributor
                      • Oct 2009
                      • 767

                      #11
                      This is with the Depth on the Y axis and a document in .DOC and .PDF explaining the use of the calibration
                      Attached Files

                      Comment

                      • Mas Juliza Alias
                        New Member
                        • Aug 2010
                        • 67

                        #12
                        THANK YOU! The codes work super nice! Plus your .pdf file helps me A LOT to understand the Calibration tool. I'm totally into it right now. Thanks again! :)

                        Comment

                        • Mas Juliza Alias
                          New Member
                          • Aug 2010
                          • 67

                          #13
                          I have a problem here. My VB6 has no UserCtlCalib component. Where can i get it?
                          TQ

                          Comment

                          • Guido Geurs
                            Recognized Expert Contributor
                            • Oct 2009
                            • 767

                            #14
                            This is not a standard control.
                            This is a control I have created for this application.
                            You find the file in my attachment as:"ReTISRO_v1. 4.0_UserCtlCali b.ctl"
                            You can load it in your application with "Add" - "Usercontro l" in the Project window. (see last attachment.

                            PS: you can always create your own controls in vb6!

                            Comment

                            • Mas Juliza Alias
                              New Member
                              • Aug 2010
                              • 67

                              #15
                              Oh I see... I am sorry for my limited knowledge. I have searched and read about it. Thanks!

                              Comment

                              Working...