I have a database table as:
. . . and I want to use this information to draw a very simple bar chart.Code:COMMENT VOTES
Great 5
OK 10
Rubbish 2
Any ideas? :)
Simon
[Edited by SimonPearce on 04-16-2000 at 07:56 AM]
Printable View
I have a database table as:
. . . and I want to use this information to draw a very simple bar chart.Code:COMMENT VOTES
Great 5
OK 10
Rubbish 2
Any ideas? :)
Simon
[Edited by SimonPearce on 04-16-2000 at 07:56 AM]
Look into using data bound controls DAO and ADO.Quote:
I have a database table as:
. . . and I want to use this information to draw a very simple bar chart.Code:COMMENT VOTES
Great 5
OK 10
Rubbish 2
Any ideas? :)
Simon
[Edited by SimonPearce on 04-16-2000 at 07:56 AM]
Place a Chart on a simple form. Add a Data Control. In this case add a DAO control. Create a ODBC link to you database. IN your Database create a query to supply your data. In VB use this as the recordset. The rest of the details is in the VB docs.
Microsoft wants you to use Data Binding for record access. It can get tricky so read carefully.
Chart controls or line controls are nice and easy, this looks sort of like the sort of thing to appear on a web page though so (I'm guessing here, it's the alcohol talking) in ASP you can set the widths of a 1 pixel wide picture to create a graph on a web page...
Ignore me if I'm going in the wrong direction
Hello
You could use an array of label controls also for a quick and dirty barchart:
I've used this when I don't want to have all the overhead for the chart control.Code:' set labels up
Label1(0).BackColor = QBColor(4)
Label1(1).BackColor = QBColor(1)
Label1(2).BackColor = QBColor(6)
' multiply 100 for effect
Label1(0).Width = 100 * Var1
Label1(1).Width = 100 * Var2
Label1(2).Width = 100 * Var3
Hope this helps,
Roger
That's great - just what I needed :)
Simon
Quote:
Hello
You could use an array of label controls also for a quick and dirty barchart:
I've used this when I don't want to have all the overhead for the chart control.Code:' set labels up
Label1(0).BackColor = QBColor(4)
Label1(1).BackColor = QBColor(1)
Label1(2).BackColor = QBColor(6)
' multiply 100 for effect
Label1(0).Width = 100 * Var1
Label1(1).Width = 100 * Var2
Label1(2).Width = 100 * Var3
Hope this helps,
Roger
Hi RvA
That is a good idea.
My Q. is how about the following code:
Label1(0).Height = 100 * Var1
This would take the bar downward! And it wouldn't take a negative value to take it upward.
I have done it, But it took too much to accomplish it!
Any work around?
Thanx.
Hello,
Ok, Lyla I played around a little and I came up with this.
I don't know if this is any easier then what you came up with.Code:Dim I As Integer, iMaxHeight As Integer
Dim iLabelOffset As Integer
For I = 0 To Label1.UBound
Label1(I).Visible = False ' hide them all
Next I
' set there colors
Label1(0).BackColor = QBColor(4)
Label1(1).BackColor = QBColor(1)
Label1(2).BackColor = QBColor(6)
' get the current offset
iLabelOffset = Label1(0).Top - Label1(0).Height
' multiply 100 for effect
Label1(0).Height = 100 * Var1
Label1(1).Height = 100 * Var2
Label1(2).Height = 100 * Var3
' find the tallest label
For I = 0 To Label1.UBound
If Label1(I).Height > iMaxHeight Then
iMaxHeight = Label1(I).Height
End If
Next I
' set the height for all the labels
For I = 0 To Label1.UBound
Label1(I).Top = (iMaxHeight - Label1(I).Height) + iLabelOffset
Label1(I).Visible = True
Next I
Best
Roger
Hi RvA.
Same result, different method :)
Label1(0).Top = Label1(0).Height + (Label1(2).Height - Label1(0).Height)
Label1(1).Top = Label1(0).Height + (Label1(2).Height - Label1(1).Height)
Label1(2).Top = Label1(0).Height + (Label1(2).Height - Label1(2).Height)
Thanx again.