|
Post by (X) on May 4, 2022 13:50:08 GMT 1
I am tired of 'reinventing the wheel' every time I need to graph data. I will try to create an "open" graph library that should make it easy to display an array of data points.
I am hoping perhaps:

'################################################################### ' ' DISCLAIMER: THIS CODE IS OFFERED AS IS FOR EDUCATIONAL PURPOSES. ' YOU ARE FREE TO USE, COPY AND DISTRIBUTE. ' THE USE OF THIS CODE IS AT YOUR OWN RISK. ' I ACCEPT NO LIABILITY NOR MAKE ANY CLAIM OF ' CORRECTNESS OR SUITABILITY IN PART OR IN WHOLE. ' '################################################################### ' ' Filename Lib_Graph.G32 ' ' Description A helper library for plotting graphs. ' This should let a programmer setup a graph with a ' minimum of fuss and bother while offering autoscaling, ' zoom, waterfall etc... ' ' ' Author (X) ' Email xman.gb32@gmail.com ' Web-site https://gb32.proboards.com/ ' Started 2022.05.03 ' Updated <ISO date> ' ' Type T_Graph - String*40 name - String*40 desc ' tooltiptext - String*40 date - String*40 v_axis_name - String*40 h_axis_name - Single fx, fy, fw, fh ' form metrics - Single gx, gy, gw, gh ' graph metrics - Single px, py, pw, ph ' plot metrics - Single ox, oy, oz ' Observer coordinates - T_Data x, y, z - Single rxy, ryz, rxz - T_V3D rv - Single sx, sy, sz - Boolean ScaleNorm ' adaptive vs fixed scaling - Single Zoom_Factor, Zoom_x, Zoom_y - Single ini_x, ini_y, ini_w, ini_h - Single new_x, new_y, new_w, new_h EndType
Type T_Data -Single val, min, max, rng, nrm, avg, rms, log10, ln EndType
Type T_V3D -Single x, y, z EndType
|
|
|
Post by (X) on May 6, 2022 2:04:43 GMT 1
Here is a Demo using a primitive version of Lib_Graph V2.
You will need to compile the Lib_Graph V2.G32 to a LG32 library.
If you right click on the form you will get a popup menu that in future versions will let you completely manage the graph properties.
|
|
|
Post by (X) on May 6, 2022 2:12:55 GMT 1
Here is the Lib Code so far...
I want to be able to save and load graph templates ready for use.
'################################################################### ' ' DISCLAIMER: THIS CODE IS OFFERED AS IS FOR EDUCATIONAL PURPOSES. ' YOU ARE FREE TO USE, COPY AND DISTRIBUTE. ' THE USE OF THIS CODE IS AT YOUR OWN RISK. ' I ACCEPT NO LIABILITY NOR MAKE ANY CLAIM OF ' CORRECTNESS OR SUITABILITY IN PART OR IN WHOLE. ' '################################################################### ' ' Filename Lib_Graph.G32 ' ' Description A helper library for plotting graphs. ' This should let a programmer setup a graph with a ' minimum of fuss and bother while offering autoscaling, ' zoom, waterfall etc... ' ' ' Author (X) ' Email xman.gb32@gmail.com ' Web-site https://gb32.proboards.com/ ' Started 2022.05.03 ' Updated <ISO date> ' ' $Export Type * $Export Proc *
Type T_Graph ' Color References... - Int32 crText - Int32 crAxes - Int32 crLines - Int32 crNumbers ' Data Properties... - Int32 Dimensions ' Dimensions 1:x, 2:x,y, 3:xyz, 4:xyzt - T_Data x, y, z, t - Int32 lpData 'The starting address of the data - Int32 cbData - Int32 EnumDataType ' Bool, Byte, Int16, Int32, Int64, Single, Double ' Graph Properties... - String*40 name - String*40 desc ' tooltiptext - String*40 date - String*40 v_axis_name - String*40 h_axis_name ' Area metrics... - Single fx, fy, fw, fh ' form metrics - Single gx, gy, gw, gh ' graph metrics - Single px, py, pw, ph ' plot metrics ' Viewer Perspective Properties... - Byte Transparency - Single ox, oy, oz ' Observer coordinates - Single rxy, ryz, rxz - T_V3D rv - Single sx, sy, sz - Boolean ScaleNorm ' adaptive vs fixed scaling - Single Zoom_Factor - Single Zoom_x, Zoom_y - T_Zoom ini - Single new_x, new_y, new_w, new_h EndType
Type T_Data -Single min, max, rng, nrm, avg, rms, log10, ln EndType
Type T_Zoom -Single x1, y1, z1, t1 -Single x2, y2, z2, t2 -Single x3, y3, z3, t3 EndType
Type T_V3D -Single x, y, z Proc L_Graph_Event Static _Popup? = False, a% If IsNothing(sb1) Ocx StatusBar sb1 sb1.SimpleText = "L_Graph_Event @ " & DateTime$ If MouseK = 2 If _Popup? = False _Popup? = True a% = PopUp("ABOUT: Lib__Graph.LG32| AutoZoom| Colors|Help", MouseSX, MouseSY) sb1.SimpleText = "Popup selection=" & a% Select a% Case 0 Ocx Form frm_Help = "Lib_Graph Help Form", 10, 10, 800, 600 With frm_Help .StartupMode = 2 .OnTop = True .ControlBox = True .Show EndWith OcxOcx frm_Help Label lbl_Help = "Label_Help", 10, 10, frm_Help.ScaleWidth - 20, frm_Help.ScaleHeight - 20 With lbl_Help .Appearance = 0 .BorderStyle = 0 .BackColor = frm_Help.BackColor .MultiLine = True .FontName = "Courier new" .FontSize = 14 .FontBold = True EndWith lbl_Help = "FILENAME: Lib_Graph.LG32"#10#10 _ "DESCRIPTION: This library code was written for:"#10#10 _ " GFA-BASIC 32 for Windows"#10#10 _ "It contains helper UDT's (User Data Types)," & _ "functions and procedures - all starting with 'L_' - to " & _ "help programmers quickly create graph templates for " & _ "plotting array stored data. See: Help File for Demos."#10#10 _ "AUTHOR: (X) 2022 "#10 _ "CONTACT: https://gb32.proboards.com/"#10#10 _ "DISCLAIMER: THIS CODE IS OFFERED FREE AS IS."#10 _ " USAGE IS AT YOUR OWN RISK." Case 1 L_Graph_AutoZoom Case 2 L_Graph_Colors Case 3 L_Graph_Help EndSelect EndIf EndIf _Popup? = False EndProc
Proc L_Graph_AutoZoom MsgBox "Autozoom" EndProc
Proc L_Graph_Colors Local cd As New CommDlg cd.ShowColor MsgBox "Color=" & Hex(cd.Color) EndProc
Proc L_Graph_Help Ocx RichEdit rtf_Help = , 10, 10, Me.ScaleWidth - 20, Me.ScaleHeight - 20 .Appearance = 1 rtf_Help.LoadFile "C:\Users\melan\Google Drive (xman.gb32@gmail.com)\(X) PROG\GB32\LG32\Lib_Graph_Help.rtf"
|
|
|
Post by (X) on May 6, 2022 2:18:16 GMT 1
This small demo shows how Lib_Graph would respond to a right click with a popup of many options to customize your graph.
'''''''''''''''''''''''''''''''''''''''''''''''''' ' Demo Lib_Graph ' $Library "Lib_Graph V2" OpenW 1 Do L_Graph_Event Sleep Until Me Is Nothing CloseW 1
|
|
|
Post by (X) on May 8, 2022 11:45:05 GMT 1
I've been slowly adding more features...
I expect the Lib_Graph.LG32 to be able to automatically respond to the graph form's Resize and Paint events. To do this, Lib_Graph.LG32 will to have to monitor the window messages conveniently mirrored in: _Mess. This is not impossible, but it does open up another "can of worms". For starters, we need to identify the message code which is an Int32 value which usually has a fixed meaning.
Here is a list of the constants associated with the window message codes.
|
|
|
Post by (X) on May 10, 2022 18:56:50 GMT 1
Here is version 4...
Now, the graph re-paints automatically if the parent window is resized. Remember that this is all done automatically - behind the scenes - within the library code.
The minimum I want to have to do is pass a data array to the Library code. From there, a user should be able to edit the many graph properties and save the configuration for later use.
There are still lots of changes to make.
I think this is something I have wanted for a long time. I am thinking this will come in handy for quite a few future projects.
|
|
|
Post by scalion on May 10, 2022 20:18:15 GMT 1
Excellent ! Tu peux encore ajouter une foule de choses. Par exemple pouvoir zoomer (mousewheel) et se promener dans les données, pouvoir cliquer sur une partie de la courbe pour avoir des infos, en copier une partie dans le presse papier, Imprimer, exporter, convertir, que sais-je encore, etc... C'était pas le but premier mais pourquoi ne pas pousser le bouchon encore plus loin avec une représentation des données en 3D (voir 4) ? Cest déjà un super outil d'analyse et de développement.
Really great job !
|
|
|
Post by (X) on May 11, 2022 11:57:17 GMT 1
En utilisant quelques autres langages de programmation, même Excel, on s'habitue d'avoir accès à un outil pour facilement générer un graph. Ça me manque avec GFA. J'espère pouvoir offrir quelque chose d'utile au group.
By using a few other programming languages, even Excel, you get used to having access to a tool to easily generate a graph. I miss it with in GFA. I hope I can offer something useful to the group.
Durch die Verwendung einiger anderer Programmiersprachen, sogar Excel, gewöhnen Sie sich daran, Zugriff auf ein Tool zu haben, mit dem Sie einfach ein Diagramm erstellen können. Ich vermisse es mit in GFA. Ich hoffe, ich kann der Gruppe etwas Nützliches bieten.
|
|