Click here to Skip to main content
15,897,226 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
SQL
I am successfully generate the bar chart using classic asp and sql... But there was some problem in my barchart... When mouseover to the barchart it will NOT show the value of the bar.... Please any one help me only in classic ASP not a .NET... I dont know how to shows the value of the chart...

Here is my code...

<%@ LANGUAGE="VBSCRIPT" %>

<!-- #INCLUDE FILE="DatabaseConnectaccess.asp" -->
<%
'How many pixels high we want our bar graph
Const graphHeight = 300
Const graphWidth = 450
Const barImage ="blubar.gif"

sub BarChart(data, labels, title, axislabel)
'Print heading
Response.Write("" & chr(13))
Response.Write("" & chr(13))
Response.Write("")
Dim widthpercent
widthpercent = CInt((1 / (UBound(data) - LBound(data) + 1)) * 100)

For i = LBound(data) to UBound(data) - 1
Response.Write(" " & chr(13))
Next
Response.Write("")
Response.Write("")
'Write footer
Response.Write("" & chr(13))
for i = LBound(labels) to UBound(labels) - 1
Response.Write("" & chr(13))
next
Response.Write("" & chr(13))
Response.Write("
")
Response.Write("" & title & "
" & chr(13))
'Find the highest value
Dim hi
hi = data(LBound(data))
Dim i
for i = LBound(data) to UBound(data) - 1
if data(i) > hi then hi = data(i)
next
'Print out the highest value at the top of the chart
Response.Write(hi & "
" & chr(13))
Response.Write(" <IMG SRC=""" & barImage & """ WIDTH=100% HEIGHT=" & CInt(data(i)/hi * graphHeight) & ">" & chr(13))
Response.Write("
0
" & axislabel & "" & labels(i) & "
")
end sub
'Open connection to database
Dim oRs
Set oRs= Server.CreateObject("ADODB.Connection")

Dim strSQL
strSQL ="select dvn_cd,sum(Target_Inf) as Target_Inf from SIDHSC3 where Target_Inf is not null group by DVN_CD order by DVN_CD "

Dim rs
Set rs = Server.CreateObject("ADODB.Recordset")
rs.Open strSQL,cn,2,3

'response.write err.number &" - " &err.description
Dim dataArray(50)
Dim labelArray(50)
'response.write err.number &" - " &err.description

Dim i
i=0
'response.write err.number &" - " &err.description
do while not rs.eof
dataArray(i) = rs("Target_Inf")
labelArray(i) = rs("dvn_cd")
i=i+1
rs.MoveNext
loop
'response.write err.number &" - " &err.description
%>

<HTML>
<head>

</head>
<BODY>

<% BarChart dataArray,labelArray,"Target_inf","dvn_cd"%>

</BODY>
</HTML>
<%
rs.Close
Set rs = Nothing
cn.Close
Set cn = Nothing
%>
Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900