Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win


GD - HTML - more than 2 graphs

Posted on 2000-02-28
Medium Priority
Last Modified: 2010-07-27
(please do not forget to read comments from experts and my comments related with their suggestions)
Hi gurus,
i want to make a page that get user's data and according to that data draws 2 different graphics on a new page, also i want to make some comments with the given data. The graphics are directly related  with the user's data.
i am on a point that can accept user's data and draws a graphic. but i can not write any comment as html (not as a part of gif) and draw a new graph.
Any help will be appreciated.
(i can draw one graph at a time but i can not send user's input to 2 perl scripts if i directly call it from html) and when i use img src=cgi-bin/draw.pl  i can not send users data again as different 2 perl scipts.
Question by:camasuvi
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
  • 8
  • 4

Expert Comment

ID: 2564134
return the following HTML:

<img src="yourGraphicFilename>
your comments here


Author Comment

ID: 2564145
Adjusted points to 47

Author Comment

ID: 2564178
Edited text of question.
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.


Expert Comment

ID: 2564304
You can call script twice for two different images.
<img src=cgi-bin/draw.pl?draw=picture_1>
<img src=cgi-bin/draw.pl?draw=picture_2>

Author Comment

ID: 2564802
Adjusted points to 130

Author Comment

ID: 2564803
okay let me explain more.
i have prepared an html site that asks starting and finishing dates of an event.
for example 10.02.2000 (starting date )
20.02.2000 are given by user.
my perl script accepts them and prints on the screen.
but i want different graphics for each day. and after each graphic i want to give some info.
since necessary info for each day are stored in oracle database and graphics are drawn according to these stored data
i have to pass them to another perl script and each graphic method should be different for each graphic. (such as pie , bar chart....)
thanks in advance

Author Comment

ID: 2564805
Edited text of question.

Expert Comment

ID: 2565080
I don't get it.
You say you have script - draw.pl that
prints desired image. Right?
You say you can use it as follows:
<img src=cgi-bin/draw.pl>  Right?
What I don't understant is why you can't call this script twice from your HTML page. You will pass some additional parameters (graph methods or anything else it needs) as
CGI parameters. If you want text INFO to be dynamic as well, you can write another script, that will receive same parameters as draw.pl and produce relevant text data.
If the problem is to include dynamic text data ino your document, solution will follow.


Author Comment

ID: 2565119
ok the problem is that it is a user-interacted page that i have to use users input as parameter.
if my cgi-script (which uses cgi-lib.pl and for getting users input) write some dynamic text it is ok. but if i call another perl (draw.pl) at the end of the cgi-script (do "draw.pl" it does not put img on the page ( i think because of content types. first one is text/html and other should be image/gif)
The problem is that i do not know which variable should i send to draw.pl since it changes according to users.

Expert Comment

ID: 2565166
You right when you say it's not going work due content types. Again, I just keep on repeating it, you sould use
<img src=cgi-bin/draw.pl?parameters_that_draw_will_use>
This way image will be requested directly by browser from your draw.pl
draw.pl should be able to parse CGI input, and produce CGI output with appropriate content type. (e.g. print to http header Content-type: image/gif")
Paramteres that are passed to draw.pl tell what user requested graph and how the data should be printed.
The only problem I can see in this system is - security issue. But this also can be solved, if it really matters.

Author Comment

ID: 2565196
ok you can be right at the moment but i have  never used to send parameters in this way draw.pl?parameters_that_draw....    if u expolain me for example how to send two data and how i can get it from perl script i think you deserv all points :))
thanks for your help.

Author Comment

ID: 2565234
ok you can be right at the moment but i have  never used to send parameters in this way draw.pl?parameters_that_draw....    if u expolain me for example how to send two data and how i can get it from perl script i think you deserv all points :))
thanks for your help.

Accepted Solution

sanek earned 520 total points
ID: 2565293
Ok, so we're going to turn draw.pl to a legal CGI script.

First of all, this is very helpful link, describing CGI.pm - perl library for CGI.

Here how can you use it.
Suppose, you have line
<img src=cgi-bin/draw.pl?user=someuser&type=pi&additional_parameter=if_you_need>


# draw.pl - CGI to produce image
use CGI;
$query = new CGI;
$user = $query->param('user') || 'default_user';       # Resolve what equals 'user' in ?user= strnig
$graph_type = $query->param('type') || 'default_type'; # Resolve graph type

print $query->header(-type=>'image/gif',
               -status=>'200 OK',
               -expires=>'now') ;

### print image for $user and depending on $graph_type and exit


Your original script, that produces HTML should fill <img src...> with appropriate info.
PS: You can test draw.pl directly from browser window by typing url that used in that <img src=...> tag.

Featured Post

How to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

Question has a verified solution.

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

Many time we need to work with multiple files all together. If its windows system then we can use some GUI based editor to accomplish our task. But what if you are on putty or have only CLI(Command Line Interface) as an option to  edit your files. I…
There are many situations when we need to display the data in sorted order. For example: Student details by name or by rank or by total marks etc. If you are working on data driven based projects then you will use sorting techniques very frequently.…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
Six Sigma Control Plans

609 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