Page 1 of 1

teechart & asp 2

Posted: Mon May 08, 2006 7:10 am
by 9526928
I have written a .asp according to ASP Server Examples included with TeeChart installation. But it can't respond mouse-event. If I write .asp according to "teechart & asp"'s example in forum, I can't use ADODB.
How I write a .asp including both thing?

My failed .asp code as follow,
<!--METADATA NAME="TeeChart Pro v7 ActiveX Control" TYPE="TypeLib" UUID="{EAE6A729-65BD-489F-BF3F-7FE35B416289}"-->
<%
'Example uses TeeChart's example System ODBC datasource.


'Send output to browser. 1st time in call CreatePage
'then call RunChart method to build Chart contents

'if Request.QueryString("CreateChart")=1 Then
Response.BinaryWrite(RunChart)
'else
'CreatePage
'end if


Function RunChart()

dim img
dim Chart
dim MyVar
dim db
dim strConn
dim strSql

'Create Chart
Set Chart = CreateObject("TeeChart.TChart")

Chart.Environment.IEPrintWithPage=True
'Setup Series
Chart.Tools.Add(8)
Chart.AddSeries(scLine)
Chart.AddSeries(scLine)
Chart.Series(0).Marks.Visible=False
Chart.Series(1).Marks.Visible=False
Chart.Series(0).Title = "H2"
Chart.Series(1).Title = "O2"
'Chart.Series(0).asBar.BarStyle=bsPyramid
'Chart.Series(numbofser).asLine.ClickableLine = False

'Chart appearance
Chart.Aspect.View3d = False
Chart.Legend.Visible=True
'Chart.Axis.Bottom.Labels.Angle=90
Chart.Height=400
Chart.Width=500
Chart.Panel.Gradient.Visible=True
Chart.Header.Text(0)="TeeChart ADO example"
Chart.Header.Font.Bold=True
Chart.Axis.Bottom.Title.Caption="Product name"
Chart.Axis.Bottom.Title.Font.Bold=True
Chart.Axis.Left.Title.Font.Bold=True
Chart.Legend.Alignment = laBottom
Chart.Legend.CheckBoxes = True

'Create a random condition to vary the output
Randomize
MyVar = (40000)+CInt(rnd*20000)
Chart.Axis.Left.Title.Caption="Order Item Totals > " & MyVar

'Connect to database
Set Conn = Server.CreateObject("ADODB.Connection")
Set RSt = Server.CreateObject("ADODB.RecordSet")
db = "TrueGas.mdb"
strConn = "DBQ="+server.mappath(db)+";DefaultDir=;DRIVER={Microsoft Access Driver (*.mdb)};"
Conn.Open strConn
strSql = "select * from OnLineGas where tname='TM8#1' order by SAMPLEDT ASC"
Rst.Open strsql, Conn, 1, 3

'Connect Series to Recordset
if RSt.RecordCount > 0 then
Chart.Series(0).Datasource = RSt
Chart.Series(0).LabelsSource="SAMPLEDT"
Chart.Series(0).YValues.ValueSource="H2"

Chart.Series(1).Datasource = RSt
Chart.Series(1).LabelsSource="SAMPLEDT"
Chart.Series(1).YValues.ValueSource="O2"
else
Chart.Series(0).Fillsamplevalues(10)
Chart.Header.Text(0)="ADO database returned no values - using random data"
end if

'Cleanup and set Chart to send to browser
Rst.close
Conn.close
Set Rst=nothing
Set Conn=nothing
img=Chart.Export.asPNG.SaveToStream
Set Chart=nothing
RunChart=img

End function

Function CreatePage
Response.Write("<html>" & chr(13))
Response.Write("<HEAD><title>TeeChart Pro AX Control ADO with ASP example</title>" & chr(13))
Response.Write("<LINK REL=STYLESHEET TYPE=""text/css"" HREF=""Style.css""></HEAD><BODY>" & chr(13))
Response.Write("<img src=""TeeChartAX300x66.jpg"">" & chr(13))
Response.Write("<br><br>" & chr(13))
Response.Write("<a href=""ASPHome.htm"">Back to Contents page</a>" & chr(13))
Response.Write("<hr>" & chr(13))
Response.Write("<img id=Img1 src=""ADOTeeChart7.asp?CreateChart=1"">" & chr(13))
Response.Write("<p>Please note that server Datsources should be System DSNs not User DSNs.</p>" & chr(13))
Response.Write("<HR>Copyright &copy; 2004 Steema Software SL</BODY></HTML>" & chr(13))
Response.Write("</body>" & chr(13))
Response.Write("</html>" & chr(13))
End Function

%>