paulafernandes
02-18-2005, 07:47 PM
Hello!
I have this code to draw a pie chart on my ASP Page:
<object id=ChartSpace1 classid=CLSID:0002E500-0000-0000-C000-000000000046 width="346" height="274"></object>
<script language=vbscript>
Sub Window_OnLoad()
Dim oChart
Dim oSeries1
dim oConst
'Ensure ChartSpace1 is empty:
ChartSpace1.Clear
Set oConst = ChartSpace1.Constants
'Create a new chart in the ChartSpace
Set oChart = ChartSpace1.Charts.Add
'Adiciona as colunas que existem no grafico
Set oSeries1 = oChart.SeriesCollection.Add
With oSeries1
.Caption = "Norte"
.SetData oConst.chDimCategories, oConst.chDataLiteral, Array("Não Respondeu", "Gasóleo", "Gasolina", "Gasolina 95", "Gasolina 98", "Mistura")
.Type = oConst.chChartTypePie
.SetData oConst.chDimValues, oConst.chDataLiteral, Array(22,55,66,99,77,44)
End With
'Add a second value axis to the Chart
'oChart.Axes.Add oChart.Scalings(oConst.chDimValues),
oConst.chAxisPositionRight, oConst.chValueAxis
'Display the legend
oChart.HasLegend = true
oChart.Legend.Position = oConst.chLegendPositionBottom
'Para por o titulo no grafico
oChart.HasTitle = true
oChart.Title.Caption = "Norte"
end sub
</script>
It works fine, including with database records. (A little diferent code...)
My problem is that I need 5 diferent charts on my ASP page, each one of them resulting from an SQL query.
The first one works fine, but when I duplicate the code above the first one desapears and it shows the second. I change the reference "object id=ChartSpace1" to object "id=ChartSpace2" and the references to this name on the VB code. It seems it's not enough.
What am I doing wrong????
Help!
Thank's
Paula
I have this code to draw a pie chart on my ASP Page:
<object id=ChartSpace1 classid=CLSID:0002E500-0000-0000-C000-000000000046 width="346" height="274"></object>
<script language=vbscript>
Sub Window_OnLoad()
Dim oChart
Dim oSeries1
dim oConst
'Ensure ChartSpace1 is empty:
ChartSpace1.Clear
Set oConst = ChartSpace1.Constants
'Create a new chart in the ChartSpace
Set oChart = ChartSpace1.Charts.Add
'Adiciona as colunas que existem no grafico
Set oSeries1 = oChart.SeriesCollection.Add
With oSeries1
.Caption = "Norte"
.SetData oConst.chDimCategories, oConst.chDataLiteral, Array("Não Respondeu", "Gasóleo", "Gasolina", "Gasolina 95", "Gasolina 98", "Mistura")
.Type = oConst.chChartTypePie
.SetData oConst.chDimValues, oConst.chDataLiteral, Array(22,55,66,99,77,44)
End With
'Add a second value axis to the Chart
'oChart.Axes.Add oChart.Scalings(oConst.chDimValues),
oConst.chAxisPositionRight, oConst.chValueAxis
'Display the legend
oChart.HasLegend = true
oChart.Legend.Position = oConst.chLegendPositionBottom
'Para por o titulo no grafico
oChart.HasTitle = true
oChart.Title.Caption = "Norte"
end sub
</script>
It works fine, including with database records. (A little diferent code...)
My problem is that I need 5 diferent charts on my ASP page, each one of them resulting from an SQL query.
The first one works fine, but when I duplicate the code above the first one desapears and it shows the second. I change the reference "object id=ChartSpace1" to object "id=ChartSpace2" and the references to this name on the VB code. It seems it's not enough.
What am I doing wrong????
Help!
Thank's
Paula