[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

Graphs using CGI

Posted on 1998-08-12
6
Medium Priority
?
251 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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
On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

 
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 100 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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

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

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Making a simple AJAX shopping cart Couple years ago I made my first shopping cart, I used iframe and JavaScript, it was very good at that time, there were no sessions or AJAX, I used cookies on clients machine. Today we have more advanced techno…
Active Directory replication delay is the cause to many problems.  Here is a super easy script to force Active Directory replication to all sites with by using an elevated PowerShell command prompt, and a tool to verify your changes.
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …
Suggested Courses

649 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