OK. Here's Version 2.0 of the control.
It can now handle multiple datasets
This allows you to add even more functionality...check out the music equalizer demo
This demo show's you most of the styles and functionality you can do with this control, except the Loading and Saving of the graph.
I will write a form and add it into the demo to do this.
Wooooof
Last edited by Wokawidget; Aug 18th, 2004 at 11:36 AM.
There are a few little bugs left, but they are hard to replicate
I will clear them up soon.
One thing it doesn't do, is multiple datasets in bar mode. This is because the last dataset drawn overwrites the previous bars from the other datasets.
Not sure how to do this yet...maybe offset them or something. Hnmmmmmm
Re: Simple, but functional and VERY effective graph control
Wow! Thanks a lot!
One slight problem, when I try to open your sample programme so I can try and understand how it works, i Get the following errors:
"Line 13: Class vbGraph.Graph of control Graph1 was not a loaded control class." for each .frm
I guess this is me being inadequate in using VB, could someone possibly tell me what I need to do? I tried to install VBGraph as a component, but that didn't seem to work.
Cheers, Chris.
PS - Here is the VB Code I have for my application, does it seem straightforward to get the information that I am currently writing into the textboxes, to be reperesented in this chart?
Private Sub Timer1_Timer()
Dim buffer() As Byte
'define buffer to use for the data
'in this configuration you can only send 8 bytes at a time
ReDim buffer(8)
'write to PIC
HIDComm1.WriteTo buffer(), 8
'read data back from the PIC
buffer() = HIDComm1.ReadFrom(8)
'put result from AN0 channel into first text box Its the 8 bits in each of
'these buffers that I want to Chart in RealTime
Text1.Text = buffer(1)
'put result from AN1 channel into second text box
Text2.Text = buffer(2)
'put result from AN2 channel into third text box
Text3.Text = buffer(3)
'put result from AN4 channel into fourth text box
Text4.Text = buffer(4)
'put result from AN5 channel into fifth text box
Text5.Text = buffer(5)
'put result from AN6 channel into sixth text box
Text6.Text = buffer(6)
'put result from AN7 channel into seventh text box
Text7.Text = buffer(7)
End Sub
Private Sub Form_Load()
'connect to the USB device as the program starts
HIDComm1.Connect
End Sub
Private Sub Form_Terminate()
'disconnect from the USB device as prgoram ends
'THIS IS IMPORTANT
HIDComm1.Uninit
End Sub
Private Sub HIDComm1_ConnectSuccess(ByVal Status As Long)
Caption = "Huzzah! - Its Connected"
End Sub
Private Sub HIDComm1_Disconnected(ByVal Status As Long)
Caption = "Not Connected"
End Sub
Private Sub Timer2_Timer()
'try and reconnect the PIC
If HIDComm1.Connected = False Then
HIDComm1.Connect
End If
Re: Simple, but functional and VERY effective graph control
Hi Wokawidget,
I did not look at your usercontrol, but reading about it, I got an idea.
In this thread http://www.vbforums.com/showthread.php?t=328242 , I did some reserch on fixing the distorted sound, and i got the solution with the trend thing, I tought you can use the same thing to draw graphs...
Anyways, I wrote some code to see what I mean, put a picturebox on the form, and paste the following code to see it in action.
The only functions I wrote are: DrawTrend, ExpandPoints, ExpandPointsB, and how to use them in Form_Load.
Maybe you can incorporate this in your graphing usercontrol...
VB Code:
Option Explicit
Private Type POINT
X As Double
Y As Double
End Type
Private Sub Form_Load()
Dim SinglePoints(4) As Double, InTrendPoints() As POINT, OutTrendPoints() As POINT
SinglePoints(0) = 10
SinglePoints(1) = 35
SinglePoints(2) = 50
SinglePoints(3) = 18
SinglePoints(4) = 13
' increase the "ExpandTo" param to have even more precision
InTrendPoints = ExpandPoints(SinglePoints, 60)
'InTrendPoints = ExpandPointsB(SinglePoints, 60) ' a simpler expand...
Re: Simple, but functional and VERY effective graph control
Very nice code indeed!
Should be quite easy to add in.
All that should be need, at 1st glance, if a function to take the data from one dataset, and pass it through those functions above, and return another dataset with many many point (so it looks like a curve).
OK. Here's Version 2.0 of the control.
It can now handle multiple datasets
This allows you to add even more functionality...check out the music equalizer demo
This demo show's you most of the styles and functionality you can do with this control, except the Loading and Saving of the graph.
I will write a form and add it into the demo to do this.
Wooooof
This is one great program! Thanks a lot for sharing it.
I have couple of questions tho
1. Is it possible to add Hscroll to line graph, so that if we have about 10000 points to put on the graph we can, lets say see only 100 of them on the picture and then when scrolling see the others. Sort of like real time graph but old point don't disapear they stay there and can be seen if scrolled back.
2. Zoom in, zoom out Maybe?
3. A small tutorial on how to do this of course not the whole thing just to have a idea...
4. Make the graph interactive. show the points, label them when mouse point on one it will show it's coordinates
Re: Simple, but functional and VERY effective graph control
Hello Woka )
Firstly .. its a gr8 program that u have written and it is really helpfull for n00bs like me . But as i am still a n00b , i am having some problems with using vbgraph. I made an ocx from the vb project u posted, and included in my project. Now, all the settings are understandable but i have no clue as to how to pass on the data to be graphed ?? i cud'nt see no variables or arrays or anything of the sort .... and there was nothing on the post . Im using it to make a PC based Oscilloscope ( or atleast planning to use vbgraph for plotting data) coz i cud'nt find any other method to plot data in realtime ......( any suggestions will be greatly appreciated )
Also, can data values below zero be plotted on the graph ?? If so how ??
Re: Simple, but functional and VERY effective graph control
Thanks
If you open the demo project and look at the code in the forms...frmMusic, frmBars etc.
You will see the code that adds the data to the graph. It's very simple.
Re: Simple, but functional and VERY effective graph control
I just stumbled on your code and it looks like just what I need. Having read through the thread, I notice you haven't answered a couple of questions which are particularly relevant to me:
1) "Yeahdisk" writes: "One slight problem, when I try to open your sample programme so I can try and understand how it works, i Get the following errors:
"Line 13: Class vbGraph.Graph of control Graph1 was not a loaded control class." for each .frm"
I get this too. How do I overcome it and more importantly, how do I access the control in my own projects?
2) Rookie7799 writes: "Is it possible to add Hscroll to line graph, so that if we have about 10000 points to put on the graph we can, lets say see only 100 of them on the picture and then when scrolling see the others. Sort of like real time graph but old point don't disapear they stay there and can be seen if scrolled back."
Re: Simple, but functional and VERY effective graph control
1) the project file. I did also try one with the file extension .vbg - is that the solution file?
how do I access the control in other projects?
2) I could give it a crack - any hints on how (I'm still a novice)? I've noticed that you used a picture box as the basis of the graph, but this doesn't include scroll bars in its properties.
Re: Simple, but functional and VERY effective graph control
Thanks
Well getting data from a DB and my graph control are 2 completely different things.
All you need to do is use code similar to what is found here: http://www.vbforums.com/showthread.p...t=vb6+database and then add that to my code demo for the graph, and instead of adding data to the graph from a static function, you call your new function that loads data from a DB.
Re: Simple, but functional and VERY effective graph control
Hi, I'm having trouble using the graph control.
I compiled the vbGraph.vbp to an .ocx control object and added it to my project as a component. Now I get an error when I want to use the Dataset type to set up datasets. It says that user-defined type is not defined ??? What should I do differently?
-e- my bad, I was using the older vbGraph build, which didn't have datasets defined.
Last edited by navaho; Oct 14th, 2007 at 11:28 PM.
Re: Simple, but functional and VERY effective graph control
Nope, and nope. Glad you like it.
This wasn't supposed to replace the MSChart control.
It was merely to create quick little graphs like in Task Manager and the Media Player equalizer control.
Re: Simple, but functional and VERY effective graph control
Haha, I didn't even know there was an MSChart control. I'm a java developer by trade but I needed a quick app that could easily make Windows API calls so I gave VB a shot. I'll look into the MSChart control, hope it's as easy to use as your graph control!
Re: Simple, but functional and VERY effective graph control
Thanks
There is no native way to export the data from the datasets.
You would have to wraite code that did that for you by looping through the datasets, then looping through the points in the dataset and outputting them to a string, and then write the string to a file.
the psuedo code would be:
Code:
For Each DataSet in DataSets
Define String csvLine
For Each point in dataSet.Points
csvLine += "," + point.value
Next
Write csv line string to txt file
Next
I dont have the VB6 graph code in front of me I am afraid and it's been a good 4 years since I looked at it
Re: Simple, but functional and VERY effective graph control
Hi,
Si, thanks for picking this up for me.
Sorry I didn't get back to you personally, but it seems Si took care of your question
All points need to be added to the Dataset.Points class, as shown above.
The graph can handle multiple datasets, and thus plot more than one set of data onto the graph.
Re: Simple, but functional and VERY effective graph control
Originally Posted by navaho
Hi, I'm having trouble using the graph control.
I compiled the vbGraph.vbp to an .ocx control object and added it to my project as a component. Now I get an error when I want to use the Dataset type to set up datasets. It says that user-defined type is not defined ??? What should I do differently?
-e- my bad, I was using the older vbGraph build, which didn't have datasets defined.
....I had the same problem except could not resolve it. I could only find 2 entries of vbGraph.zip listed here and I made sure to use the most recent. Still getting
"Can't find project or library"
and the highlighted line is Dim objDataset As Dataset
Re: Simple, but functional and VERY effective graph control
hi! I am new in using vb and i am currently making a project in vb6. my project is suppose to function like this: from a remote sensor, temperature samples will be gathered and transfer the data into computer via SMS. In the computer the interfaced used is VB6, I have been able to save the data into the flex grid, the next thing I should do is to plot it in real time basis.
-that was a big prob, cause this is my first time in vb and i locked so much of idea about this. please help me here. thanks a lot.
Re: Simple, but functional and VERY effective graph control
Hi Woka,
Thanks, finally someone has noticed my post, if you don't mind, where can I find that sample codes? I have downloaded a sample code that you have posted entitled vbgraph, but I can't make it work. when I am trying to run the program, it always has an error : method or data member not found, then the .Redraw has been highlighted. thanks.
Re: Simple, but functional and VERY effective graph control
hi,
how could I attached the file? i mean the screen shot for error msg? i am sorry i am really new here and this is my first time to join a forum, what actually am i doing is i run the program, i was thinking if it requires additional api or what? really sorry, im struggling here, thanks for your help
Additional, Hi, I want to also ask about this equation,
If lngIndex = 3 Then
lngValue = 70 + (Rnd * 10) - 5
ElseIf lngIndex = 2 Then
lngValue = 50 + (Rnd * 50) - 25
Else
I dont understand what's happening here, why should lngValue is changed. Thanks.
Last edited by cristey; Sep 25th, 2010 at 09:00 AM.
Reason: i forgot some important points
Re: Simple, but functional and VERY effective graph control
That is my code to get it to produce random graph data using random numbers.
I probably made it more complex than needed.
To post a screen shot click on the Go Advanced button at the bottom of this thread while logged in. Then you see a button to attach files.
Re: Simple, but functional and VERY effective graph control
hi Woka,
i really like your program, i have download the codes again ad surprised that it worked fine. Thanks so much that would be a big help to my project. thanks a lot ad i hope that you will be able to make more interesting topics.