|
-
Apr 15th, 2000, 06:52 PM
#1
Thread Starter
Lively Member
I have a database table as:
Code:
COMMENT VOTES
Great 5
OK 10
Rubbish 2
. . . and I want to use this information to draw a very simple bar chart.
Any ideas? 
Simon
[Edited by SimonPearce on 04-16-2000 at 07:56 AM]
-
Apr 15th, 2000, 07:05 PM
#2
New Member
Data bound controls in VB
I have a database table as:
Code:
COMMENT VOTES
Great 5
OK 10
Rubbish 2
. . . and I want to use this information to draw a very simple bar chart.
Any ideas? 
Simon
[Edited by SimonPearce on 04-16-2000 at 07:56 AM]
Look into using data bound controls DAO and ADO.
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.
-
Apr 15th, 2000, 08:05 PM
#3
Fanatic Member
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
-
Apr 15th, 2000, 10:08 PM
#4
Fast Barchart
Hello
You could use an array of label controls also for a quick and dirty barchart:
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
I've used this when I don't want to have all the overhead for the chart control.
Hope this helps,
Roger
-
Apr 16th, 2000, 04:36 AM
#5
Thread Starter
Lively Member
That's great - just what I needed 
Simon
Hello
You could use an array of label controls also for a quick and dirty barchart:
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
I've used this when I don't want to have all the overhead for the chart control.
Hope this helps,
Roger
-
Apr 16th, 2000, 04:53 AM
#6
Addicted Member
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.
-
Apr 16th, 2000, 06:16 AM
#7
Hello,
Ok, Lyla I played around a little and I came up with this.
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
I don't know if this is any easier then what you came up with.
Best
Roger
-
Apr 16th, 2000, 08:10 AM
#8
Addicted Member
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.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|