Foros del Web » Programando para Internet » ASP Clásico »

Generar Array

Estas en el tema de Generar Array en el foro de ASP Clásico en Foros del Web. Hola a todos, tengo un problemilla, estoy creando un arreglo de la manera mas facil pero no me funciona al momento de graficar, entonces quiero ...
  #1 (permalink)  
Antiguo 26/12/2006, 09:55
Avatar de dobled  
Fecha de Ingreso: enero-2002
Ubicación: Rancagua - Chile
Mensajes: 1.328
Antigüedad: 22 años, 4 meses
Puntos: 2
Generar Array

Hola a todos, tengo un problemilla, estoy creando un arreglo de la manera mas facil pero no me funciona al momento de graficar, entonces quiero ver otra alternativa o metodo pero que me entregue el mismo resultado.

de esta manera array(9, 8, 45, 4, 21, 54, 6)
en estos momento lo gerero asi

Código:
'me conecto y despues
do while not dataChartb.Eof
If arrB = "" Then
arrB = dataChartb("numxarea")
else
arrB = arrB &", "& dataChartb("numxarea")
end If
dataChartb.movenext
loop
Cierra(dataChartb)
response.write arrB
será el problema por que lo deja como string?

Saludos.
__________________
Usa títulos específicos y con sentido
En las listas de correo o en los grupos de noticias, la cabecera del mensaje es tu oportunidad de oro para atraer la atención de expertos cualificados en aproximadamente 50 caracteres o menos. No los desperdicies en balbuceos como "Por favor ayúdame" (de "POR FAVOR AYÚDAME!!!" ya ni hablamos). No intentes impresionarnos con lo profundo de tu angustia; mejor usa ese preciado espacio para una descripción lo más concisa posible del problema.
  #2 (permalink)  
Antiguo 26/12/2006, 10:15
Avatar de Myakire
Colaborador
 
Fecha de Ingreso: enero-2002
Ubicación: Centro de la república
Mensajes: 8.849
Antigüedad: 22 años, 4 meses
Puntos: 146
Re: Generar Array

a ver ....

Código:
 arrB = "" 
While not dataChartb.Eof
   arrB = arrB & dataChartb("numxarea") & ", " 
   dataChartb.movenext
Wend
arrB = MID(arrB, 1, LEN(arrB)-2)
Cierra(dataChartb)
response.write arrB
  #3 (permalink)  
Antiguo 26/12/2006, 10:20
Avatar de dobled  
Fecha de Ingreso: enero-2002
Ubicación: Rancagua - Chile
Mensajes: 1.328
Antigüedad: 22 años, 4 meses
Puntos: 2
Re: Generar Array

Myakire igual me aparece el error lo mas raro es que si pongo los datos a mano me funciona
este es el error
No coinciden los tipos: '[string: "1, 1, 14, 5, 1, 3, 1"]'
__________________
Usa títulos específicos y con sentido
En las listas de correo o en los grupos de noticias, la cabecera del mensaje es tu oportunidad de oro para atraer la atención de expertos cualificados en aproximadamente 50 caracteres o menos. No los desperdicies en balbuceos como "Por favor ayúdame" (de "POR FAVOR AYÚDAME!!!" ya ni hablamos). No intentes impresionarnos con lo profundo de tu angustia; mejor usa ese preciado espacio para una descripción lo más concisa posible del problema.
  #4 (permalink)  
Antiguo 26/12/2006, 10:36
Avatar de Myakire
Colaborador
 
Fecha de Ingreso: enero-2002
Ubicación: Centro de la república
Mensajes: 8.849
Antigüedad: 22 años, 4 meses
Puntos: 146
Re: Generar Array

Pero, ¿dónde te marca error, en qué linea?

¿en la concatenación?, arrB = arrB & CStr(dataChartb("numxarea")) & ", "
  #5 (permalink)  
Antiguo 26/12/2006, 10:59
Avatar de dobled  
Fecha de Ingreso: enero-2002
Ubicación: Rancagua - Chile
Mensajes: 1.328
Antigüedad: 22 años, 4 meses
Puntos: 2
Re: Generar Array

mejor te posteo el codigo que tengo:
aqui el error primero
Error de Microsoft VBScript en tiempo de ejecución error '800a000d'

No coinciden los tipos: '[string: "1, 1, 14, 5, 1, 3, 1"]'

/graficos/default.asp, line 107

Código:
<!--#include file="conexion_inc.asp" -->
<%
	conexion = ConectarSQL()
	Set  dataChart = Query("SELECT * FROM vista_feedback_graf_area ORDER By subarea", conexion)
	
	do while not dataChart.Eof
	If arrA = "" Then
	arrA = CHR(34) & dataChart("subarea") & CHR(34)
	else
	arrA = arrA &", "&CHR(34) & dataChart("subarea") & CHR(34)
	end If
	dataChart.movenext
	loop
	Cierra(dataChart)

	response.write (""&arrA&"<BR>")
	
	conexion = ConectarSQL()
	Set  dataChartb = Query("SELECT * FROM vista_feedback_graf_area ORDER By subarea", conexion)
	
	'do while not dataChartb.Eof
	'If arrB = "" Then
	'arrB = dataChartb("numxarea")
	'else
	'arrB = arrB &", "& dataChartb("numxarea")
	'end If
	'dataChartb.movenext
	'loop
	'Cierra(dataChartb)
	'response.write arrB

 arrB = "" 
While not dataChartb.Eof
   arrB = arrB & CStr(dataChartb("numxarea")) & ", "
   dataChartb.movenext
Wend
arrB = MID(arrB, 1, LEN(arrB)-2)
Cierra(dataChartb)
response.write arrB

%>

<%
Sub ShowChart(ByRef aValues, ByRef aLabels, ByRef strTitle, ByRef strXAxisLabel, ByRef strYAxisLabel)
' Some user changable graph defining constants
' All units are in screen pixels
Const GRAPH_WIDTH = 430 ' El ancho del cuerpo del grafico
Const GRAPH_HEIGHT = 250 ' La altura del cuerpo del grafico
Const GRAPH_BORDER = 1 ' Tamaño de borde negro
Const GRAPH_SPACER = 2 ' Tamaño del espacio entre barras

' Debugging constant so I can eaasily switch on borders in case
' the tables get messed up. Should be left at zero unless you're
' trying to figure out which table cells doing what.
Const TABLE_BORDER = 0
'Const TABLE_BORDER = 10

' Declare our variables
Dim I
Dim iMaxValue
Dim iBarWidth
Dim iBarHeight

' Get the maximum value in the data set
iMaxValue = 0
For I = 0 To UBound(aValues)
If iMaxValue < aValues(I) Then iMaxValue = aValues(I)
Next 'I
'Response.Write iMaxValue ' Debugging line


' Calculate the width of the bars
' Take the overall width and divide by number of items and round down.
' I then reduce it by the size of the spacer so the end result
' should be GRAPH_WIDTH or less!
iBarWidth = (GRAPH_WIDTH \ (UBound(aValues) + 1)) - GRAPH_SPACER
'Response.Write iBarWidth ' Debugging line


' Start drawing the graph
%>

<TABLE BORDER="<%= TABLE_BORDER %>" CELLSPACING="0" CELLPADDING="0" align=center>
<TR>
<TD COLSPAN="3" ALIGN="center"><H2><%= strTitle %></H2></TD>
</TR>
<TR>
<TD VALIGN="center"><B><%= strYAxisLabel %></B></TD>
<TD VALIGN="top">
<TABLE BORDER="<%= TABLE_BORDER %>" CELLSPACING="0" CELLPADDING="0">
<TR>
<TD ROWSPAN="2"><IMG SRC="./images/spacer.gif" BORDER="0" WIDTH="1" HEIGHT="<%= GRAPH_HEIGHT %>"></TD>
<TD VALIGN="top" ALIGN="right"><%= iMaxValue %>&nbsp;</TD>
</TR>
<TR>
<TD VALIGN="bottom" ALIGN="right">0&nbsp;</TD>
</TR>
</TABLE>
</TD>
<TD>
<TABLE BORDER="<%= TABLE_BORDER %>" CELLSPACING="0" CELLPADDING="0">
<TR>
<TD VALIGN="bottom"><IMG SRC="./images/spacer_black.gif" BORDER="0" WIDTH="<%= GRAPH_BORDER %>" HEIGHT="<%= GRAPH_HEIGHT %>"></TD>
<%
' We're now in the body of the chart. Loop through the data showing the bars!
For I = 0 To UBound(aValues)
iBarHeight = Int((aValues(I) / iMaxValue) * GRAPH_HEIGHT)

' This is a hack since browsers ignore a 0 as an image dimension!
If iBarHeight = 0 Then iBarHeight = 1
%>
<TD VALIGN="bottom"><IMG SRC="./images/spacer.gif" BORDER="0" WIDTH="<%= GRAPH_SPACER %>" HEIGHT="1"></TD>
<TD VALIGN="bottom"><IMG SRC="./images/spacer_red.gif" BORDER="0" WIDTH="<%= iBarWidth %>" HEIGHT="<%= iBarHeight %>" ALT="<%= aValues(I) %>"></A></TD>
<%
Next 'I
%>
</TR>
<!-- I was using GRAPH_BORDER + GRAPH_WIDTH but it was moving the last x axis label -->
<TR>
<TD COLSPAN="<%= (2 * (UBound(aValues) + 1)) + 1 %>"><IMG SRC="./images/spacer_black.gif" BORDER="0" WIDTH="<%= GRAPH_BORDER + ((UBound(aValues) + 1) * (iBarWidth + GRAPH_SPACER)) %>" HEIGHT="<%= GRAPH_BORDER %>"></TD>
</TR>
<% ' The label array is optional and is really only useful for small data sets with very short labels! %>;
<% If IsArray(aLabels) Then %>
<TR>
<TD><!-- Spacing for Left Border Column --></TD>
<% For I = 0 To UBound(aValues) %>
<TD><!-- Spacing for Spacer Column --></TD>
<TD ALIGN="center"><FONT SIZE="1"><%= aLabels(I) %></FONT></TD>
<% Next 'I %>;
</TR>
<% End If %>
</TABLE>
</TD>
</TR>
<TR>
<TD COLSPAN="2"><!-- Place holder for X Axis label centering--></TD>
<TD ALIGN="center"><BR><B><%= strXAxisLabel %></B></TD>
</TR>
</TABLE>
<%
End Sub
%>
<%
' Static Chart (with Bar Labels)
'ShowChart Array(6, 10, 12, 18, 23, 26, 27, 28, 30, 34, 37, 45, 55), Array("P1", "P2", "P3", "P4", "P5", "P6", "P7", "P8", "P9", "P10", "P11", "P12", "P13"), "Título del Gráfico", "X Label", "Y"

ShowChart Array(arrB), Array("P1", "P2", "P3", "P4", "P5", "P6", "P7"), "Título del Gráfico", "X Label", "Y"



' Spacing
Response.Write "<BR>" & vbCrLf
Response.Write "<BR>" & vbCrLf
Response.Write "<BR>" & vbCrLf
Response.Write "<HR>" & vbCrLf
Response.Write "<BR>" & vbCrLf

' Random number chart
Dim I
Dim aTemp(49)

Randomize
For I = 0 to 49
aTemp(I) = Int((50 + 1) * Rnd)
Next 'I

' Chart made from random numbers (without Bar Labels)
ShowChart aTemp, "Note that this isn't an Array!", "Gráfico de 50 Números", "Index", "Valor"
%>
usalo sin conexion, comentalo y te daras cuenta que funciona bien pero cuando traigo valores de la bd se cae.

Saludos
__________________
Usa títulos específicos y con sentido
En las listas de correo o en los grupos de noticias, la cabecera del mensaje es tu oportunidad de oro para atraer la atención de expertos cualificados en aproximadamente 50 caracteres o menos. No los desperdicies en balbuceos como "Por favor ayúdame" (de "POR FAVOR AYÚDAME!!!" ya ni hablamos). No intentes impresionarnos con lo profundo de tu angustia; mejor usa ese preciado espacio para una descripción lo más concisa posible del problema.
  #6 (permalink)  
Antiguo 26/12/2006, 11:30
Avatar de Myakire
Colaborador
 
Fecha de Ingreso: enero-2002
Ubicación: Centro de la república
Mensajes: 8.849
Antigüedad: 22 años, 4 meses
Puntos: 146
Re: Generar Array

Esta fácil

Solo cambia
ShowChart Array(arrB), Array("P1", "P2", "P3", "P4", "P5", "P6", "P7"), "Título del Gráfico", "X Label", "Y"



Por
ShowChart por Split(arrB), Array("P1", "P2", "P3", "P4", "P5", "P6", "P7"), "Título del Gráfico", "X Label", "Y"



Saludos
  #7 (permalink)  
Antiguo 26/12/2006, 12:20
Avatar de dobled  
Fecha de Ingreso: enero-2002
Ubicación: Rancagua - Chile
Mensajes: 1.328
Antigüedad: 22 años, 4 meses
Puntos: 2
Re: Generar Array

Perfecto , funciona. Ahora me queda ver por que no me saca el valor maximo del arreglo.

Gracias
__________________
Usa títulos específicos y con sentido
En las listas de correo o en los grupos de noticias, la cabecera del mensaje es tu oportunidad de oro para atraer la atención de expertos cualificados en aproximadamente 50 caracteres o menos. No los desperdicies en balbuceos como "Por favor ayúdame" (de "POR FAVOR AYÚDAME!!!" ya ni hablamos). No intentes impresionarnos con lo profundo de tu angustia; mejor usa ese preciado espacio para una descripción lo más concisa posible del problema.
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 00:26.