• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 254
  • Last Modified:

Graphs using CGI

I want to generate graphs on a HTML page automatically(on the fly) using the data entered through a form in the web.... How do I go about . If I cannot do it is there any other way of doing it (like ASP or something like that)....Please suggest a solution fast as it is a bit urgent.!!!
0
studoo
Asked:
studoo
1 Solution
 
sybeCommented:
What kind of information will there be in that graph ??
If you want to display bar-diagrams you can use a table with colored cells. As for example are generated by Nedstat counter

see for example
http://viewstat.nedstat.nl/cgi-bin/viewstat?name=clichebook

If you want more complicated graphs, then you could use an applet and write the parameters.

This of course is all cgi (including ASP).

If you really want to make images on the fly, I know it is being done, but I don't know what program is used for that. It is probably not so easy, because you have to know a lot about the image-format.

0
 
VoodooCommented:
What platform will you be developing on?
0
 
WDBCommented:
If you're using C for your cgi scripts then you can obtain gdlib by Thomas Boutell for free. It's a C based library that allows cgi scripts to create images on the fly. You can obtain it at
http://www.boutell.com/freeware.html. It's easy to use and very helpful.
0
Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
wisdom042597Commented:
There are two basic ways to do this.  Well, one "basic" way and another more complicated method.  

If you need something sophisticated, you probably want to get ahold of the GNU (c-based) graphics library (http://freebie.cfcl.com/ptf/products/UNIX/current/0185.0.html) which can be used to generate gif and other graphic files on the fly and includes plotting and charting functions.

The more widely used method of generating graphs is to simply reference a static image and "stretch" it by using HEIGHT and WIDTH commands, as in:
<IMG SRC="img/blueblock.gif" ALT="xxx" HEIGHT=15 WIDTH=136 BORDER=1>

In the above example, I have a gif called "blueblock.gif" which is a small 15x1 image, and I stretch the width to match the measurement I want to visualize.  You can use this technique to make horizontal or vertical bar charts.  (see: http://ads.icorp.net/ads/sample.html)

If you need something like pie charts, you're going to have to generate a complete .gif file and the GNU Plot/graphics libraries are what you need.

Either one of these methods will work with Unix or NT.

Hope this helps.
0
 
wisdom042597Commented:
Let me know if the answer above is acceptable.  

0
 
MasseyMCommented:
Studoo-- Found this on the net... If you like, I will post as answer...
Found it @ http://www.avatarmag.com/columns/serverside/


<%@ LANGUAGE="VBSCRIPT" %>
<%      Set xl = CreateObject("Excel.Application")
      Set fs = CreateObject("AspChart.clsFileSystem")
      ' Was there a previously created chart?      If Session("szLastChart") <> Empty Then
            fs.DeleteFile Session("szLastChart")      End If
      ' Get the path to create the chart in
      szChartPath = Server.MapPath(Request.ServerVariables("PATH_INFO"))
      ' Strip the name of this file off the path
      For i = Len(szChartPath) To 1 Step -1            If Mid(szChartPath,i,1) = "\" Then
                  Exit For            End If      Next      ' Truncate the full path
      szChartPath =  Left(szChartPath, i)      ' Get a temporary filename
      szFullChartName = fs.GetTempFileName(CStr(szChartPath))
      Session("szLastChart") = szFullChartName      ' Add a new workbook
    xl.workbooks.Add    ' Setup titles
    xl.activeworkbook.Sheets(1).Range("B1:M1").Value = Array("Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec")
    xl.activeworkbook.Sheets(1).Range("A2").Value = "Apples"
    xl.activeworkbook.Sheets(1).Range("A3").Value = "Oranges"
    xl.activeworkbook.Sheets(1).Range("A4").Value = "Kiwis"
   ' Fill with random data    For x = 1 To 12        For y = 1 To 3
            xl.activeworkbook.Sheets(1).Range("A1").Offset(y, x).Value = Rnd() * 100
        Next    Next      ' Select the data
    xl.activeworkbook.Sheets(1).Range("A1:M4").Select      ' Add a chart
    xl.Charts.Add      ' Format the chart
    xl.activechart.SetSourceData xl.Sheets("Sheet1").Range("A1:M4"), 1
    xl.activechart.Location 1    xl.activechart.HasDataTable = True
    xl.activechart.DataTable.ShowLegendKey = True      ' Export the chart
    xl.activechart.export szFullChartName, "GIF"    
    xl.activeworkbook.Close False
      ' Get just the filename since the chart is already local
      ' relative to this script      For i = Len(szFullChartname) To 1 Step -1
            If Mid(szFullChartname,i,1) = "\" Then                  Exit For            End If      Next
      ' Truncate the full path
      szChartName =  Right(szFullChartname, Len(szFullChartName)-i)
      ' Write out a tag to show the chart
      Response.Write "<IMG SRC=""" + szChartName + """>"      Set xl = Nothing
      Set fs = Nothing%>
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now