BUG: Graph Axis Titles Don't Switch on Horizontal Bar Graphs
ID: Q83463
|
The information in this article applies to:
-
Microsoft Visual Basic Professional Edition for Windows, versions 2.0, 3.0
-
Microsoft Professional Toolkit for Microsoft Visual Basic programming system for Windows, version 1.0
SYMPTOMS
The Graph custom control allows you to convert your graph control from a
non-horizontal bar graph to a horizontal bar graph or vice versa. This
conversion will switch all necessary information to its proper
position except for the axis titles. The BottomTitle and LeftTitle
should switch positions, but do not.
WORKAROUND
As a workaround for this problem, test whether the graph is being
converted from or to a horizontal bar graph, and switch the values for
BottomTitle and LeftTitle yourself. The example shown in the More
Information section illustrates the problem and provides code to work
around it.
STATUS
Microsoft has confirmed this to be a bug with the Graph custom control
supplied with the Microsoft products listed at the beginning of this
article. We are researching this problem and will post new information here
in the Microsoft Knowledge Base as it becomes available.
MORE INFORMATIONStep-by-Step Example
- Start Visual Basic or from the File menu, choose New Project (ALT,
F, N) if Visual Basic is already running. Form1 is created by default.
- From the File menu, choose Add File. In the Files list box, select
the GRAPH.VBX custom control file. The Graph tool appears in the
toolbox.
- On Form1, add three command buttons (Command1, Command2, and
Command3) and a Graph control (Graph1).
- Change the following properties:
Control Property Value
-----------------------------------------------------
Command1 Caption Make Horizontal
Command2 Caption Make Vertical
Command3 Caption Switch Correctly
Graph1 Width 4000
Graph1 Height 2500
Graph1 GraphType 3 (default)
Graph1 GraphStyle 0 (default)
Graph1 GraphData 10, 20, 30, 40, 50
Graph1 BottomTitle Title for axis labeled 1-5
Graph1 LeftTitle Title for axis labeled 0-50
- In the Command1 Click event, add the following code:
Sub Command1_Click ()
Graph1.GraphStyle = 1 'horizontal
Graph1.DrawMode = 2 ' redraws graph with new properties
End Sub
- In the Command2 Click event, add the following code:
Sub Command2_Click ()
Graph1.GraphStyle = 0 'default (vertical)
Graph1.DrawMode = 2 ' redraws graph with new properties
End Sub
- In the Command3 Click event, add the following code:
Sub Command3_Click ()
Const TRUE = 1
OldStyle = Graph1.GraphStyle
Graph1.GraphType = 3 'or change according to your needs
Graph1.GraphStyle = 1 'or change according to your needs
If (Graph1.GraphType=3) Or (Graph1.GraphType=4) Then BarGraph%=TRUE
' The next line of code takes advantage of the fact that the
' GraphStyle numbers for the horizontal bar graphs are odd and the
' vertical are even.
If (Graph1.GraphStyle + OldStyle) Mod 2 = 1 Then Switched% = TRUE
If BarGraph% And Switched% Then
temp$ = Graph1.BottomTitle
Graph1.BottomTitle = Graph1.LeftTitle
Graph1.LeftTitle = temp$
End If
Graph1.DrawMode = 2
End Sub
- Press F5 (or ALT, R, S) to run the program.
When you run the program and click the Command1 button, Graph1 will
redraw itself as a horizontal graph. The left and bottom labels
switched but the LeftTitle and BottomTitle do not. Next, click the
Command2 button. The Command2 Click event will return the graph to its
original appearance.
When you click the Command3 button, Graph1 will redraw itself as a
horizontal graph with all labels and titles switched appropriately.
The code for the Command3 Click event was written to react appropriately,
regardless of which GraphType and GraphStyle are chosen.
Additional query words:
buglist1.00 buglist2.00 buglist3.00 1.00 2.00 3.00
Keywords :
Version : WINDOWS:2.0,3.0; :1.0
Platform : WINDOWS
Issue type :
|