How can i make a line-diagram?
Printable View
How can i make a line-diagram?
Hum what do you mean? What's the diagram for? Could you explain a bit more please? :rolleyes:
I have a number of values which i want to show in a more exciting way...
That's easy :)
How are the values stored? In a database? In variables? In arrays?
If you can store them in arrays, it's gonna be much easier :)
I store them in an array :D
In that case it's easy :)
Do you have any idea of what the maximum value should be? In that case we can cut down the code a lot ;)
Yeah, values is only 0-24. :)
Cool :)
Here's the code. It loops trough all the elements in the array except for the last one, and draws a line between this element and the next one :)
(Here, X represents the index of each element, and Y represents the value of each element)
VB Code:
For i = 0 to UBound(TheValues)-1 Form1.Line (i*15,TheValues(i)*15)-((i+1)*15,TheValues(i+1)*15) Next i
The size of the grid, in this case, is 15 (pixels or twips, it depends on the ScaleMode of the form), but you can change that value if you want :)
Is there any way to color it? Fill the diagram i mean.
No, I'm afraid that would be a bit hard unless you're familiar with the Windows API :)
Uhh, just the basics, i know how to use API. What API call should i use?
It's "Fill"-something :)
Look for an article on it, if you use it to paint just below one of the items of the array it should work ;)
Public Declare Function ExtFloodFill Lib "gdi32" Alias "ExtFloodFill" (ByVal hdc As Long, ByVal x As Long, ByVal y As Long, ByVal crColor As Long, ByVal wFillType As Long) As Long
This? There is a FloodFill API call to, but it look almost the same.
Thanks, think i'm going to mess around a bit with this. :D
Yeah, I think it's the FloodFill one but the one you have should work ok ;)
If you need help... just post here again :)
Yes, but that wouldn't draw a filled graph unless it was made with columns :)
Ah, I didnt read through the entire thread. This is a line graph =).
Z.
VB also has controls for graphing - MSChart is really high end powered and does 3D renderings. High memory usage too.
DataGrid is another. If you must do a lot of graphs or change it constantly like in showinf %use of a channel, these are easier to program.
What's MSChart, and DataGrid?
Ohh, found MSChart, but how do you use it?