Link to home
Start Free TrialLog in
Avatar of mdbbound
mdbbound

asked on

How do we create a chart in classic ASP without using the Visual Studio. Please provide some kind of tutorial.

How do you go about creating a decent dynamic chart (pie and bar) in classic ASP.  Also can someone please do some kind of tutorial with sample data.  I'm sure this will not only benefit me but also all of us who are forced to use ASP and no budget to buy third party software.   I will really appreciate this.

I need to know how viable it is because I am going to the meeting and I want to make sure I can do this before recommending asp.  How do we go about taking result from a query (recordset) and use it as a data in creating my charts in ASP pages.  Thank you

Please help

mdbbound
Avatar of lil_puffball
lil_puffball
Flag of Canada image

Don't think it's possible in ASP, but you can use a combination of ASP and Javascript. Basically you would get the data from the database using ASP (server side), and write it to javascript records, then call javascript functions to create the graphs (client side).
ASKER CERTIFIED SOLUTION
Avatar of Anthony Perkins
Anthony Perkins
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Actually, you should use this code, as this works for variable maximum values, whereas the last one is written for percentage values...
Dim arrVals, iBarWidth, iMaxHeight
     Dim arrColours, arrfonts
'//The colours for the various cols. All looped.
     arrcolours = array("#C93D3D","#00974D", "#FEEE00","#1E6CB5")
'//This is then the corresponding font colour for the colours above
     arrfonts = array("white", "white", "black","white")
     iBarWidth = 35
     iMaxHeight = 300
      arrVals = array(101,233,211,44,22,22,55,666,343)    

Dim divValue, tmpVal
      tmpVal = 300
      For i = 0 to Ubound(arrVals,2)
            If tmpVal < arrVals(1,i) then
                  tmpVal = arrvals(1,i)
            End if      
      Next
      
      divValue = 1
      If tmpVal > iMaxHeight then
            divValue = ((tmpVal + 50)/iMaxHeight)
      End if
      
            
      %>
      <table border=0 padding=0 cellpadding="0"cellspacing="0">
      <tr>            
            <td width=400 align="center">
                  <div id="parentdiv" style="padding:4px;position:relative; height:<%= iMaxHeight + 2%>px; width:<%= (iBarWidth * (Ubound(arrVals,2) + 1) )+ 2%>px; border: 1px solid #000;">
                  <%
                  For i = 0 to UBound(arrVals,2)
                  %>
                        <div id="col1" style="bordercolor:#ffffff;position:absolute;left:<%= iBarWidth * i%>px; top: <%=iMaxHeight - (Cint(arrVals(1,i)/divValue))%>px; width:<%= iBarWidth%>px;height:<%= Cint(arrVals(1,i)/divValue)%>px; background-color:<%= arrColours(i mod (uBound(ArrColours) + 1))%>;color:<%= arrFonts(i mod (uBound(ArrFonts) + 1))%>">
                        <div style="height:<%= (Cint(arrVals(1,i)/divValue) - 6)%>px;;writing-mode: tb-rl;filter: flipv flipv;font:  8pt Arial;">&nbsp;<%= MonthName(Month(arrVals(0,i)),true)%> - <%= arrvals(1,i)%></div>
                        </div>
                  <%
                  Next
                  %>
                  </div>
            </td>
      </tr>
      <tr><td style="font:Arial, Helvetica, sans-serif; color:grey; font-size:9px;">Monthly subscription Numbers</em></td></tr>
</table>
Avatar of mdbbound
mdbbound

ASKER

lil_puffball:

Thanks.  I checked out the link www.4guysfromrolla.com.  It's clean code and with explanation.  I have yet to try it.  It's 2 of the best reference I've seen so far.  Have you ever tried it?

ap  sajith:
I looked at those graphs and they really look great.  I'm trying to find out the differences in pricing $49, $99 $799,  I want to make sure of the licensing and distribution description but could not find it.  I'm probably just too tired.  I'll take a look at it again.  Thanks

Slimshaneey:
Thanks. Wow I can never come up with these code by myself.  I am still trying to understand it.  I have yet to try it.  I'm looking for the  part where it gets its data from a recordset or query as I prefer my charts to be dynamic.  It's 2 of the most manageable and clear code I've seen out there.  Just don't know how the output looks like.  You may also want to checkout the link posted by lil_puffball.

If I had the visual studio or ultradev or interdev, can these tool make it easier to create the chart that we are after.  I have to seen the UI of these tools and have no idea on how to use them.  Although, I've used the Dreamweaver MX (not the 2004) for Coldfusion.  Why would microsoft make it so hard to create these charts.  It's very frustrating.
actually, the link was from acperkins. ;)
Thanks :)

>>Have you ever tried it?<<
And yes, I also said I tried it ("Here is one approach that we have used some years back")