Microsoft KB Archive/256627

From BetaArchive Wiki
The printable version is no longer supported and may have rendering errors. Please update your browser bookmarks and please use the default browser print function instead.

Article ID: 256627

Article Last Modified on 8/23/2005



APPLIES TO

  • Microsoft Office Web Components
  • Microsoft Office Chart Component 9.0
  • Microsoft Visual Basic, Scripting Edition 5.0



This article was previously published under Q256627

SYMPTOMS

When you use the Office Chart component, the Minimum and Maximum properties of a WCScaling object return incorrect values when called during the onLoad event of a Web page in Internet Explorer. These properties might return incorrect values such as zero or a number that is very small.

CAUSE

With Internet Explorer, there is no guarantee that that all controls on a Web page have an associated window until the Web page finishes loading. Therefore, the Minimum and Maximum properties for a WCScaling object may be uninitialized during the window's onLoad event and attempts to retrieve the Minimum and Maximum properties could result in inconsistent values.

RESOLUTION

To work around this problem, retrieve the Minimum or Maximum property for a WCScaling object after Internet Explorer has associated a window with the Chart component. If you want to retrieve these properties when your Web page loads, use the window's setTimeout method in the onLoad event to allow the window to finish loading. This work around is illustrated in the "More Information" section.

MORE INFORMATION

The following steps illustrate how to reproduce the behavior of the Maximum property when called from the onLoad event. The script creates three charts at run-time and then displays the value returned from the Maximum property in the title of each chart.

Steps to Reproduce Behavior

  1. Use a text editor, such as Notepad, and create a text file that contains the following:

    <HTML>
    
    <BODY>
    <OBJECT id=ChartSpace1 classid=CLSID:0002E500-0000-0000-C000-000000000046></OBJECT>
    <OBJECT id=ChartSpace2 classid=CLSID:0002E500-0000-0000-C000-000000000046></OBJECT>
    <OBJECT id=ChartSpace3 classid=CLSID:0002E500-0000-0000-C000-000000000046></OBJECT>
    </BODY>
    
    <SCRIPT Language=VBScript>
    
    Dim c
    
    Function Window_OnLoad()
    
       Set c = ChartSpace1.Constants
    
       CreateCharts()
    
       GetMax()
    
    End Function
    
    Sub CreateCharts()
    
       Dim i
       Dim oCSpace, oChart
    
       'Add data to each of the three chartspace objects
       For i=1 to 3
          Set oCSpace = document.all.item("Chartspace" & i)
          oCSpace.Clear
          Set oChart = oCSpace.Charts.Add
          oChart.HasTitle=True
          With oChart.SeriesCollection.Add
             .SetData c.chDimCategories, c.chDataLiteral, _
                      Array("A","B","C")
             .SetData c.chDimValues, c.chDataLiteral, _
                      Array(Rnd()*10, Rnd()*10, Rnd()*10)
          End With
    
       Next
    
    End Sub
         
    Sub GetMax()
    
       Dim i
       Dim oCSpace
    
       'Display the maximum of the value axis for each chart in the chart title
       For i=1 to 3
          Set oCSpace = document.all.item("Chartspace" & i)
          oCSpace.Charts(0).Title.Caption = "Max = " & _
             oCSpace.Charts(0).Axes(c.chAxisPositionLeft).Scaling.Maximum
       Next
    
    End Sub
    
    </SCRIPT>
    
    </HTML>
                        
  2. Save the text file as ChartMax.htm.
  3. Start Internet Explorer and browse to ChartMax.htm.

    RESULTS: The maximum value that is displayed in the Charts' titles may not be correct. The titles for one or more of the charts may indicate a maximum for the value axis that is 0 or a very small number.

To workaround the problem in the sample code, you could call the GetMax function, by using the window's setTimeout method so that Internet Explorer can complete the loading of the window before you retrieve the Maximum property of the value axis. To use the workaround, replace this line in the Window_onLoad event:

GetMax()
                

with:

window.setTimeout "GetMax", 200, "VBScript"

                

NOTE: Because this is a timing related issue, you may have to adjust the timeout so that you get the right behavior.

REFERENCES

Programming Microsoft Office 2000 Web Components by Dave Stearns, ISBN 0-7356-0794-X, Chapter 6 "Dynamic and Real-Time Charting"

For more information on the Office Web Components, please visit the following support site:

For sample code that demonstrates solutions using the Office 2000 Web Components with VBScript and ASP, see the following article in the Microsoft Knowledge Base:

258187 OWebComp.exe Contains Scripting Samples for the Office Web Components



Additional query words: normalize normalization axes scaling maximum minimum max min

Keywords: kbofficewebchart kbprb KB256627