VB Graph Axes Titles Don't Switch on Horizontal Bar Graphs

ID Number: Q83463

1.00

WINDOWS

buglist1.00

Summary:

The Graph 1.2 custom control from Microsoft Professional Toolkit for

Visual Basic 1.0 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 axes titles. The BottomTitle and LeftTitle

should switch positions, but they do not.

Microsoft has confirmed this to be a problem with the Graph version

1.2 custom control supplied with Microsoft Professional Toolkit for

Microsoft Visual Basic programming system version 1.0 for Windows. We

are researching this problem and will post new information here as it

becomes available.

More Information:

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 following example illustrates

the problem and provides code to work around it.

Example

-------

1. Run Visual Basic, or from the File menu, choose New Project (ALT,

F, N) if Visual Basic is already running. Form1 is created by

default.

2. 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.

3. On Form1, add three command buttons (Command1, Command2, and

Command3) and a Graph control (Graph1).

4. 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

5. 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

6. 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

7. 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

8. Press F5 (or ALT, R, S) to run the program.

When you run the program and click on 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 on the

Command2 button. The Command2 Click event will return the graph to its

original appearance.

When you click on 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 what GraphType and GraphStyle are chosen.

Additional reference words: 1.00