Jump to content

Draw chart


Recommended Posts

try this<!doctype html public "-//w3c//dtd html 4.0 transitional//en"><html><head> <title>Cool Chart 1.0</title></head><body><%sub displayverticalgraph(strtitle,strytitle,strxtitle,avalues,alabels)'************************************************************************' draw chart' '************************************************************************const GRAPH_HEIGHT = 300 'set up the graph heightconst GRAPH_WIDTH = 400 'set up the graph widthconst GRAPH_SPACING = 0 const GRAPH_BORDER = 0 'if you would like to see the borders to align things differently const GRAPH_BARS = 2 'loops through different colored bars e.g. 2 bars = gold,blue,gold,blueconst USELOWVALUE = FALSE 'this uses the low value of the array as the value of origin (default = 0)const SHOWLABELS = TRUE 'set this to toggle whether or not the labels are shownconst L_LABEL_SEPARATOR = "|" ' |Labelconst R_LABEL_SEPARATOR = "|" ' Label|const LABELSIZE = -4 const GRAPHBORDERSIZE = 1const INTIMGBORDER = 1 'border around the barsConst ALT_TEXT = 3 'Changes the format of the alternate text of the bar image '1 = Labels ,2 = Values , 3 = Labels + Values , 4 = Percent'************************************************************************'array of different bars to loop through'you can change the order of these 'Count = 10 '"dark_green","red","gold","blue","pink","light_blue","light_gold","orange","green","purple"'cut and paste from here and insert into the agraph_bars array below Make sure the 'number specified in the const GRAPH_BARS is the same as or less than that in the array ' 7 graph_bars <= 7 elements in array'************************************************************************agraph_bars = array("dark_green","red","gold","blue","pink","light_blue","light_gold","orange","green","purple")intmax = 0'find the maximum value of the values arrayfor i = 0 to ubound(avalues)if cint(intmax) < cint(avalues(i)) then intmax = cint(avalues(i)) nextif uselowvalue then intmin = avalues(0)for i = 0 to ubound(avalues)if cint(intmin) > cint(avalues(i)) then intmin = cint(avalues(i)) nextend if'establish the graph multipliergraphmultiplier = 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="leftbord.gif" width="2" height="<%=graphmultiplier+8%>"> </td> <% '*******************MAIN PART OF THE CHART************************************ 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'> </td></tr><tr><td width=8> </td><td> </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> </td><td> </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(1,9,0,23,28,31,13,22,31,7,1,14)aMonthNames = array("Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec")displayverticalgraph "TEST GRAPH","Y-AXIS","X-AXIS",aMonthValues,aMonthNames %></body></html>

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Create New...