Print and Print Preview in V6

TeeChart for ActiveX, COM and ASP
Post Reply
MCD
Newbie
Newbie
Posts: 14
Joined: Fri Nov 15, 2002 12:00 am

Print and Print Preview in V6

Post by MCD » Wed Jul 18, 2007 12:15 pm

Hello, We are having a coder develop a web application for us using ASP and the ActiveX TeeChart. We have several other applications on the same server on the same domain, heck in the same root folder and all of them work great, we can print and print preview etc... I gave the coder an example page for this application and after months of waiting he is done but we can not print or print preview the page. I am somewhat of an ASP person, but I have looked over this code and compared it to other code that works fine yet I can not figure this out. I was hoping to post the code here and maybe someone could take a look at it?

Here is the code as well as pasted below. Everything works but when you print all it shows is the graph box.

http://www.miamiconservancy.org/showgraph.zip

Thanks
Jason



<!--#include file="Includes\SQLConnection.asp"-->
<%
response.buffer=true


dim h, w,wname,fd,td,chart


h=request.form("h")
w=request.form("w")
wname=request.form("wname")
fd=request.form("fd")
td=request.form("td")
ChartType=request.form("chart")
P=request.form("P")
dim GCol(4)

GCol(0)=vbred
GCol(1)=vbgreen
GCol(2)=vbcyan
GCol(3)=vbblue
GCol(4)=vbMagenta
'********************************************************************************
'******************************************
checkitem=wname
dim SelectedArr(20) ' to get the IDs of selected reminders

dim i
dim t
dim selcount
selcount=0
i=0
j=0
t=0
scount=0
pos = instr(1,checkitem,",")
if pos > 0 then
do while pos > 0

SelectedArr(scount)=trim(mid(checkitem,1,pos-1))
checkitem=mid(checkitem,pos+1)
scount=scount + 1
pos=InStr(1,checkitem,",")

loop
if checkitem <> "" then
SelectedArr(scount)=trim(checkitem)
end if
else
SelectedArr(scount)=trim(checkitem)

end if

'********************************************************************************
'Response.write scount+1
'Response.end
if scount > 4 then

Response.Write "You can only select 5 wells to geneate the graph. "
Response.end
end if
'test for emply values
if w=0 then
h=300
w=550
end if
if ChartType="" then
ChartType=0
end if
Response.BinaryWrite(RunChart)

Function RunChart()

dim img
dim Chart
dim MyVar

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

'Setup Series
'*
Chart.Walls.Left.Transparent=True
Chart.Walls.Left.Color=vbgreen
Chart.Environment.IEPrintWithPage = True
'Chart appearance
Chart.Legend.Visible=True
Chart.Axis.Bottom.Labels.Angle=(-90)
Chart.Height=h
Chart.Width=w
Chart.Panel.Gradient.Visible=True
Chart.Header.Text(0)=" for Well : " & wname & " from " & fd & " to " & td
Chart.Header.Font.Bold=True
Chart.Header.Font.Height=14

Chart.Axis.Bottom.Title.Caption="Collection Date"
Chart.Axis.Bottom.Title.Font.Bold=True
Chart.Axis.Left.Title.Font.Bold=True

Chart.Aspect.View3D=0

Chart.Panel.Gradient.StartColor= RGB(255,255,255)
Chart.Panel.Gradient.EndColor=RGB(255,255,255)
Chart.Axis.Left.Title.Caption=" Parameter : " &P

' Chart.Axis.Bottom.Increment=Chart.GetDateTimeStep dtOneMonth
' Chart.Axis.Bottom.Increment=Chart.GetDateTimeStep

Set RSt = Server.CreateObject("ADODB.RecordSet")


For I=LBound(SelectedArr) to UBound(SelectedArr)
if SelectedArr(i) <> "" then
'****************************************************************************************************************
'Setup Series
Chart.AddSeries(ChartType)
Chart.Series(i).Marks.Visible=False
Chart.Series(i).Color=GCol(i)
Chart.Series(i).Name=SelectedArr(i)
Chart.Series(i).XValues.DateTime = True
'Chart.Series(i).Color=vbRed

sql="SELECT ("& p &") as min,Wdate, WTIME FROM [WellData] "
sql=SQL&" WHERE wname = '"&SelectedArr(i)&"' and "& p &" <> '' and "& p &" <> '0' and "& p &" is not NULL "
SQL=SQL&" GROUP BY [WDate], [WTIME], "&P&" HAVING [WDate] BETWEEN '" & fd & "' AND '" & td & "'"

'response.write sql
'response.end
RSt.open sql,db,1,1
showLow = 1000

' FINDING THE FIRST DATA AND DATE
if not rst.eof then
' GRAPH STARTS HERE
while not rst.eof
if isnull(rst("min")) or rst("min")="" then min=0 else min=rst("min")
chart.series(i).addxy rst("Wdate"),min,"",GCol(i)
'
rst.movenext
wend
end if
'TESTING RATIOS


'Chart.Axis.Left.AutomaticMinimum = True



'Cleanup and set Chart to send to browser
Rst.close
'Conn.close
end if
next

Set Rst=nothing

'****************************************************************************************************************
'img=Chart.Export.Stream(asPNG)
RunChart=(Chart.Export.asPNG.SaveToStream)

' img=Chart.Export.asPNG.SaveToStream
'''Chart.Export.Stream(stJpeg)
Set Chart=nothing
' RunChart=img
end function


%>

Pep
Site Admin
Site Admin
Posts: 3295
Joined: Fri Nov 14, 2003 5:00 am
Contact:

Post by Pep » Thu Jul 26, 2007 7:53 pm

Hi Jason,

the code seems fine to me. Does the ASP examples included into the TeeChart Pro installation work fine for you ?

Post Reply