Gerando gráficos em barrasNeste artigo irei demonstrar uma função genérica que não utiliza componentes e nem é necessário a instalação de DLL para gerar gráficos dinamicamente.
Está função é muito útil, pois você poderá fazer dela uma biblioteca e chama quando quiser apenas passando os parâmetros e o gráfico é gerado automaticamente.
Abaixo segue imagem de como fica o resultado final do gráfico.

<%
'****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 = "Meu Gráfico" 'Define o nome do grafico
imagem = "images/img_grafico.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
stuff = Array(200,100,50,74,50.5) 'Aqui vc deve passar os valores que o grafico ira apresentar
labelstuff = Array("Campo1","Campo2","Campo3","Campo4","Campo5") 'Aqui vc 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 vc passou como parametro
'****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
%>
Bem galera, chego ao final dessa matéria.
Duvidas, sugestões no email: fabrizio@gianfratti.com
Abraços