Ayuda para graficos ASP

15/06/2005 - 23:12 por espinfire | Informe spam
Hola compañeros
Les mando un cordial saludo y requiero de su apoyo para
resolver una situación que no he podido darle avance ,
resulta que tengo un sistema de indicadores que grafica
los valores de una base de datos que tengo en SQL SERVER.
Realice una prueba cambiando los valores de 0 a NULL en la
DB y ahora las graficas no se muestran, esto debidoa que
en el codigo tengo una división, y NULL/<VALOR> = ERROR.
Les anexo el cóigo para ver quien me puede apoyar a
resolver esta situación, de antemano gracias a todos.
Para desplegar las gráficas tengo instalado el Office Web
Components de XP.
EL VALOR DE G_DIVISOR0 si encuentra el dato % o 1 en
cualqueir otro caso.

<object id=ChartSpace2 classid=CLSID:0002E556-0000-0000-
C000-000000000046 style="width:654;height:450"></object>
<script language=vbs>
Sub ativa_Chart2()
<!--#Include File="Colores.asp"-->
Dim rs2, categories2, Total_Atual(12), Bud_Atual
(12),Ant_mes(12), c2, IND, i, xmes

LANG = "<%=LANG%>"
<%
Rs1.Source = "SELECT * FROM <TABLA> where CAMPO1='" & IND
& "' and CAMPO2='" & INDP & "' "
Rs1.CursorType = 0
Rs1.CursorLocation = 2
Rs1.LockType = 1
Rs1.Open()
%>
Select Case LANG
Case "por" Categories2 = "JAN" & chr(9) & "FEV" & chr(9)
& "MAR" & chr(9)& "ABR" & chr(9) & "MAI" & chr(9) & "JUN"
Categories2 = Categories2 & chr(9) & "JUL" & chr(9)
& "AGO" & chr(9) & "SET" & chr(9) & "OUT" & chr(9) & "NOV"
& chr(9) & "DEZ"
Case "esp" Categories2 = "ENE" & chr(9) & "FEB" & chr(9)
& "MAR" & chr(9)& "APR" & chr(9) & "MAY" & chr(9) & "JUN"
Categories2 = Categories2 & chr(9) & "JUL" & chr(9)
& "AUG" & chr(9) & "SEP" & chr(9) & "OCT" & chr(9) & "NOV"
& chr(9) & "DEC"
Case "eng" Categories2 = "JAN" & chr(9) & "FEB" & chr(9)
& "MAR" & chr(9)& "APR" & chr(9) & "MAY" & chr(9) & "JUN"
Categories2 = Categories2 & chr(9) & "JUL" & chr(9)
& "AUG" & chr(9) & "SEP" & chr(9) & "OCT" & chr(9) & "NOV"
& chr(9) & "DEC"

Case Else MsgBox "pick another Language"
End Select

<%for i = 1 to G_mes
xmes=right("0" & i,2)%>
Total_Atual(<%=i-1%>) = Replace("<%=cdbl(rs1.Fields
("Total_Atual_Mes_" & xmes).value)/G_DIVISOR%>",",",".")
<%next%>
<%for i = 1 to 12
xmes=right("0" & i,2)%>
Bud_Atual(<%=i-1%>) = Replace("<%=cdbl(rs1.Fields
("Bud_Atual_Mes_" & xmes).value)/G_DIVISOR%>",",",".")
<%next%>
<%for i = 1 to 12
xmes=right("0" & i,2)%>
Ant_mes(<%=i-1%>) = Replace("<%=cdbl(rs1.Fields("Ant_Mes_"
& xmes).value)/G_DIVISOR%>",",",".")
<%next%>
<%rs1.Close%>

' Create a chart with one series (called "Sales").
ChartSpace2.Clear
Set c2 = ChartSpace2.Constants

ChartSpace2.Charts.Add
ChartSpace2.Charts(0).HasTitle = True
'ChartSpace2.Charts(0).HasLegend = True
ChartSpace2.Charts(0).Border.color="white"

ChartSpace2.Charts(0).PlotArea.interior.color =
(c_Chart2_PlotArea)
ChartSpace2.Charts(0).interior.color = (c_Chart2_bg)
select case LANG
case "esp" ChartSpace2.Charts(0).Title.Caption = "Budget /
Real"
case "eng" ChartSpace2.Charts(0).Title.Caption = "Budget /
Actual"
case "por" ChartSpace2.Charts(0).Title.Caption = "Budget /
Real"
End Select

ChartSpace2.Charts(0).Title.Font.Bold = True
ChartSpace2.Charts(0).Title.Font.Name = "Tahoma"
ChartSpace2.Charts(0).Title.Font.Size = 12
ChartSpace2.Charts(0).SeriesCollection.Add
ChartSpace2.Charts(0).SeriesCollection.Add
ChartSpace2.Charts(0).SeriesCollection.Add

ChartSpace2.Charts(0).SeriesCollection(0).Caption = "<%
=G_ANO_ATUAL%>"
ChartSpace2.Charts(0).SeriesCollection(1).Caption = "<%
=G_ANO_ATUAL-1%>"
ChartSpace2.Charts(0).SeriesCollection(2).Caption
= "Budget"
ChartSpace2.Charts(0).Type = 0

ChartSpace2.Charts(0).SeriesCollection(0).line.color
= "green"
ChartSpace2.Charts(0).SeriesCollection(0).Marker.Style = 2
ChartSpace2.Charts(0).SeriesCollection(0).Interior.Color =
(c_Ano_atu)


ChartSpace2.Charts(0).SeriesCollection(1).line.color
= "red"
ChartSpace2.Charts(0).SeriesCollection(1).Marker.Style = 8
ChartSpace2.Charts(0).SeriesCollection(1).Interior.Color =
(c_ano_ant)

ChartSpace2.Charts(0).SeriesCollection(2).Interior.Color =
(c_budget)
ChartSpace2.Charts(0).SeriesCollection(2).line.color =
(c_budget)
ChartSpace2.Charts(0).SeriesCollection(2).Marker.Style = 3

' ChartSpace2.Charts(0).SeriesCollection(0).type = <%
=request.querystring("type")%>
ChartSpace2.Charts(0).SeriesCollection(2).type =
c2.chChartTypeLineMarkers
'Set the series categories and values using the strings
created from the recordset.
ChartSpace2.Charts(0).SeriesCollection(0).SetData
c2.chDimCategories, c2.chDataLiteral, categories2
ChartSpace2.Charts(0).SeriesCollection(0).SetData
c2.chDimValues, c2.chDataLiteral, Total_Atual

ChartSpace2.Charts(0).SeriesCollection(1).SetData
c2.chDimCategories, c2.chDataLiteral, categories2
ChartSpace2.Charts(0).SeriesCollection(1).SetData
c2.chDimValues, c2.chDataLiteral, Ant_Mes

ChartSpace2.Charts(0).SeriesCollection(2).SetData
c2.chDimCategories, c2.chDataLiteral, categories2
ChartSpace2.Charts(0).SeriesCollection(2).SetData
c2.chDimValues, c2.chDataLiteral, Bud_Atual

' Set the chart type and format the axis
'ChartSpace2.Charts(0).Axes
(c2.chAxisPositionLeft).Hastitle = true
'ChartSpace2.Charts(0).Axes
(c2.chAxisPositionLeft).title.Font = "Tahoma"
'ChartSpace2.Charts(0).Axes
(c2.chAxisPositionLeft).title.font.Size = 8
'ChartSpace2.Charts(0).Axes
(c2.chAxisPositionLeft).title.font.Bold = True
'ChartSpace2.Charts(0).Axes
(c2.chAxisPositionLeft).title.caption = "<%=UNIDADE%>"

<%If UNIDADE="%" then %>
ChartSpace2.Charts(0).Axes
(c2.chAxisPositionLeft).NumberFormat = "0.0%"
<%else%>
ChartSpace2.Charts(0).Axes
(c2.chAxisPositionLeft).NumberFormat = "#,##0"
<% end if%>

'ChartSpace2.Charts(0).Legend.Position = 2

End Sub
</script>
 

Leer las respuestas

#1 Nuno Santos
16/06/2005 - 10:03 | Informe spam
Por que no verificas primero si el valor no es null y después haces la
división, o entonces en el select que trae los datos hace el cambio del NULL
por zero:

SELECT ISNULL(Campo1,0) as Campo1, ISNULL(Campo2,0) as Campo2 FROM Table1


Nuno Santos



Nuno Santos
nunos7[REMOVER]@hotmail.com

"espinfire" wrote in message
news:0c8401c571ee$f231c3f0$
Hola compañeros
Les mando un cordial saludo y requiero de su apoyo para
resolver una situación que no he podido darle avance ,
resulta que tengo un sistema de indicadores que grafica
los valores de una base de datos que tengo en SQL SERVER.
Realice una prueba cambiando los valores de 0 a NULL en la
DB y ahora las graficas no se muestran, esto debidoa que
en el codigo tengo una división, y NULL/<VALOR> = ERROR.
Les anexo el cóigo para ver quien me puede apoyar a
resolver esta situación, de antemano gracias a todos.
Para desplegar las gráficas tengo instalado el Office Web
Components de XP.
EL VALOR DE G_DIVISOR0 si encuentra el dato % o 1 en
cualqueir otro caso.

<object id=ChartSpace2 classid=CLSID:0002E556-0000-0000-
C000-000000000046 style="width:654;height:450"></object>
<script language=vbs>
Sub ativa_Chart2()
<!--#Include File="Colores.asp"-->
Dim rs2, categories2, Total_Atual(12), Bud_Atual
(12),Ant_mes(12), c2, IND, i, xmes

LANG = "<%=LANG%>"
<%
Rs1.Source = "SELECT * FROM <TABLA> where CAMPO1='" & IND
& "' and CAMPO2='" & INDP & "' "
Rs1.CursorType = 0
Rs1.CursorLocation = 2
Rs1.LockType = 1
Rs1.Open()
%>
Select Case LANG
Case "por" Categories2 = "JAN" & chr(9) & "FEV" & chr(9)
& "MAR" & chr(9)& "ABR" & chr(9) & "MAI" & chr(9) & "JUN"
Categories2 = Categories2 & chr(9) & "JUL" & chr(9)
& "AGO" & chr(9) & "SET" & chr(9) & "OUT" & chr(9) & "NOV"
& chr(9) & "DEZ"
Case "esp" Categories2 = "ENE" & chr(9) & "FEB" & chr(9)
& "MAR" & chr(9)& "APR" & chr(9) & "MAY" & chr(9) & "JUN"
Categories2 = Categories2 & chr(9) & "JUL" & chr(9)
& "AUG" & chr(9) & "SEP" & chr(9) & "OCT" & chr(9) & "NOV"
& chr(9) & "DEC"
Case "eng" Categories2 = "JAN" & chr(9) & "FEB" & chr(9)
& "MAR" & chr(9)& "APR" & chr(9) & "MAY" & chr(9) & "JUN"
Categories2 = Categories2 & chr(9) & "JUL" & chr(9)
& "AUG" & chr(9) & "SEP" & chr(9) & "OCT" & chr(9) & "NOV"
& chr(9) & "DEC"

Case Else MsgBox "pick another Language"
End Select

<%for i = 1 to G_mes
xmes=right("0" & i,2)%>
Total_Atual(<%=i-1%>) = Replace("<%=cdbl(rs1.Fields
("Total_Atual_Mes_" & xmes).value)/G_DIVISOR%>",",",".")
<%next%>
<%for i = 1 to 12
xmes=right("0" & i,2)%>
Bud_Atual(<%=i-1%>) = Replace("<%=cdbl(rs1.Fields
("Bud_Atual_Mes_" & xmes).value)/G_DIVISOR%>",",",".")
<%next%>
<%for i = 1 to 12
xmes=right("0" & i,2)%>
Ant_mes(<%=i-1%>) = Replace("<%=cdbl(rs1.Fields("Ant_Mes_"
& xmes).value)/G_DIVISOR%>",",",".")
<%next%>
<%rs1.Close%>

' Create a chart with one series (called "Sales").
ChartSpace2.Clear
Set c2 = ChartSpace2.Constants

ChartSpace2.Charts.Add
ChartSpace2.Charts(0).HasTitle = True
'ChartSpace2.Charts(0).HasLegend = True
ChartSpace2.Charts(0).Border.color="white"

ChartSpace2.Charts(0).PlotArea.interior.color (c_Chart2_PlotArea)
ChartSpace2.Charts(0).interior.color = (c_Chart2_bg)
select case LANG
case "esp" ChartSpace2.Charts(0).Title.Caption = "Budget /
Real"
case "eng" ChartSpace2.Charts(0).Title.Caption = "Budget /
Actual"
case "por" ChartSpace2.Charts(0).Title.Caption = "Budget /
Real"
End Select

ChartSpace2.Charts(0).Title.Font.Bold = True
ChartSpace2.Charts(0).Title.Font.Name = "Tahoma"
ChartSpace2.Charts(0).Title.Font.Size = 12
ChartSpace2.Charts(0).SeriesCollection.Add
ChartSpace2.Charts(0).SeriesCollection.Add
ChartSpace2.Charts(0).SeriesCollection.Add

ChartSpace2.Charts(0).SeriesCollection(0).Caption = "<%
=G_ANO_ATUAL%>"
ChartSpace2.Charts(0).SeriesCollection(1).Caption = "<%
=G_ANO_ATUAL-1%>"
ChartSpace2.Charts(0).SeriesCollection(2).Caption
= "Budget"
ChartSpace2.Charts(0).Type = 0

ChartSpace2.Charts(0).SeriesCollection(0).line.color
= "green"
ChartSpace2.Charts(0).SeriesCollection(0).Marker.Style = 2
ChartSpace2.Charts(0).SeriesCollection(0).Interior.Color (c_Ano_atu)


ChartSpace2.Charts(0).SeriesCollection(1).line.color
= "red"
ChartSpace2.Charts(0).SeriesCollection(1).Marker.Style = 8
ChartSpace2.Charts(0).SeriesCollection(1).Interior.Color (c_ano_ant)

ChartSpace2.Charts(0).SeriesCollection(2).Interior.Color (c_budget)
ChartSpace2.Charts(0).SeriesCollection(2).line.color (c_budget)
ChartSpace2.Charts(0).SeriesCollection(2).Marker.Style = 3

' ChartSpace2.Charts(0).SeriesCollection(0).type = <%
=request.querystring("type")%>
ChartSpace2.Charts(0).SeriesCollection(2).type c2.chChartTypeLineMarkers
'Set the series categories and values using the strings
created from the recordset.
ChartSpace2.Charts(0).SeriesCollection(0).SetData
c2.chDimCategories, c2.chDataLiteral, categories2
ChartSpace2.Charts(0).SeriesCollection(0).SetData
c2.chDimValues, c2.chDataLiteral, Total_Atual

ChartSpace2.Charts(0).SeriesCollection(1).SetData
c2.chDimCategories, c2.chDataLiteral, categories2
ChartSpace2.Charts(0).SeriesCollection(1).SetData
c2.chDimValues, c2.chDataLiteral, Ant_Mes

ChartSpace2.Charts(0).SeriesCollection(2).SetData
c2.chDimCategories, c2.chDataLiteral, categories2
ChartSpace2.Charts(0).SeriesCollection(2).SetData
c2.chDimValues, c2.chDataLiteral, Bud_Atual

' Set the chart type and format the axis
'ChartSpace2.Charts(0).Axes
(c2.chAxisPositionLeft).Hastitle = true
'ChartSpace2.Charts(0).Axes
(c2.chAxisPositionLeft).title.Font = "Tahoma"
'ChartSpace2.Charts(0).Axes
(c2.chAxisPositionLeft).title.font.Size = 8
'ChartSpace2.Charts(0).Axes
(c2.chAxisPositionLeft).title.font.Bold = True
'ChartSpace2.Charts(0).Axes
(c2.chAxisPositionLeft).title.caption = "<%=UNIDADE%>"

<%If UNIDADE="%" then %>
ChartSpace2.Charts(0).Axes
(c2.chAxisPositionLeft).NumberFormat = "0.0%"
<%else%>
ChartSpace2.Charts(0).Axes
(c2.chAxisPositionLeft).NumberFormat = "#,##0"
<% end if%>

'ChartSpace2.Charts(0).Legend.Position = 2

End Sub
</script>

Preguntas similares