Se vocês puderem me ajudar a melhora eu agradeço.
<%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%>
<%'Para garantir que a acentuação estará correta
Response.Charset="ISO-8859-1"%>
<!-- #include file="../Templates/conecta.asp" -->
<!-- include file="Templates/valida_usu.asp" -->
<%'Padrão brasileiro de apresentação de data e hora
Session.LCID = 1046
'Datas , Datas e mais datas...
'http://www.macoratti.net/vbdatas1.htm
'http://www.macoratti.net/vb_datas.htm
'fazer cálculos com datas e horas
'http://www.macoratti.net/d010901.htm
'Fazendo o tratamento de datas para incluir no banco de dados
'http://www.macoratti.net/d150102.htm
'data = Right("00" & Day(date),2)&"/"& Right("00" & Month(date),2)&"/" & Year(date)
'Página com exemplo de gráficos
'http://imasters.uol.com.br/artigo/5637/asp/graficos_em_asp_usando_owc/
'http://www.linhadecodigo.com.br/Artigo.aspx?id=1506
'===========================
'| Declarando as variáveis |
'===========================
Dim Meses, pegaMes, pegaAno, i, pegaMesPassado, pegaMesAno, arrMeses, arrAno, arrMesAno, NomeCidade, RsCidade, arrCidade, corLinha
Dim TotalMes, cont, Cidade, Soma
'****************************************************************************
**********************
'* nas três linhas abaixo eu pego um valor qualquer que será a quantidades de meses que eu desejo. *
'* depois eu uso o comando DateAdd para pegar o mês anterior ao atual subtraindo 1 do comando Date.*
'* depois eu aproveito a minha variável para pegar a data equivalente ao mês inicial da consulta *
'* retirando a partir da data do mês passado a quantidade de meses que eu desejo. Assim eu tenho a *
'* data inicial e a data final da minha consulta. *
'****************************************************************************
**********************
'Pega a quantidade de meses passados para a consulta
Meses = 12
'Pega o mês anterior ao atual (data final)
pegaMesPassado = DateAdd("m",-1,Date())
'Pega a data de início, aproveitando a variável
Meses = DateAdd("m",-Meses,pegaMesPassado)
'Monta um vetor com o ano passado mais o atual e monta um array a partir dele.
'pegaAno = Year(Date()) & "," & Year(DateAdd("yyyy",-1,Date()))
'arrAno = Split(pegaAno,",")
'Controla a cor da linha da tabela
corLinha = "#FFFFFF"
'****************************************************************************
************************
'* no loop abaixo eu pego a data inicial e enquanto ela for menor que a data atual eu monto o meu *
'* controle de meses e mesesanos que, no meu caso, preciso para conseguir acessar as bases desejadas *
'* uso o comando DateDiff para fazer a comparação da data de hoje com a data passada no loop *
'****************************************************************************
************************
'Pega a data inicial
i = Meses
'Monta vetor de meses e mesesanos
Do While i < Date()
'Monta os meses
if DateDiff("m", i, pegaMesPassado) > 0 Then
pegaMes = pegaMes & Month(i) & ","
pegaMesAno = pegaMesAno & Month(i) & Year(i) & ","
elseif DateDiff("m", i, pegaMesPassado) = 0 Then
pegaMes = pegaMes & Month(i)
pegaMesAno = pegaMesAno & Month(i) & Year(i)
end if
'Pega a próxima data adicionando 1 mês à data atual
i = DateAdd("m",1,i)
Loop
'****************************************************************************
*********************
'* Nas duas próximas linhas eu monto um array para cada vetor que eu criei usando o comando Split *
'****************************************************************************
*********************
'Monta array de meses e MesesAno
'pegaMes = Left(pegaMes, Len(pegaMes)-1)
arrMeses = Split(pegaMes,",")
arrMesAno = Split(pegaMesAno,",")
'****************************************************************************
******************
'* Abaixo eu transformo a variável criada num array do mesmo tamanho do array arrMesAno criado.*
'* uso o comando UBound para pegar a última posição do array arrMesAno criado logo a cima *
'****************************************************************************
******************
'Transforma a variável num array
ReDim TotalMes(UBound(arrMesAno))
'****************************************************************************
'* preencho as posições do meu novo array com 0 para eu calcular lá embaixo *
'****************************************************************************
for i = 1 to UBound(TotalMes)
TotalMes(i) = 0
next
'Se o mês for menor que 10 será adicionado um 0 à esquerda do número
for i = 1 to UBound(arrMeses)
if arrMeses(i) < 10 Then
arrMeses(i) = 0 & arrMeses(i)
arrMesAno(i) = 0 & arrMesAno(i)
end if
next
%>
<html xmlns="[url="http://www.w3.org/1999/xhtml"]http://www.w3.org/1999/xhtml[/url]">
<head>
<title>Relatório de Faturamento</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<link href="css/generic.css" rel="stylesheet" type="text/css" media="all" />
<link href="css/reset.css" rel="stylesheet" type="text/css" media="all" />
<link href="css/print.css" rel="stylesheet" type="text/css" media="print" />
<link href="css/ie.css" rel="stylesheet" type="text/css" media="all" />
<link href="css/estilo.css" rel="stylesheet" type="text/css" media="all" />
<!-- #include file="../VBS/Funcoes.asp" -->
</head>
<body bgcolor="#FFFFFF" leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">
<table cellpadding="2" cellspacing="1" border="0" style="width:1000px;" align="left">
<tr><td bgcolor="#7E78B6" colspan="13" align="center" class="titulo">Faturamento</td></tr>
<tr bgcolor="#7E78B6">
<td nowrap="nowrap" class="subtitulo" align="center">Mês</td>
<%'Apresenta as colunas da tabela com os meses abreviados
for i = 1 to UBound(arrMesAno)%>
<td class="subtitulo" align="center"><%Response.Write(VerMes(arrMeses(i)) &"/"& Mid(arrMesAno(i),5,2))%></td>
<%next%>
</tr>
<%'Monta retorno para pegar o nome das cidades existentes no banco
Set RsCidade = Server.CreateObject("AdoDb.RecordSet")
strSql ="spCidade"
Set RsCidade = con.Execute(strSql)
'Se não for final da consulta monta as linhas da tabela
if not RsCidade.eof Then
'Enquanto não for final da consulta
while not RsCidade.eof
'Controla as cores da tabela
If corLinha = "#FFFFFF" Then
corLinha = "#D8C7EC"
Else
corLinha = "#FFFFFF"
End If
'Monta array de cedades para usar no gráfico
if Cidade <> "" then
Cidade = """"&Cidade &""","""& RsCidade("cidade")&""""
else
Cidade = """"& RsCidade("cidade") &""""
end if
%>
<tr><td bgcolor="<%=corLinha%>" align="left"><%=RsCidade("cidade")%></td>
<% 'Para cada coluna uma consulta
for i = 1 to UBound(arrMesAno)
strSql = "spSoma '"& RsCidade("cidade") &"','"& arrMesAno(i) &"'"
'Vem da página de conexão com o banco
registros.Open strSql, con, 3, 3
'Se não for final de arquivo apresenta a soma
If Not registros.Eof Then
If Trim(registros("soma")) <> "" Or Not IsNull(registros("soma")) Then
'Monta vetor de total de cada posição para realizar a soma total da coluna
if Soma <> "" then
Soma = Soma &"|"& registros("soma")
else
Soma = registros("soma")
end if
%>
<td bgcolor="<%=corLinha%>" align="right">
<% Response.Write(registros("soma"))
'array recebe os valores que serão somados em cada posição
TotalMes(i) = Soma
Else
%>
<td bgcolor="<%=corLinha%>" align="right">
<% Response.Write(0)
'array recebe 0 na posição vazia para cálculo
TotalMes(i) = 0
End If
%>
</td>
<% Else
%>
<td bgcolor="<%=corLinha%>" align="right">
<% Response.Write(0)
End If
%>
</td>
<% 'Fecha Registro
registros.Close
next
%>
</tr>
<% 'Move para próximo registro
RsCidade.MoveNext
wend
end If
'Fecha objeto
RsCidade.Close%>
<tr><td bgcolor="<%=corLinha%>">Total</td>
<%'Declara as variáveis para fazer cálculo do total de cada coluna
Dim arrTotalMes, SomaTotal
'inicia a variável com 0 para fazer cálculo
SomaTotal = 0
'Para cada posição do array criado outro array separa os valores
for i = 1 to UBound(TotalMes)
'Pega cada valor passado na posição do array
arrTotalMes = Split(TotalMes(i), "|")
'Prepara a soma dos valores de cada coluna
for cont = 1 to UBound(arrTotalMes)
SomaTotal = SomaTotal + arrTotalMes(cont)
next%>
<td bgcolor="<%=corLinha%>" align="right"><%=SomaTotal%></td>
<%next%>
</tr>
<tr><td colspan="13"><!-- Objeto responsável por montar o gráfico -->
<OBJECT CLASSID="clsid:0002E500-0000-0000-C000-000000000046" id=ChartSpace WIDTH="100%"></OBJECT>
</td></tr>
</table>
<p>
<script language="vbscript" type="text/vbscript">
'Configuração do gráfico'
'Sub Window_onload()'
'lstChartType_onchange'
'End Sub'
'Sub lstChartType_onchange()'
'Declara as variáveis'
Dim Cidades, TotalMes
Dim oChart , oSeries, oLabels
Dim c
Dim nChartType
'Pega vetor feito no ASP acima, lembra?'
Cidades = <%=Cidade%>
'Troca caracteres para separar os valores e fazer o cálculo desejado'
TotalMes = <%=Replace(TotalMes,",",".")%>
TotalMes = Replace(TotalMes,"|",",")
'set c = ChartSpace.Constants'
set c = 3 'o valor passado ao lado é do gráfico de colunas, já que é apenas ele que me importa no momento'
'Clear the Chartspace'
ChartSpace.Clear
'ChartSpace.Border.Color = c.chColorNone'
'Create a new chart with a legend and a title'
set oChart = ChartSpace.Charts.Add()
oChart.HasLegend = True
oChart.Legend.Position = c.chLegendPositionBottom
oChart.HasTitle = True
'Set the Chart type to the selected chart type's long value'
nChartType = CLng(lstChartType.value)
oChart.Type = nChartType
'Set up the series on the chart based on the chart type that was selected'
Select Case nChartType
'============================================================================
======'
' Chart Type: Bar, Column, Stacked Pie, Doughnut, Line (and Variants of those types)'
' '
' Creates two series for the chart. Each series has Categories and Values. '
'============================================================================
======'
Case 0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,20,29,30,31,32,33,34,35,36,37,38:
'Add the first series and specify the categories and values'
With oChart.SeriesCollection.Add
.Caption = "Cidades"
.SetData c.chDimCategories, c.chDataLiteral, Array(Cidades)
.SetData c.chDimValues, c.chDataLiteral, Array(TotalMes)
End With
'//Add a second series and specify the categories and values'
With oChart.SeriesCollection.Add
.Caption = "GESTOR"
.SetData c.chDimCategories, c.chDataLiteral, _
Array("P_1","P_2","P_3","P_4","P_5","P_6","P_7","P_8","P_9","P_10","P_11","P_12")
.SetData c.chDimValues, c.chDataLiteral, _
Array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12)
End With
oChart.Title.Caption = "Gráfico do Faturamento Mensal"
'============================================================================
======'
' Chart Type: Pie and Exploded Pie '
' '
' Create a single series for the chart. The series has Categories and Values. Also '
' display data labels for each pie slice as percentages '
'============================================================================
======'
case 18, 19:
With oChart.SeriesCollection.Add
.SetData c.chDimCategories, c.chDataLiteral, _
Array("Clothing", "Food", "Rent", "Gas", "Utilities", "Entertainment")
.SetData c.chDimValues, c.chDataLiteral, _
Array(100, 300, 500, 70, 200, 250)
Set oLabels = .DataLabelsCollection.Add
oLabels.HasValue = False
oLabels.HasPercentage = True
End With
oChart.Title.Caption = "Personal Budget"
'============================================================================
======'
' Chart Type: Scatter and Bubble (and Variants of those Types) '
' '
' Create two series for the chart. The series has XValues and Yalues. '
'============================================================================
======'
case 21,22,23,24,25,26,27,28:
'Add a series and specify the XValues and YValues'
With oChart.SeriesCollection.Add
.Caption = "Queue A"
.SetData c.chDimXValues, c.chDataLiteral, _
Array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10)
.SetData c.chDimYValues, c.chDataLiteral, _
Array(1.6, 1.9, 2.5, 5.3, 4.6, 5.3, 4.1, 3.7, 2.9, 4)
End With
'Add a second series and specify the XValues and YValues'
With oChart.SeriesCollection.Add
.Caption = "Queue B"
.SetData c.chDimXValues, c.chDataLiteral, _
Array(5, 6, 7, 8, 9, 10, 11, 12, 13, 14)
.SetData c.chDimYValues, c.chDataLiteral, _
Array(3.2, 4.6, 4.8, 5.1, 4.2, 3.8, 3.7, 3.9, 4.3, 2.9)
End With
'Add Bubble Values for Bubble type charts only'
If nChartType = 27 or nChartType = 28 Then
oChart.SeriesCollection(0).SetData c.chDimBubbleValues, c.chDataLiteral, _
Array(0.5, 0.33, 0.55, 0.47, 0.23, 0.52, 0.63, 0.12, 0.41, 0.3)
oChart.SeriesCollection(1).SetData c.chDimBubbleValues, c.chDataLiteral, _
Array(0.11, 0.27, 0.53, 0.49, 0.31, 0.47, 0.51, 0.19, 0.49, 0.22)
End If
oChart.Title.Caption = "Average Call Duration by HeadCount"
'============================================================================
======'
' Chart Type: High-Low-Close (HLC) and Open-High-Low-Close (OHLC) '
' '
' Create one series for the chart. HLC charts have Categories, High Values, Low Values'
' and Close Values. OHLC has those same values plus Open Values. '
'============================================================================
======='
case 39, 40:
With oChart.SeriesCollection.Add
.Caption = "TICKER"
.SetData c.chDimCategories, c.chDataLiteral, _
Array("2/1", "2/2", "2/3", "2/4", "2/5", "2/6", "2/7")
.SetData c.chDimHighValues, c.chDataLiteral, _
Array(101, 105, 106, 104.5, 105.75, 106, 107.5)
.SetData c.chDimLowValues, c.chDataLiteral, _
Array(98.5, 100.75, 99, 101.5, 103.25, 103.5, 102.25)
.SetData c.chDimCloseValues, c.chDataLiteral, _
Array(100, 104.75, 102, 104, 105.75, 105.25, 104)
'Add Open values for OHLC chart type'
If nChartType = 40 Then
.SetData c.chDimOpenValues, c.chDataLiteral, _
Array(98.5, 101, 105, 102.5, 104.75, 105.25, 106)
End If
End With
oChart.Title.Caption = "My Stock"
'============================================================================
======'
' Chart Type: Polar '
' '
' Create one series for the chart. The series contains R and Theta Values. '
'============================================================================
======='
Case 41,42,43,44,45:
With oChart.SeriesCollection.Add
.SetData c.chDimRValues, c.chDataLiteral, _
Array(29, 20, 25, 45, 50, 30, 35, 29)
.SetData c.chDimThetaValues, c.chDataLiteral, _
Array(0, 60, 120, 180, 240, 300, 360)
End With
oChart.Title.Caption = "Polar Chart Type"
End Select
'End Sub'
</script>
<! --- CODE ENDS HERE --->
</p>
</body>
</html>Código do arquivo Funções.asp
<%'//dia da semana e mes por extenso
Function data_hoje()
Dim m
Dim dia_semana
Dim dia_numero
Dim mes_nome
Dim ano_numero
Dim Dia
Dim mes
Dim D
Dia = array(" ","Domingo","Segunda-Feira","Terça-Feira","Quarta-Feira","Quinta-Feira","Sexta-Feira","Sábado")
mes = array(" ","Janeiro","Fevereiro","Março","Abril","Maio","Junho","Julho","Agosto","Setembro","Outubro","Novembro","Dezembro")
d = WeekDay (date()) '//dia da semana
m = DatePart("m",(date()))
dia_semana = Cstr(Dia(d))
dia_numero = Cstr(day(date()))
mes_nome = Cstr(mes(m))
ano_numero = Cstr(year(date()))
data_hoje = dia_semana +", " +dia_numero +" de " +mes_nome +" de " +ano_numero
End Function
'%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
'função para mudar apresentação ano|mês
'%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Function MudaData(string)
fMes = VerMes(right(string,2))
fAno = mid(string,3,2)
MudaData = fMes & "|" & fAno' & " " & fAno
End Function
'Apresenta mês abreviado
Function VerMes(string)
select case string
case "01"
VerMes = "Jan"
case "02"
VerMes = "Fev"
case "03"
VerMes = "Mar"
case "04"
VerMes = "Abr"
case "05"
VerMes = "Mai"
case "06"
VerMes = "Jun"
case "07"
VerMes = "Jul"
case "08"
VerMes = "Ago"
case "09"
VerMes = "Set"
case "10"
VerMes = "Out"
case "11"
VerMes = "Nov"
case "12"
VerMes = "Dez"
end select
End Function
%>O objeto que monta o gráfico eu peguei não lembro onde e ainda não seu usá-lo direito mas como só quero usar um tipo de gráfico então só alterei para me retornar u primeiro gráfico. Se alguém souber como usá-lo e puder ajudar será muito bom.
Uma coisa que eu queria que alguém me ajudasse com a tabela é o seguinte. Eu quero criar um efeito de onmouseover e onmouseout para destacar a linha que o mouse está, não estou sabendo como fazer isso.
Um grande abraço a todos e muito obrigado pela atenção.

Entrar
Cadastre-se
Ajuda
Responder


Quote