MicroSoft VBScript and ASP specific


Q: IIS Server locks up when running TeeChart as a server instance with an ASP script.


Check that you are not still running an evaluation of TeeChart on the server as the nag screen generated by the eval will cause problems with server side scripts.
Versions earlier than teechart.ocx v 3.0.0.3 (right click on ocx for properties) would hang on servers  with a local (on server) printer installed.


Q: How do I run a serverside instance of TeeChart in IIS4 or 5?

There are several ASP examples of this with source code available at:

http://www.steema.com/products/teechart/asp/ASPHome.htm


Q: How do I define colours in VBScript?


Colour constants vbRed, vbBlue, etc are not available to VBScript in versions older than 2.0 (IIS3 and IE3). You can define colours using RGB values. Eg. RGB(255,0,0) is red, RGB(0,255,0) is green, etc.

clTeeColor (EConstants in help) equates to 536870912


Q: Using an ODBC Datasource. How do I get the "myfilename.tee" chart to update with current data when it is loaded into an HTML page?


The tee format file will save the Chart definition with current data (if any). To use it with updateable data in an html page you need to define the datasource on the page.

Sub Window_onload()
  TChart1.Import.LoadFromFile("c:\temp\dbchart.tee")	
  TChart1.Series(0).DataSource = "DSN=TeeChart Pro Database; 
  sql=SELECT * from employee"
  TChart1.Series(0).LabelsSource = "LASTNAME"
  TChart1.Series(0).YValues.ValueSource = "SALARY"

  TChart1.TimerEnabled = True  'setting up for data refresh
  TChart1.TimerInterval = 4000
end Sub

Sub TChart1_OnTimer()
  TChart1.Series(0).CheckDatasource
End Sub


The above code redefines the datasource for the Series and sets the timer with CheckDatasource to renew the data every 4000ms. This code requires that the ODBC DSN exists on the client machine.

An alternative to this is to make similar changes to the "Return template Chart" ASP example on: http://www.steema.com/products/teechart/asp/ASPHome.htm . In this case the OnTimer() event would run the line:

TChart1.Import.LoadFromURL("http://<%=ServerPath%>/TeeChart5/TeeFromWeb.asp")


Q:TeeChart EConstants don't work in VBScript.


For VBScript standard TeeChart enum constants need to be replaced with their numeric values. The TeeChart Online helpfile shows the numeric values necessary (eg. EMultibar Type 'mbNone = 0').
Eg.

'The result in this case will be:
TChart1.Series(0).asBar.MultiBar = 0

This is not true for VBScript in ASP files, where the additional of a MetaData section at the very beginning of the ASP script enables the TeeChart constants to be used:

<!--METADATA NAME="TeeChart Pro v5 ActiveX Control" TYPE="TypeLib" UUID="{B6C10482-FB89-11D4-93C9-006008A7EED4}"-->


Q:Can I use PARAMS to set TeeChart properties in an HTML page?


No. TeeChart properties may be set at design time and saved in Base64 format with a tool such as MS ActivePad. Parameters may be set for runtime using VBScript or Javascript.


Q: If I reload the page before IIS has "released" the image file (about 1 minute (?)), I get the "error '8000ffff' Catastrophic failure". Is there a way I can write the image directly to the browers? e.g. Response.binaryWrite TChart1.?

There is no way to write directly to the browser. This is a known issue with IIS and is work aroundable by using a dynamic naming technique with filenames to save. The example of one option below showing its application to tee and jpeg files.

<HTML>
<%
dim filePath
dim httpPath
dim outputTeefile
dim outputJpegfile

' where server filepath locates to the same as URL below
filePath = "d:\data\WebTestFiles\"
httpPath = "http://128.0.0.55/testfiles/"
outputTeefile = "Chart" & Session.Sessionid & Replace(Time, ".", "") &
".tee"
outputJpegfile = "Chart" & Session.Sessionid & Replace(Time, ".", "") &
".jpg"
Set Chart1 = CreateObject("TeeChart.TChart")
Chart1.AddSeries(1)
Chart1.Aspect.View3D=False
'use your methods eg via DB to populate Chart or...
Chart1.Series(0).FillSampleValues 20
Chart1.Export.SaveToFile filepath & outputTeefile
Chart1.Export.SaveToJPEGFile filepath & outputJpegfile, False,
jpegBestQuality, 100, 450, 290
%>
<HEAD></HEAD><BODY>
<p>In the client section of the page you can display JPEG or Live
Charts.</p>

<SCRIPT LANGUAGE=VBSCRIPT>
Sub FillChart()
TChart1.Import.LoadFromURL("<%=httpPath%><%=outputTeefile %>")
End Sub
Sub TChart1_OnAfterDraw()
TChart1.Canvas.Font.Color = RGB(240,240,50)
TChart1.Canvas.Font.Bold=True
If TChart1.SeriesCount > 0 then
If TChart1.Series(0).Count > 0 then
TChart1.Canvas.TextOut TChart1.Axis.Left.Position, _
TChart1.Axis.Top.Position - 18, _
"Max point: " & TChart1.Series(0).YValues.Maximum
End if
End if
end sub
</SCRIPT>

<p>Here loading the Chart with a button (or could use IE Window_Onload
event):</p>
<p><input type="button" value="Populate Chart" onclick="FillChart"
name="cdmChart1"></p>

<OBJECT ID="TChart1" WIDTH=450 HEIGHT=290
CLASSID="CLSID:008BBE7E-C096-11D0-B4E3-00A0C901D681">
</OBJECT>

<IMG SRC=<%=httpPath%><%=outputJpegfile%>> </A>

</BODY></HTML>

The situation is different in IIS4 and 5, however, where images can be written directly to the browser:

<!--METADATA NAME="TeeChart Pro v5 ActiveX Control" TYPE="TypeLib" 
UUID="{B6C10482-FB89-11D4-93C9-006008A7EED4}"-->
<%
' Meta data section above to permit use of TeeChart constants in script

Set Chart1 = CreateObject("TeeChart.TChart")

Chart1.AddSeries(scPoint)
Chart1.Series(0).FillSampleValues(10) 

Response.BinaryWrite (Chart1.Export.asPNG.SaveToStream)
%>