Ver Mensaje Individual
  #1 (permalink)  
Antiguo 27/08/2004, 17:00
Avatar de ruben_vmb
ruben_vmb
 
Fecha de Ingreso: noviembre-2003
Ubicación: Mex
Mensajes: 1.325
Antigüedad: 21 años, 5 meses
Puntos: 0
Modificar Codigo p/ grafica

Hola, tengo el siguiente codigo para hacer graficas,, pero quisiera saber
como modificarlo para que los valores del siguiente codigo que son los que
forman las barras me los traiga de una base de datos de dos campos.

<!--<%
aMonthValues = array(15,9,0,23,28,31,13,22,31,7,1,14,1,1,1)
aMonthNames = array("28","30","31","1","2","3","6","10","11","12 ","13","14","15","16","17")
displayverticalgraph "Seguimiento Proyectos","<b>EJE Y</b>","<b>EJE X</b>",aMonthValues,aMonthNames
%>-->


<html>
<head>
<title>Ruta Crítica</title>
</head>
<p align="center"><b><font size="3" face="Tempus Sans ITC">Ruta Crítica</font></b>
<body style="font-family: Arial; font-size: 9pt"></p>

<%sub displayverticalgraph(strtitle,strytitle,strxtitle, avalues,alabels)

const GRAPH_HEIGHT = 300
const GRAPH_WIDTH = 400
const GRAPH_SPACING = 0
const GRAPH_BORDER = 0
const GRAPH_BARS = 2
const USELOWVALUE = FALSE
const SHOWLABELS = TRUE
const L_LABEL_SEPARATOR = "|"
const R_LABEL_SEPARATOR = "|"
const LABELSIZE = -4
const GRAPHBORDERSIZE = 1
const INTIMGBORDER = 1
Const ALT_TEXT = 3



agraph_bars = array("dark_green","red","gold","blue","pink","lig ht_blue","light_gold","orange","green","purple")

intmax = 0

'find the maximum value of the values array
for i = 0 to ubound(avalues)
if cint(intmax) < cint(avalues(i)) then intmax = cint(avalues(i))
next
if uselowvalue then
intmin = avalues(0)
for i = 0 to ubound(avalues)
if cint(intmin) > cint(avalues(i)) then intmin = cint(avalues(i))
next
end if
'establish the graph multiplier
graphmultiplier = round(graph_height-100/intmax)

imgwidth = round(300/(ubound(avalues)+1))
if imgwidth > 16 then imgwidth = 16


%>

<table border =<%=GRAPH_BORDER%> width:100% height=<%=graph_height%>>

<tr>
<td rowspan=3 valign="middle"><%=strytitle%> </td>
<td colspan=<%=ubound(avalues)+2%> height=50 align="center">

<h4><%=strtitle%></h4></td>
</tr>
<% count = 0%>
<tr>
<td>
<table border=<%=graph_border%> cellpadding = 0 cellspacing = <%=graph_spacing%>><tr>
<tr>
<TD height="100%">
<table border="<%=graph_border%>" height="100%">
<tr>
<td height="50%" valign="top" align=right><%=intmax%></td>
</tr>
<tr>
<td height="50%" valign="bottom" align=right>

<%if uselowvalue then
response.write cstr(intmin)
else
response.write "0"
end if
%>
</td>
</tr>
</table>
</td>
<td valign="bottom" align="right"><img src="../Documents%20and%20Settings/VMCHARRAGAB.CAS/Configuración%20local/Temp/Directorio%20temporal%206%20para%20Gráfica%204.zip/leftbord.gif" width="2" height="<%=graphmultiplier+8%>">
</td>

<%
for i = 0 to ubound(avalues)
strgraph = agraph_bars(count)
if alt_text = 1 then
stralt = alabels(i)
elseif alt_text = 2 then
stralt = avalues(i)
elseif alt_text = 3 then
stralt = alabels(i) &" - " &avalues(i)
elseif alt_text = 4 then
stralt = round(avalues(i) /intmax *100,2) &"%"
end if

if uselowvalue then %>
<td valign="bottom" align="center">
<img src="<%=strgraph%>.gif" height="<%=round((avalues(i)-intmin)/intmax*graphmultiplier,0)%>" width="<%=imgwidth%>" alt="<%=strAlt%>" border="<%=intimgborder%>"></td>
<%else%>
<td valign="bottom" align="center">
<img src="<%=strgraph%>.gif" height="<%=round(avalues(i)/intmax*graphmultiplier,0)%>" width="<%=imgwidth %>" alt="<%=strAlt%>" border="<%=intimgborder%>"></td>
<%end if

if count = graph_bars-1 then
count = 0
else
count = count + 1
end if
next

'write out the border at the bottom of the bars also leave a blank cell for spacing on the right
response.write "<td width='50'>&nbsp;</td></tr><tr><td width=8>&nbsp;</td><td>&nbsp;</td><td colspan=" &(ubound(avalues)+1) &" valign='top'>" _
&"<img src='botbord.gif' width='100%' height='2'</td></tr>"
if showlabels then %>
<tr><td width=8 height=1>&nbsp;</td><td>&nbsp;</td>
<%for i = 0 to ubound(avalues)%>
<td valign="bottom" width=<%=imgwidth%> ><font size=
<%=labelsize &">" &l_label_separator &alabels(i) &r_label_separator %></font></td>
<%next%>
</tr>
<%end if%>
<tr><td colspan=<%=ubound(avalues)+3%> height=50 align="center"><%=strxtitle%></td>
</tr>
</table>
</td>
</tr>
<tr>
<td></td></tr>
</table>

<%end sub %>


<%
aMonthValues = array(15,9,0,23,28,31,13,22,31,7,1,14,1,1,1)
aMonthNames = array("28","30","31","1","2","3","6","10","11","12 ","13","14","15","16","17")
displayverticalgraph "Seguimiento Proyectos","<b>EJE Y</b>","<b>EJE X</b>",aMonthValues,aMonthNames
%>

</body>
</html>