Difference between revisions of "Microsoft KB Archive/256627"

From BetaArchive Wiki
m (Text replacement - "&" to "&")
m (Text replacement - """ to """)
 
Line 60: Line 60:
 
== RESOLUTION ==
 
== 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.
+
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.
  
 
</div>
 
</div>
Line 101: Line 101:
 
   'Add data to each of the three chartspace objects
 
   'Add data to each of the three chartspace objects
 
   For i=1 to 3
 
   For i=1 to 3
       Set oCSpace = document.all.item(&quot;Chartspace&quot; & i)
+
       Set oCSpace = document.all.item("Chartspace" & i)
 
       oCSpace.Clear
 
       oCSpace.Clear
 
       Set oChart = oCSpace.Charts.Add
 
       Set oChart = oCSpace.Charts.Add
Line 107: Line 107:
 
       With oChart.SeriesCollection.Add
 
       With oChart.SeriesCollection.Add
 
         .SetData c.chDimCategories, c.chDataLiteral, _
 
         .SetData c.chDimCategories, c.chDataLiteral, _
                   Array(&quot;A&quot;,&quot;B&quot;,&quot;C&quot;)
+
                   Array("A","B","C")
 
         .SetData c.chDimValues, c.chDataLiteral, _
 
         .SetData c.chDimValues, c.chDataLiteral, _
 
                   Array(Rnd()*10, Rnd()*10, Rnd()*10)
 
                   Array(Rnd()*10, Rnd()*10, Rnd()*10)
Line 123: Line 123:
 
   'Display the maximum of the value axis for each chart in the chart title
 
   'Display the maximum of the value axis for each chart in the chart title
 
   For i=1 to 3
 
   For i=1 to 3
       Set oCSpace = document.all.item(&quot;Chartspace&quot; & i)
+
       Set oCSpace = document.all.item("Chartspace" & i)
       oCSpace.Charts(0).Title.Caption = &quot;Max = &quot; & _
+
       oCSpace.Charts(0).Title.Caption = "Max = " & _
 
         oCSpace.Charts(0).Axes(c.chAxisPositionLeft).Scaling.Maximum
 
         oCSpace.Charts(0).Axes(c.chAxisPositionLeft).Scaling.Maximum
 
   Next
 
   Next
Line 146: Line 146:
 
with:<br />
 
with:<br />
  
<pre class="codesample">window.setTimeout &quot;GetMax&quot;, 200, &quot;VBScript&quot;
+
<pre class="codesample">window.setTimeout "GetMax", 200, "VBScript"
  
 
                 </pre>
 
                 </pre>
Line 156: Line 156:
 
== REFERENCES ==
 
== REFERENCES ==
  
''Programming Microsoft Office 2000 Web Components'' by Dave Stearns, ISBN 0-7356-0794-X, Chapter 6 &quot;Dynamic and Real-Time Charting&quot;<br />
+
''Programming Microsoft Office 2000 Web Components'' by Dave Stearns, ISBN 0-7356-0794-X, Chapter 6 "Dynamic and Real-Time Charting"<br />
 
<br />
 
<br />
 
For more information on the Office Web Components, please visit the following support site:<br />
 
For more information on the Office Web Components, please visit the following support site:<br />

Latest revision as of 13:53, 21 July 2020

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