Solved

Graphs using CGI

Posted on 1998-08-12
6
231 Views
Last Modified: 2013-12-25
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
Comment
Question by:studoo
6 Comments
 
LVL 28

Expert Comment

by:sybe
ID: 1831480
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
 
LVL 2

Expert Comment

by:Voodoo
ID: 1831481
What platform will you be developing on?
0
 
LVL 2

Expert Comment

by:WDB
ID: 1831482
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
What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

 
LVL 1

Expert Comment

by:wisdom042597
ID: 1831483
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
 
LVL 1

Accepted Solution

by:
wisdom042597 earned 50 total points
ID: 1831484
Let me know if the answer above is acceptable.  

0
 
LVL 10

Expert Comment

by:MasseyM
ID: 1831485
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

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

It is a general practice to get rid of old user profiles on a computer  in a LAN environment. As I have been working with a company in a LAN environment where users move from one place to some other place at times. This will make many user profil…
Batch, VBS, and scripts in general are incredibly useful for repetitive tasks.  Some tasks can take a while to complete and it can be annoying to check back only to discover that your script finished 5 minutes ago.  Some scripts may complete nearly …
Learn the basics of lists in Python. Lists, as their name suggests, are a means for ordering and storing values. : Lists are declared using brackets; for example: t = [1, 2, 3]: Lists may contain a mix of data types; for example: t = ['string', 1, T…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)

744 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now