Hi everyone,
I hope someone will be able to help.... i am using ASP technology (incorperating a
VB DLL as a middle tier) and I want to use office xp web components to generate dynamic graphs.. i have downloaded the owc toolpack too but nothing seems to work for me.... i have tried several differnt ways of coding this but with no success.
Basically..... I am returning a recordset with 2 variables "program" and "number".... I want to chart each "number" for each "program"... Below id the cde I have implemented.. (I have also registered the required DLLs)
Many Thanks. Kkathryne
Code:
<%@ Language=VBScript %>
<html>
<head>
<title>Create Report</title>
</head>
<body>
<%
dim strUserID
dim strTime
dim strProgram
dim strSeverity
dim strStatus
dim objProj
dim adoRS
Dim objConstants, objFont, objChart, objCSpace, objAxis
Dim objBinaryFile, FSO
strUserID = Request.Form("txtUserID")
strTime = Request.form("txtTime")
strProgram = Request.form("txtProgram")
strSeverity = Request.form("txtSeverity")
strStatus = Request.form("txtStatus")
%>
<table id=TblTitle width="100%" >
<tr height="63" style="HEIGHT: 63px">
<td width="100" style="WIDTH: 100px"><img src="file:///D|/Inetpub/wwwroot/defect/images/logo.bmp" width="70" height="51"
style="WIDTH: 86px; HEIGHT: 84px">
</td>
<td>
<h1 align="center">Create Report</h1>
<td>
<td width="100" style="WIDTH: 100px"><h6 align="center">Nissan
</h6><h6 align="center">Defect
Tracking System
</h6></td>
</tr>
</table>
<P>
</P>
<P> </P>
<P> </P>
<P> </P>
<%
'Get Data for graph
set objProject1 = Server.CreateObject("Project1.Class1")
set adoRS = objProject1.MakeChart()
set objProject1 = nothing
Response.ContentType = "image/gif"
'create the chart object
set objCSpace = Server.CreateObject("OWC.Chart")
'set up chart and properties
set objChart = objCSpace.Charts.Add()
set objConstants = objCSpace.Constants
'create a clustered column chart
objChart.Type = objConstants.chChartTypeColumnClustered
'add a legend
objChart.HasLegend = True
'set the data source to the recordset
set objCSpace.DataSource = adoRS
'set the data points and categories
objChart.SetData objConstants.chDimCategories, 0, "Programs"
objChart.SetData objConstants.chDimValues, 0, "Defects"
'set up some additional properties
'add and format the chart title
objChart.HasTitle = True
objChart.Title.Caption = "Number of Defects outstanding by Program"
set objFont = objChart.Title.Font
objFont.Name = "Tahoma"
objFont.Size = 12
objFont.Bold = True
'add and format a title to the category axis
set objAxis = objChart.Axes(objConstants.chAxisPositionBottom)
objAxis.HasTitle = True
objAxis.Title.Caption = "Programs"
set objFont = objAxis.Title.Font
objFont.Name = "Tahoma"
objFont.Size = 8
objFont.Bold = True
'add and format a title to the value axis
'set objAxis = cht.Axes(objConstants.chAxisPositionLeft)
'objAxis.NumberFormat = "Number"
'objAxis.HasTitle = True
'objAxis.Title.Caption = "Dollars"
'set objFont = objAxis.Title.Font
'objFont.Name = "Tahoma"
'objFont.Size = 8
'objFont.Bold = True
'Save the current chart to a GIF file with a temporary
'filename using the FSO
set fso = Server.CreateObject("Scripting.FileSystemObject")
strFileName = Server.MapPath(".") & "\" & fso.GetTempName()
objCSpace.ExportPicture strFileName, "gif", 800, 400
'Use On Error Resume Next to make sure we eventually delete
'the temporary GIF file even if something fails in the next
'couple of functions
on error resume next
'The GIF file has been created. Return the contents of the
'GIF file as binary data using the BinaryFileStream COM object
set objBinaryFile = Server.CreateObject("BinaryFileStream.Object")
Response.BinaryWrite objBinaryFile.GetFileBytes(CStr(strFileName))
'Delete the GIF file since it is no longer needed
objBinaryFile.DeleteFile CStr(sFullFileName)
'clear variables
set objBinaryFile = nothing
set FSO = nothing
set objCSpace = nothing
%>
<P> </P>
<P> </P>
<P> </P>
<table id=TblBottomBanner width="100%" bgcolor=lightgrey>
<tr height="63" style="HEIGHT: 63px">
<td>
<P align=center><STRONG>   ; All rights
registered 2004 Nissan Europe</STRONG></P>
<td width="80" style="WIDTH: 80px">
<button id="cmdDoBack" style="WIDTH: 80px" class="StdButton" onclick="DoBack();">Back
</button>
</td>
</tr>
</table>
<form id="frmMain" name="frmMain" method="post">
<input id="txtUserID" name="txtUserID" type=hidden value="<%=strUserID%>">
</form>
</body>
<script language=javascript>
//------------------------------------------------------------------------------
// DoBack()
// ~~~~~~~~~~~~~~~
//------------------------------------------------------------------------------
function DoBack()
{
Navigate(frmMain, "MainMenu.asp");
}
</script>
</html>