BUG: Graph Axis Titles Don't Switch on Horizontal Bar Graphs

Last reviewed: June 21, 1995
Article ID: Q83463
The information in this article applies to:

- Professional Edition of Microsoft Visual Basic for Windows,

  versions 2.0 and 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 INFORMATION

Step-by-Step Example

1. 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 reference words: buglist1.00 buglist2.00 buglist3.00 1.00 2.00
    3.00
    KBCategory: kbprg kbbuglist
    KBSubcategory: PrgCtrlsCus


    THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.

    Last reviewed: June 21, 1995
    © 1998 Microsoft Corporation. All rights reserved. Terms of Use.