Clarkie001
IS-IT--Management
Hi,
I am looking for some help regarding the code below. In the first snippet, I am creating an XML file based on a database recordset. This works great.
but!
On the second snippet I am trying to create a OWC graph based on the newly created XML file.
It works fine on the first selection, but on any subsequent selection the refresh rate is poor and it doesn't always pick up the new xml file even though it is created.
Any advice would be greatly appreciated.
Thanks
Clarkie
1st Snippet of code
dim xmlDoc, root1, p,child1, child2, child3, x
set xmlDoc = server.createobject("Microsoft.XMLDOM")
set root1 = xmlDoc.createElement("Scenario")
xmlDoc.appendchild root1
for each x in rs.fields
set child1 = xmlDoc.createElement("Name")
set child2 = xmlDoc.createElement("Value")
set child3 = xmlDoc.createElement("Year")
child1.text=mySelection
child2.text=cdbl(x.value)
child3.text=x.name
root1.appendchild child1
child1.appendchild child2
child1.appendchild child3
next
set p = xmlDoc.CreateProcessingInstruction("xml","version='1.0'")
xmlDoc.insertbefore p,xmlDoc.childnodes(0)
xmlDoc.Save server.mappath("myxmls/usrscenario.xml")
rs.close
conn.close
set rs = nothing
set conn = nothing
Dim adoRS 'ADODB.Recordset
Set adoRS = CreateObject("ADODB.Recordset")
'Database objects
dim oRs
' Set up the Connection
adoRS.ActiveConnection = "Provider=MSDAOSP; Data Source=MSXML2.DSOControl.2.6;"
' Open the XML source
adoRS.Open Server.MapPath(".") & "\myXMLs\usrscenario.xml"
2nd snippet of code
Dim strChartAbsPath
Dim strChartRelPath
Dim objChartSpace
Dim objChart
Dim c
Dim objSeries
Dim objAxis
Dim objFont
Dim strChartFile
'Get the relative and absolute path names for the GIF folder
strChartAbsPath = Server.MapPath("/charts")
strChartRelPath = "charts"
'Create ChartSpace
Set objChartSpace = Server.CreateObject("OWC.Chart")
'Create Chart
Set objChart = objChartSpace.Charts.Add()
'Create Constants Object
Set c = objChartSpace.Constants
'Set the datasource (SQL Server Database recordset)
Set objChartSpace.Datasource = adors
'Chart Properties
With objChart
'title (header)
.HasTitle = True
.Title.Caption = mySelection
.Title.Font.Bold = True
.plotArea.Interior.color= "white"
.border.color = "white"
.interior.color= "white"
.Title.Position = c.chTitlePositionTop
'legend (footer)
.HasLegend = False
'.Legend.Position = c.chLegendPositionright
'.legend.border.color = "white"
'.legend.interior.color = "white"
End With
'*************************************************
'SERIES
'*************************************************
'Create Series 1
Set objSeries = objChart.SeriesCollection.Add()
'Series 1 Properties
With objSeries
'methods
.SetData c.chDimCategories, 0, "Year"
.SetData c.chDimValues, 0, "Value"
'line
.Caption= none
.Type = c.chChartTypeLineMarkers
.Line.Color = "Black"
.Marker.Style = c.chMarkerStyleSquare
.Interior.Color = "Blue"
End With
'*************************************************
'AXIS
'*************************************************
'Create Horizontal Axis
Set objAxis = objChart.Axes(c.chAxisPositionBottom)
'Axis Properties
With objAxis
.HasTitle = True
.Title.Caption = "Year"
.TickMarkSpacing = 1
.Scaling.Orientation = c.chScaleOrientationMinMax
.Font.Size = 7
.TickLabelSpacing = 1
End With
'Create Font (Horizontal Axis)
Set objFont = objAxis.Title.Font
'Font Properties
With objFont
.Name = "Helvetica"
.Size = 12
.Bold = True
End With
'Create Vertical Axis
Set objAxis = objChart.Axes(c.chAxisPositionLeft)
'Axis Properties
With objAxis
.NumberFormat = "£#,###"
.HasTitle = True
.Title.Caption = "£bn"
.Font.Size = 8
End With
'Create Font (Horizontal Axis)
Set objFont = objAxis.Title.Font
'Font Properties
With objFont
.Name = "Helvetica"
.Size = 12
.Bold = True
End With
set fso = server.createobject("Scripting.FileSystemObject")
strfilename = server.mappath( "Charts\usrscenario.gif")
if fso.fileexists(strfilename) then
fso.deletefile(strfilename)
end if
objChartSpace.exportpicture strfilename, "gif", 780, 350
strfilename = right(strfilename,len(strfilename)-24)
response.write("<img style='position:absolute;left:-20' src='charts/usrscenario.gif'/>")
'Clean up objects
Set objChartSpace = Nothing
Set objChart = Nothing
Set c = Nothing
Set objSeries = Nothing
Set objAxis = Nothing
Set objFont = Nothing
adors.close
set adors = nothing
I am looking for some help regarding the code below. In the first snippet, I am creating an XML file based on a database recordset. This works great.
but!
On the second snippet I am trying to create a OWC graph based on the newly created XML file.
It works fine on the first selection, but on any subsequent selection the refresh rate is poor and it doesn't always pick up the new xml file even though it is created.
Any advice would be greatly appreciated.
Thanks
Clarkie
1st Snippet of code
dim xmlDoc, root1, p,child1, child2, child3, x
set xmlDoc = server.createobject("Microsoft.XMLDOM")
set root1 = xmlDoc.createElement("Scenario")
xmlDoc.appendchild root1
for each x in rs.fields
set child1 = xmlDoc.createElement("Name")
set child2 = xmlDoc.createElement("Value")
set child3 = xmlDoc.createElement("Year")
child1.text=mySelection
child2.text=cdbl(x.value)
child3.text=x.name
root1.appendchild child1
child1.appendchild child2
child1.appendchild child3
next
set p = xmlDoc.CreateProcessingInstruction("xml","version='1.0'")
xmlDoc.insertbefore p,xmlDoc.childnodes(0)
xmlDoc.Save server.mappath("myxmls/usrscenario.xml")
rs.close
conn.close
set rs = nothing
set conn = nothing
Dim adoRS 'ADODB.Recordset
Set adoRS = CreateObject("ADODB.Recordset")
'Database objects
dim oRs
' Set up the Connection
adoRS.ActiveConnection = "Provider=MSDAOSP; Data Source=MSXML2.DSOControl.2.6;"
' Open the XML source
adoRS.Open Server.MapPath(".") & "\myXMLs\usrscenario.xml"
2nd snippet of code
Dim strChartAbsPath
Dim strChartRelPath
Dim objChartSpace
Dim objChart
Dim c
Dim objSeries
Dim objAxis
Dim objFont
Dim strChartFile
'Get the relative and absolute path names for the GIF folder
strChartAbsPath = Server.MapPath("/charts")
strChartRelPath = "charts"
'Create ChartSpace
Set objChartSpace = Server.CreateObject("OWC.Chart")
'Create Chart
Set objChart = objChartSpace.Charts.Add()
'Create Constants Object
Set c = objChartSpace.Constants
'Set the datasource (SQL Server Database recordset)
Set objChartSpace.Datasource = adors
'Chart Properties
With objChart
'title (header)
.HasTitle = True
.Title.Caption = mySelection
.Title.Font.Bold = True
.plotArea.Interior.color= "white"
.border.color = "white"
.interior.color= "white"
.Title.Position = c.chTitlePositionTop
'legend (footer)
.HasLegend = False
'.Legend.Position = c.chLegendPositionright
'.legend.border.color = "white"
'.legend.interior.color = "white"
End With
'*************************************************
'SERIES
'*************************************************
'Create Series 1
Set objSeries = objChart.SeriesCollection.Add()
'Series 1 Properties
With objSeries
'methods
.SetData c.chDimCategories, 0, "Year"
.SetData c.chDimValues, 0, "Value"
'line
.Caption= none
.Type = c.chChartTypeLineMarkers
.Line.Color = "Black"
.Marker.Style = c.chMarkerStyleSquare
.Interior.Color = "Blue"
End With
'*************************************************
'AXIS
'*************************************************
'Create Horizontal Axis
Set objAxis = objChart.Axes(c.chAxisPositionBottom)
'Axis Properties
With objAxis
.HasTitle = True
.Title.Caption = "Year"
.TickMarkSpacing = 1
.Scaling.Orientation = c.chScaleOrientationMinMax
.Font.Size = 7
.TickLabelSpacing = 1
End With
'Create Font (Horizontal Axis)
Set objFont = objAxis.Title.Font
'Font Properties
With objFont
.Name = "Helvetica"
.Size = 12
.Bold = True
End With
'Create Vertical Axis
Set objAxis = objChart.Axes(c.chAxisPositionLeft)
'Axis Properties
With objAxis
.NumberFormat = "£#,###"
.HasTitle = True
.Title.Caption = "£bn"
.Font.Size = 8
End With
'Create Font (Horizontal Axis)
Set objFont = objAxis.Title.Font
'Font Properties
With objFont
.Name = "Helvetica"
.Size = 12
.Bold = True
End With
set fso = server.createobject("Scripting.FileSystemObject")
strfilename = server.mappath( "Charts\usrscenario.gif")
if fso.fileexists(strfilename) then
fso.deletefile(strfilename)
end if
objChartSpace.exportpicture strfilename, "gif", 780, 350
strfilename = right(strfilename,len(strfilename)-24)
response.write("<img style='position:absolute;left:-20' src='charts/usrscenario.gif'/>")
'Clean up objects
Set objChartSpace = Nothing
Set objChart = Nothing
Set c = Nothing
Set objSeries = Nothing
Set objAxis = Nothing
Set objFont = Nothing
adors.close
set adors = nothing