473,395 Members | 1,678 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

How to put an interactive line on a chart?

Mas Juliza Alias
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
File Type: zip 170311.zip (13.7 KB, 211 views)
Mar 17 '11 #1

✓ answered by Guido Geurs

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

21 4108
Guido Geurs
767 Expert 512MB
Please can you attach ALL the files?
I get an error on loading the VBP: some files are missing in the ZIP.
Mar 19 '11 #2
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
File Type: zip retisro_210311.zip (36.9 KB, 133 views)
Mar 21 '11 #3
Guido Geurs
767 Expert 512MB
Add a command button (ComDraw) with the code= (this will put the line to the coordinates (0,0) in the chart)

Expand|Select|Wrap|Line Numbers
  1. Private Sub ComDraw_Click()
  2.    With ChartFraTESCalc
  3.       FrameGraphRTL.Left = .Left + 970
  4.       FrameGraphRTL.Top = .Top + .Height - 1040
  5.       With .Plot.LocationRect
  6.          FrameGraphRTL.Width = .Max.X - .Min.X - 970
  7.       End With
  8.    End With
  9. 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.
Mar 24 '11 #4
Guido Geurs
767 Expert 512MB
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
File Type: zip ReTISRO_v1.1.12.zip (33.5 KB, 115 views)
Mar 25 '11 #5
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 (ChartFraTESCalc) 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
File Type: txt volumeTrapezium.txt (4.2 KB, 389 views)
Mar 29 '11 #6
Guido Geurs
767 Expert 512MB
Sorry, my mistake.
I was still using the data from "cubic.txt" in which the MAX. value was positive.
In the data from "volumeTrapezium.txt", the MAX. is still negative.
So the code for the error trap of the maximum value should also be:
Expand|Select|Wrap|Line Numbers
  1. ...
  2.       If txtRTimeDepth > CDbl(ARRAYGRAPH(UBound(ARRAYGRAPH), 2)) Then
  3. ...
PS: I have also modified the DIM in "dlgTableTerramodel"

Expand|Select|Wrap|Line Numbers
  1. ...Public Sub cmdNext_Click()
  2. Dim ARRAYDATAidx As Double...
Attached Files
File Type: zip ReTISRO_v1.1.13.zip (34.3 KB, 133 views)
Mar 30 '11 #7
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.
Mar 30 '11 #8
Guido Geurs
767 Expert 512MB
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 = "Calibration".
You can activate it with the red button on the graph frame.
You can hide it by setting the line
Expand|Select|Wrap|Line Numbers
  1.    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)
Expand|Select|Wrap|Line Numbers
  1.    Call frmMainMenu.mnuDownloadTerramodel_Click
  2.    DoEvents
  3.    With dlgBrowseTerramodel
  4.       .txtFile.Text = App.Path & "\" & "volumeTrapezium.txt"
  5.       Call .cmdNext_Click
  6.    End With
  7.    DoEvents
  8.    Call dlgContentTerramodel.cmdNext_Click
  9.    DoEvents
  10.    Call dlgTableTerramodel.cmdNext_Click
  11.    DoEvents
The tool "calibration" 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
File Type: zip ReTISRO_v1.2.7.zip (37.4 KB, 102 views)
Apr 7 '11 #9
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.
Apr 10 '11 #10
Guido Geurs
767 Expert 512MB
This is with the Depth on the Y axis and a document in .DOC and .PDF explaining the use of the calibration
Attached Files
File Type: zip ReTISRO_v1.3.4.zip (37.6 KB, 106 views)
File Type: zip DOC calibrate.zip (117.9 KB, 103 views)
Apr 17 '11 #11
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! :)
Apr 21 '11 #12
I have a problem here. My VB6 has no UserCtlCalib component. Where can i get it?
TQ
Apr 28 '11 #13
Guido Geurs
767 Expert 512MB
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_UserCtlCalib.ctl"
You can load it in your application with "Add" - "Usercontrol" in the Project window. (see last attachment.

PS: you can always create your own controls in vb6!
Apr 28 '11 #14
Oh I see... I am sorry for my limited knowledge. I have searched and read about it. Thanks!
Apr 29 '11 #15
There is a problem here when 0 depth is entered. The volume should be 400 but it appears as 0. How can I fix this?
TQ
Apr 30 '11 #16
Guido Geurs
767 Expert 512MB
Because there is no value above "0" you can't interpolate.
So when depth = 0 the it's the max of volume.
The code for the calculation will be=
Expand|Select|Wrap|Line Numbers
  1. Private Function CalcVolume(DEPTH As Double) As Double
  2. Dim ROWidx As Integer
  3. Dim ELEVATIONmin As Double
  4. Dim ELEVATIONmax As Double
  5. Dim VOLUMEmin As Double
  6. Dim VOLUMEmax As Double
  7. Dim VOLUMEDIF As Double
  8.    With GridFraTESCalc
  9.       If CDbl(txtRTimeDepth.Text) = CDbl(ARRAYGRAPH(UBound(ARRAYGRAPH), 2)) Then
  10.          CalcVolume = Format(CDbl(ARRAYGRAPH(UBound(ARRAYGRAPH), 1)), "0.000")
  11.       Else
  12.          For ROWidx = 1 To .Rows - 1
  13.             If CDbl(.TextMatrix(ROWidx, 0)) > DEPTH Then
  14.                ELEVATIONmin = CDbl(.TextMatrix(ROWidx - 1, 0))
  15.                ELEVATIONmax = CDbl(.TextMatrix(ROWidx, 0))
  16.                VOLUMEmin = CDbl(.TextMatrix(ROWidx - 1, 1))
  17.                VOLUMEmax = CDbl(.TextMatrix(ROWidx, 1))
  18.                VOLUMEDIF = (VOLUMEmax - VOLUMEmin) * _
  19.                            (DEPTH - ELEVATIONmin) / _
  20.                            (ELEVATIONmax - ELEVATIONmin)
  21.                CalcVolume = Format(VOLUMEmin + VOLUMEDIF, "0.000")
  22.                Exit Function
  23.             End If
  24.          Next
  25.       End If
  26.    End With
  27. End Function
May 1 '11 #17
Oh I see... So you just add the If function to read the graph data for the first value, am I right? The code works nicely. Thank YOU!
May 2 '11 #18
I am facing a problem here. I am using a data with positive and negative values. When I enter the positive value for the elevation, an error message "Run-Time Error '380', Invalid property values" appears highlighting this line
Expand|Select|Wrap|Line Numbers
  1. With FrameGraphRTLx
  2.    .Left = FrameGraphRTLy.Left + FrameGraphRTLy.Width
  3.    .Top = FrameGraphRTLy.Top
  4.    .Height = (Abs(Ymin) - Abs(CDbl(txtElevUser.Text))) * TWIPSy 'highlighted line of the error debug
  5.    .Visible = True
  6. End With
  7.  
When I enter negative value of the elevation, the X line appear at the positive value as in the attached picture. How am I supposed to fix this?
Attached Images
File Type: jpg incorrectlines.jpg (41.0 KB, 254 views)
Attached Files
File Type: zip ReTISRO_manually.zip (137.5 KB, 100 views)
File Type: txt tapahdam_volume.txt (2.9 KB, 374 views)
File Type: txt trapezoidalprism_volume_shift3m.txt (5.1 KB, 360 views)
May 24 '11 #19
To use the data files, create new file (File > New) and download the data file (Download/Import). Data file with positive and negative values of elevation is trapezoidal_volume_shift3m.txt file. TQ.
May 24 '11 #20
Guido Geurs
767 Expert 512MB
This is how you can modiffy the calculations for all kind of data: (see also attachment)

Expand|Select|Wrap|Line Numbers
  1. '§ draw lines
  2.    With ChartFraTESCalc.Plot.LocationRect
  3.       PLOTmaxX = .Max.X
  4.       PLOTminX = .Min.X
  5.       PLOTmaxY = .Max.Y
  6.       PLOTminY = .Min.Y
  7.    End With
  8.    Xmax = CDbl(ARRAYGRAPH(UBound(ARRAYGRAPH), 1))
  9.    Xmin = CDbl(ARRAYGRAPH(LBound(ARRAYGRAPH), 1))
  10.    Ymax = CDbl(ARRAYGRAPH(UBound(ARRAYGRAPH), 2))
  11.    Ymin = CDbl(ARRAYGRAPH(LBound(ARRAYGRAPH), 2))
  12.    TWIPSx = CDbl(PLOTmaxX - PLOTminX - PLOTGRIDleft - PLOTGRIDright) / Abs(Xmax - Xmin)
  13.    If Ymax > 0 And Ymin < 0 Then
  14.       TWIPSy = CDbl((PLOTmaxY - PLOTminY - PLOTGRIDtop - PLOTGRIDbottom) / Abs(Abs(Ymax) + Abs(Ymin)))
  15.    Else
  16.       TWIPSy = CDbl((PLOTmaxY - PLOTminY - PLOTGRIDtop - PLOTGRIDbottom) / Abs(Abs(Ymax) - Abs(Ymin)))
  17.    End If
  18.    With FrameGraphRTLy
  19.       .Left = ChartFraTESCalc.Left + PLOTminX + PLOTGRIDleft
  20.       If Ymax > 0 And CDbl(txtElevUser.Text) < 0 Then
  21.          .Top = ChartFraTESCalc.Top + (ChartFraTESCalc.Height - PLOTmaxY) + PLOTGRIDtop + _
  22.                (Abs(Abs(Ymax) + Abs(CDbl(txtElevUser.Text))) * TWIPSy)
  23.       Else
  24.          .Top = ChartFraTESCalc.Top + (ChartFraTESCalc.Height - PLOTmaxY) + PLOTGRIDtop + _
  25.                (Abs(Abs(Ymax) - Abs(CDbl(txtElevUser.Text))) * TWIPSy)
  26.       End If
  27.       .Width = (VOLUME - Xmin) * TWIPSx
  28.       .Visible = True
  29.    End With
  30.    With FrameGraphRTLx
  31.       .Left = FrameGraphRTLy.Left + FrameGraphRTLy.Width
  32.       .Top = FrameGraphRTLy.Top
  33.       If CDbl(txtElevUser.Text) > 0 And Ymin < 0 Then
  34.          .Height = (Abs(Abs(CDbl(txtElevUser.Text)) + Abs(Ymin)) * TWIPSy)
  35.       Else
  36.          .Height = (Abs(Abs(CDbl(txtElevUser.Text)) - Abs(Ymin)) * TWIPSy)
  37.       End If
  38.       .Visible = True
  39.    End With
Attached Files
File Type: zip How to put an interactive line on a chart_v1.4.0.zip (66.7 KB, 76 views)
May 27 '11 #21
Guido Geurs
767 Expert 512MB
If the data will be of different types: min-plus, plus-plus, min-min, than the place of the plotgrid will change and the user must adapt the boundaries.
So I have added a simple calibration tool to do it.(see attachment)
Attached Files
File Type: zip 1.4.2 How to put an interactive line on a chart.zip (66.6 KB, 125 views)
May 30 '11 #22

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: Anks | last post by:
I need to display a printable line chart on client machine using jsp/servlet. Is it possible ?Please explain? Anks
1
by: Frank | last post by:
I've written a jsp that retrieves data from a sybase table via the sql JSTL. Two colums of data are returned, date and value. Currently the data is placed in an HTML table. Does anyone know of...
3
by: Serdar C | last post by:
hello there.. there used to be a usefull and simple control on vb6.0 which was a line chart.. it was quite easy to use.. but in c# theres a pani named "crystal reports" and its too much complicated...
5
by: Zach | last post by:
Hi, I am completely new to VC#.NET graphics code and would like some help to stop me wasting my time up blind alleys. I am looking for a line charting code example. Nothing posh or airy...
5
by: Bruce Schechter | last post by:
I need to generate a series of line charts dynamically from ADO.NET data in a C#, ASP.NET application. I've read several articles about using GDI+ to render graphs into a bitmap image and then to...
1
by: Scott H. | last post by:
Hello: I am trying to use Crystal Reports from VS.NET 2003 to produce a simple line chart, where the x axis represents the number of measurements taken and the y axis represents the range of...
0
by: zenius | last post by:
Can anyone please give me an example how to create line chart graphic using VB.NET
4
by: =?Utf-8?B?bWFydGluMQ==?= | last post by:
Hi, All, I want to draw line chart on the web using visual basic 2005, vb 2005 doesn't have chart components, so can anyone point out where I can start working this? Thanks, Ma
6
craigfr
by: craigfr | last post by:
I am looking to compare this year's defects to last year's defects (by month) with a two-line graph. So I will need a line chart with two different lines, one that shows YTD # of defects and another...
3
by: Sean Tech | last post by:
Hello Everyone, I have run into a problem with creating a line chart in access. My ultimate goal is to have the chart produce monthly totals for the salesmen and also show there quotas for the...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.