Home > ASP Development > OWC Chart - No Image

OWC Chart - No Image



I have this OWC Chart, its the first time

I am using it, so I will post all the code, sorry.


Code:



<%
Option Explicit
Response.ContentType = "image/gif"
%>

<%

'declare our variables
Dim strSQL, rst, conn
Dim objConstants, objFont, objChart, objCSpace, objAxis
Dim objBinaryFile, FSO

'the connection string
set conn=Server.CreateObject("ADODB.Connection")

conn.Open "connectionstring"

'create the recordset object
set rst = Server.CreateObject("ADODB.Recordset")

%>

<%

'the SQL query
strSQL = "SELECT Trade_Volume AS Trade, Trade_Price as Price, Trade_Trader as Trader FROM OTC_Trade"

'get the data with a client side cursor, and static dataset
rst.open strSQL, conn, 3, 3

'Now create the chart object
set objCSpace = Server.CreateObject("OWC10.Chartspace")

%>

<%

'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 = rst

'set the data points and categories
objChart.SetData objConstants.chDimSeriesNames, 0, "Trade"
objChart.SetData objConstants.chDimCategories, 0, "Price"
objChart.SetData objConstants.chDimValues, 0, "Trader"

'set up some additional properties
'add and format the chart title
objChart.HasTitle = True
objChart.Title.Caption = "Sales by Products"
set objFont = objChart.Title.Font
objFont.Name = "Tahoma"
objFont.Size = 10
objFont.Bold = True

'add and format a title to the category axis
set objAxis = objChart.Axes(objConstants.chAxisPositionBottom)
objAxis.HasTitle = True
objAxis.Title.Caption = "Price"
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 = objChart.Axes(objConstants.chAxisPositionLeft)
objAxis.NumberFormat = "Currency"
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
Dim strFileName
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

%>




its not giving an error, but I only see a red cross

instead of the chart, any ideas?

the source code said I must use OWC.Chart, but that

didn't work so I changed it do OWC10.Chartspace.



Any ideas on this?



Thanx in advance

Jako

    
Guest


you probably do get error - so remove the Response.ContentType = "image/gif"

and you will see it.

Was this answer helpful ? Yes No   
Guest
 
 
Home - About Infoqu - Contact - Privacy Statement - Link to Infoqu - Bookmark Infoqu

Copyright 2007-2008 by Infoqu. All rights reserved