Ir para conteúdo
Fórum Script Brasil
  • 0

Ajuda Para Montar Um Gráfico


ri_nepo

Pergunta

Olá galera,

Estou montando um script que gera um grafico simples , eu preciso que ele aparecesse assim na mesma tabela e um ao lado do outro , só que está aparecendo um embaixo do outro

vejam no link abaixo

http://www.hth.com.br/extranet/grafico.asp

Veja o script

<!--#include file="include/conexao.asp"-->

<%

'abre a conexão

Set Conexao = Connect()

'DEMOGRAFIA

SQL_sexo = "SELECT COUNT(tb10_sexo) as quantidade_sexo,tb10_sexo FROM tb10_lifeClub group by tb10_sexo order by quantidade_sexo desc"

SET RS_sexo = conexao.execute(SQL_sexo)

'****CONFIGURAÇÔES**********

' esta parte você coloca onde realmente deseja que o gráfico apareça em seu site...

dim stuff , labelstuff , titulo, imagem, altura, largura, valores

titulo = "Sexo" 'Define o nome do grafico

imagem = "imagens/barramidle.gif" 'Imagem que o grafico ira usar para montar as barras, pode ser uma imagem de 1x1

altura = 100 'Altura maxima do grafico

largura = 10 'Largura maxima do grafico

valores = "True" 'Se verdadeiro apresenta os valores

while not RS_sexo.eof

stuff = Array(RS_sexo("quantidade_sexo")) 'Aqui você deve passar os valores que o grafico ira apresentar

labelstuff = Array(RS_sexo("tb10_sexo")) 'Aqui você deve passar uma legenda para os valores passados na linha acima, deve ter a mesma quantidade

Response.Write makechart(titulo, stuff, labelstuff, imagem, altura, largura, valores) 'Chama a função e passa os valores que você passou como parametro

RS_sexo.movenext

wend

'****FIM CONFIGURAÇÔES**********

%>

<%

'**NÃO É OBRIGATORIO A MUDANÇA DE NENHUMA LINHA A PARTIR DESTE PONTO**

Function makechart(title, numarray, labelarray, imagename, maxheight, maxwidth, addvalues)

dim tablestring

dim max

dim tempnumarray

dim templabelarray

dim heightarray

dim tempnum

if maxheight > 0 and maxwidth > 0 and ubound(labelarray) = ubound(numarray) then

templabelarray = labelarray

tempnumarray = numarray

heightarray = array()

max = 0

maxlength = 0

tablestring = "<TABLE border='1' bordercolor='#000000'>" & vbCrLf

for each stuff in tempnumarray

if stuff > max then max = stuff end if

next

tempnum = maxheight/max

for counter = 0 to ubound(tempnumarray)

if tempnumarray(counter) = max then

redim preserve heightarray(counter)

heightarray(counter) = maxheight

else

redim preserve heightarray(counter)

heightarray(counter) = tempnumarray(counter) * tempnum

end if

next

tablestring = tablestring & "<TR bgcolor='#CCCCFF'><TH colspan='" & ubound(tempnumarray)+1 & "'>" & title & "</TH></TR>" & _

vbCrLf & "<TR bordercolor='#FFFFFF'>" & vbCrLf

for counter = 0 to ubound(tempnumarray)

tablestring = tablestring & vbTab & "<TD valign='bottom' align='center'><img src='" & imagename & "' width='" & maxwidth & "' height='" & _

heightarray(counter) & "'>"

if addvalues then

tablestring = tablestring & "<BR>" & tempnumarray(counter)

end if

tablestring = tablestring & "</TD>" & vbCrLf

next

tablestring = tablestring & "</TR>" & vbCrLf

for each stuff in labelarray

tablestring = tablestring & vbTab & "<TD align='center' bordercolor='#FFFFFF'><B> " & stuff & " </TD>" & vbCrLf

next

tablestring = tablestring & "</TABLE>" & vbCrLf

makechart = tablestring

else

Response.Write "Erro! A altura e a largura devem ser maiores que zero (0), ou o número de títulos não é igual ao número de valores passados..."

end if

end function

%>

Quem puder ajudar eu agradeço

abraços

Ricardo

Link para o comentário
Compartilhar em outros sites

3 respostass a esta questão

Posts Recomendados

  • 0

tenta assim

---- editado ----

malz cara

eu pensei em uma coisa

mas acho qe pensei errado

tenta aí

mas acho qe não vai funciona não

e to sem tempo agora

mas alguém aí deve ajudar se desse jeito não funcionar

<!--#include file="include/conexao.asp"-->
<%
'abre a conexão
Set Conexao = Connect()
'DEMOGRAFIA

SQL_sexo = "SELECT COUNT(tb10_sexo) as quantidade_sexo,tb10_sexo FROM tb10_lifeClub group by tb10_sexo order by quantidade_sexo desc"
SET RS_sexo = conexao.execute(SQL_sexo)


'****CONFIGURAÇÔES**********

' esta parte você coloca onde realmente deseja que o gráfico apareça em seu site...
dim stuff , labelstuff , titulo, imagem, altura, largura, valores
titulo = "Sexo" 'Define o nome do grafico
imagem = "imagens/barramidle.gif" 'Imagem que o grafico ira usar para montar as barras, pode ser uma imagem de 1x1
altura = 100 'Altura maxima do grafico
largura = 10 'Largura maxima do grafico
valores = "True" 'Se verdadeiro apresenta os valores


while not RS_sexo.eof
stuff = Array(RS_sexo("quantidade_sexo")) 'Aqui você deve passar os valores que o grafico ira apresentar
labelstuff = Array(RS_sexo("tb10_sexo")) 'Aqui você deve passar uma legenda para os valores passados na linha acima, deve ter a mesma quantidade
Response.Write makechart(titulo, stuff, labelstuff, imagem, altura, largura, valores) 'Chama a função e passa os valores que você passou como parametro
RS_sexo.movenext
wend

'****FIM CONFIGURAÇÔES**********
%>

<%
'**NÃO É OBRIGATORIO A MUDANÇA DE NENHUMA LINHA A PARTIR DESTE PONTO**
Function makechart(title, numarray, labelarray, imagename, maxheight, maxwidth, addvalues)

dim tablestring
dim max
dim tempnumarray
dim templabelarray
dim heightarray
dim tempnum

if maxheight > 0 and maxwidth > 0 and ubound(labelarray) = ubound(numarray) then


templabelarray = labelarray
tempnumarray = numarray
heightarray = array()
max = 0
maxlength = 0
tablestring = "<TABLE border='1' bordercolor='#000000'>" & vbCrLf

for each stuff in tempnumarray
if stuff > max then max = stuff end if
next


tempnum = maxheight/max

for counter = 0 to ubound(tempnumarray)
if tempnumarray(counter) = max then
redim preserve heightarray(counter)
heightarray(counter) = maxheight
else
redim preserve heightarray(counter)
heightarray(counter) = tempnumarray(counter) * tempnum
end if
next

tablestring = tablestring & "<TR bgcolor='#CCCCFF'><TH colspan='" & ubound(tempnumarray)+1 & "'>" & title & "</TH></TR>" & _
vbCrLf & "<TR bordercolor='#FFFFFF'>" & vbCrLf
for counter = 0 to ubound(tempnumarray)
tablestring = tablestring & vbTab & "<TD valign='bottom' align='center'><img src='" & imagename & "' width='" & maxwidth & "' height='" & _
heightarray(counter) & "'>"
if addvalues then 
tablestring = tablestring & tempnumarray(counter)
end if
tablestring = tablestring & "</TD>" & vbCrLf
next

tablestring = tablestring & "</TR>" & vbCrLf

for each stuff in labelarray
tablestring = tablestring & vbTab & "<TD align='center' bordercolor='#FFFFFF'><B> " & stuff & " </TD>" & vbCrLf
next

tablestring = tablestring & "</TABLE>" & vbCrLf
makechart = tablestring
else
Response.Write "Erro! A altura e a largura devem ser maiores que zero (0), ou o número de títulos não é igual ao número de valores passados..."
end if
end function
%>

Link para o comentário
Compartilhar em outros sites

  • 0

Olá , obrigado pela atenção

infelizmente não funcionou ,

o problema está aqui

while not RS_sexo.eof

stuff = Array(RS_sexo("quantidade_sexo"))

labelstuff = Array(RS_sexo("tb10_sexo"))

Response.Write makechart(titulo, stuff, labelstuff, imagem, altura, largura, valores)

RS_sexo.movenext

wend

Eu teria que achar uma forma dos registros ficarem juntos pois da forma que estar ele monta um grafico diferente para cada registro

Se for manual funciona

stuff = Array(100,50,20

labelstuff = Array("Valor1","Valor2","Valor3")

Response.Write makechart(titulo, stuff, labelstuff, imagem, altura, largura, valores)

Quem puder ajudar eu agradeço

valeu

Ricardo

Link para o comentário
Compartilhar em outros sites

Participe da discussão

Você pode postar agora e se registrar depois. Se você já tem uma conta, acesse agora para postar com sua conta.

Visitante
Responder esta pergunta...

×   Você colou conteúdo com formatação.   Remover formatação

  Apenas 75 emoticons são permitidos.

×   Seu link foi incorporado automaticamente.   Exibir como um link em vez disso

×   Seu conteúdo anterior foi restaurado.   Limpar Editor

×   Você não pode colar imagens diretamente. Carregar ou inserir imagens do URL.



  • Estatísticas dos Fóruns

    • Tópicos
      152,2k
    • Posts
      651,9k
×
×
  • Criar Novo...