D
dropshadow
i am trying to product simple pie charts using OWC11, classic ASP, and
MS SQL server. i have everything working, but the chart that is
produced has an "extra" chart that I don't know where it is comoing
from. please see following code:
<!-- BEGIN //-->
<!--#include file="includes/header.asp" -->
<%
'============================================================================
'============================================================================
'
'function exports data to temp gif file
'
Function ExportChartToGIF(objCSpace, strAbsFilePath, strRelFilePath)
'Get a random filename
Dim strFileName
Randomize
strFileName = Timer & Rnd & ".gif"
'Save the image as a GIF
objCSpace.ExportPicture strAbsFilePath & "\" & strFileName, "gif",
640, 480
'Return the path to the GIF image of the graph
ExportChartToGIF = strRelFilePath & "/" & strFileName
End Function
'============================================================================
'============================================================================
'============================================================================
'============================================================================
'
'routine cleans up temp gif files over 60 minutes old
'
Sub CleanUpGIF(GIFpath)
Dim objFS
Dim objFolder
Dim gif
set objFS = Server.CreateObject("Scripting.FileSystemObject")
set objFolder = objFS.GetFolder(GIFpath)
'Loop through each file in the GIFpath folder
for each gif in objFolder.Files
'Delete GIF files older than 60 minutes
if instr(gif.Name, ".gif") > 0 and _
DateDiff("n", gif.DateLastModified, now) > 60 then
objFS.DeleteFile GIFpath & "\" & gif.Name, True
end if
next
set objFolder = nothing
set objFS = nothing
End Sub
'============================================================================
'============================================================================
'var declaration
Dim strSQL, rst, strConnectionString
Dim objConstants, objFont, objChart, objCSpace, objAxis
Dim objBinaryFile, FSO
strChartAbsPath = Server.MapPath("/ADR/tempChart")
strChartRelPath = "tempChart"
'create the recordset object
set rst = Server.CreateObject("ADODB.Recordset")
'the SQL query
strSQL = "SELECT * FROM test"
'get the data with a client side cursor, and static dataset
rst.open strSQL, conn_string, adOpenStatic, adUseClient
'create the chart object
set objCSpace = Server.CreateObject("OWC11.ChartSpace")
'hide field buttons
objCSpace.DisplayFieldButtons = false
'no idea what this does
objCSpace.DisplayFieldList = false
'set up chart and properties
set objChart = objCSpace.Charts.Add()
set objConstants = objCSpace.Constants
'chart type
objChart.Type = objConstants.chChartTypePie3D
'add legend to chart
objChart.HasLegend = True
'set the data source to the recordset
set objCSpace.DataSource = rst
'set the data points and categories
'objChart.SetData objConstants.chDimSeriesNames, 0, "data2"
objChart.SetData objConstants.chDimCategories, 0, "data1"
objChart.SetData objConstants.chDimValues, 0, "data3"
'set up some additional properties
'add and format the chart title
objChart.HasTitle = True
objChart.Title.Caption = "CHART TITLE HERE"
set objFont = objChart.Title.Font
objFont.Name = "Tahoma"
objFont.Size = 10
objFont.Bold = True
'call chartgen function
strChartFile = ExportChartToGIF(objCSpace, strChartAbsPath,
strChartRelPath)
response.write "<IMG SRC=""" & strChartFile & """>" & "<P>"
'cleanup routine
CleanUpGIF strChartAbsPath
%>
<!--#include file="includes/footer.asp" -->
<!-- END //-->
can anyone help me please!?! i need to get rid of the "extra data"
and then i can just bind to real data from a different table. please
see attached screenshot of actual code running in my dev environment.
MS SQL server. i have everything working, but the chart that is
produced has an "extra" chart that I don't know where it is comoing
from. please see following code:
<!-- BEGIN //-->
<!--#include file="includes/header.asp" -->
<%
'============================================================================
'============================================================================
'
'function exports data to temp gif file
'
Function ExportChartToGIF(objCSpace, strAbsFilePath, strRelFilePath)
'Get a random filename
Dim strFileName
Randomize
strFileName = Timer & Rnd & ".gif"
'Save the image as a GIF
objCSpace.ExportPicture strAbsFilePath & "\" & strFileName, "gif",
640, 480
'Return the path to the GIF image of the graph
ExportChartToGIF = strRelFilePath & "/" & strFileName
End Function
'============================================================================
'============================================================================
'============================================================================
'============================================================================
'
'routine cleans up temp gif files over 60 minutes old
'
Sub CleanUpGIF(GIFpath)
Dim objFS
Dim objFolder
Dim gif
set objFS = Server.CreateObject("Scripting.FileSystemObject")
set objFolder = objFS.GetFolder(GIFpath)
'Loop through each file in the GIFpath folder
for each gif in objFolder.Files
'Delete GIF files older than 60 minutes
if instr(gif.Name, ".gif") > 0 and _
DateDiff("n", gif.DateLastModified, now) > 60 then
objFS.DeleteFile GIFpath & "\" & gif.Name, True
end if
next
set objFolder = nothing
set objFS = nothing
End Sub
'============================================================================
'============================================================================
'var declaration
Dim strSQL, rst, strConnectionString
Dim objConstants, objFont, objChart, objCSpace, objAxis
Dim objBinaryFile, FSO
strChartAbsPath = Server.MapPath("/ADR/tempChart")
strChartRelPath = "tempChart"
'create the recordset object
set rst = Server.CreateObject("ADODB.Recordset")
'the SQL query
strSQL = "SELECT * FROM test"
'get the data with a client side cursor, and static dataset
rst.open strSQL, conn_string, adOpenStatic, adUseClient
'create the chart object
set objCSpace = Server.CreateObject("OWC11.ChartSpace")
'hide field buttons
objCSpace.DisplayFieldButtons = false
'no idea what this does
objCSpace.DisplayFieldList = false
'set up chart and properties
set objChart = objCSpace.Charts.Add()
set objConstants = objCSpace.Constants
'chart type
objChart.Type = objConstants.chChartTypePie3D
'add legend to chart
objChart.HasLegend = True
'set the data source to the recordset
set objCSpace.DataSource = rst
'set the data points and categories
'objChart.SetData objConstants.chDimSeriesNames, 0, "data2"
objChart.SetData objConstants.chDimCategories, 0, "data1"
objChart.SetData objConstants.chDimValues, 0, "data3"
'set up some additional properties
'add and format the chart title
objChart.HasTitle = True
objChart.Title.Caption = "CHART TITLE HERE"
set objFont = objChart.Title.Font
objFont.Name = "Tahoma"
objFont.Size = 10
objFont.Bold = True
'call chartgen function
strChartFile = ExportChartToGIF(objCSpace, strChartAbsPath,
strChartRelPath)
response.write "<IMG SRC=""" & strChartFile & """>" & "<P>"
'cleanup routine
CleanUpGIF strChartAbsPath
%>
<!--#include file="includes/footer.asp" -->
<!-- END //-->
can anyone help me please!?! i need to get rid of the "extra data"
and then i can just bind to real data from a different table. please
see attached screenshot of actual code running in my dev environment.