Link to home
Start Free TrialLog in
Avatar of sureshp
sureshp

asked on

Urgent!!!

Hi all,

Using Perl Script I would like to plot graph for the following data.

Order      Start Date      Start Time      Set      Run
---------------------------------------------------
12345      22-05-2005      19:00            1:00      3:00
78910      23-05-2005      6:00            2:00      4:00
24689      23-05-2005      18:00            2:00      1:00
8765      24-05-2005      8:00            2:00      3:00

The above said data is stored in a hash.

The HTMLpage contains two columns, Each column contain 1 to 24 divisions for hrs(24hrs per day).
For each order , I would like to plot the graph using Start date,start time,set and run.

For ex: for 1st set of data given above... order is 12345, starttime is 19:00 and set should start from 19th division and end in 20th division(1 unit move) and colour for this area is "red"(like bar graph). and run will end in 23rd position after moving 3 divisions from set position(20th div) and fill the cell by green color. Next date will be in next column and order(78910) starts from 6th division and set will end in 8th division(colour red) and run will end in 12th position(green). like next set of values... Finally the graph should be displayed in browser(IE).

Sample page view for the given data...

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
                                       22-05-2005 Order-12345         23-05-2005 Order-78910          Order-24689    
                                                         <.R.><..green..>                 <.R..><.G>
                                    <.R.><..green>
  24-05-2005 Order-8765
              <.R.><.Green.>


-------------------------------------------------------------------------

<R.> FOR to fill red colour(Set) and <green> to fill green colour(Run)

Which module will support to do this problem? GD can be used or is it possible to draw graph without using CPAN module?
Can you please provide a code for my sample data?
 


Avatar of ozo
ozo
Flag of United States of America image

print q{Content-Type: text/html; charset=ISO-8859-1

<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE html
        PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
         "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en-US">
<head><title>Urgent!!!</title>
</head>
<body>
<style type="text/css">
SPAN.red {background-color: red}
SPAN.green {background-color: green}
</style>
<pre>
};
my %hash;
for( <DATA> ){
    my @F=split;
    $F[1] = join'-',reverse split/-/,$F[1];
    $hash{shift @F} = \@F;
}
printf "%2s ",$_ for 1..24,"|",1..24;
print "\n";
my $n=1;
for( sort{$hash{$a}[1] cmp $hash{$b}[0]} keys %hash ){
   printf "%-127s", "   "x$hash{$_}[1]
                . '<span class="red">'
                . "   "x$hash{$_}[2]
                . '</span><span class="green">'
                . "   "x$hash{$_}[3]
                . '</span>';
  print "\n" if ++$n%2;
}
print "</pre></body></html>\n";
__DATA__
12345     22-05-2005     19:00          1:00     3:00
78910     23-05-2005     6:00          2:00     4:00
24689     23-05-2005     18:00          2:00     1:00
8765     24-05-2005     8:00          2:00     3:00
Avatar of sureshp
sureshp

ASKER

Hi ozo,

Thanks a lot for your help.

12345     22-05-2005     19:00          1:00     3:00
78910     23-05-2005     6:00          2:00     4:00
24689     23-05-2005     18:00          2:00     1:00
8765     24-05-2005     8:00          2:00     3:00

Using the above data, getting html page display as follows:

html code:-
<html xmlns="http://www.w3.org/1999/xhtml" lang="en-US">
<head><title>Urgent!!!</title>
</head>
<body>
<style type="text/css">
SPAN.red {background-color: red}
SPAN.green {background-color: green}
</style>
<pre>
 1  2  3  4  5  6  7  8  9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24  |  1  2  3  4  5  6  7  8  9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 <br>                                                         <span class="red">   </span><span class="green">         </span>                                                            <span class="red">      </span><span class="green">   </span>            <br>                  <span class="red">      </span><span class="green">            </span>                                                               <span class="red">      </span><span class="green">         </span>                                    <br></pre></body></html>
---

Looking for Output page as shown below:

html code:
<html xmlns="http://www.w3.org/1999/xhtml" lang="en-US">
<head><title>Urgent!!!</title>
</head>
<body>
<style type="text/css">
SPAN.red {background-color: red}
SPAN.green {background-color: green}
</style>
<pre>
 1  2  3  4  5  6  7  8  9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24  |  1  2  3  4  5  6  7  8  9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 <br>(12345 22-05-2005)                                     <span class="red">   </span><span class="green">         </span>          (23-05-2005)  <span class="red">      </span><span class="green">            </span>                  <span class="red">      </span><span class="green">   </span>            <br>(8765 24-05-2005)      <span class="red">      </span><span class="green">         </span><br></pre></body></html>
======

The data will be stored in the hash sort by date.

On 22-05-2005, Can see Only One data to draw.
But on 23-05-2005, there are 2 set of data. Need to draw in the same column.
On 24-05-2005, Can see Only One data to draw.

Can you please provide a solution for this?

And I have another doubt, if the data overlap on the same date , for example

12345     22-05-2005     19:00          1:00     3:00
78910     23-05-2005     6:00           2:00     4:00
55556     23-05-2005     6:00           1:00     3:00
24689     23-05-2005     18:00          2:00     1:00
8765      24-05-2005     8:00           2:00     3:00

I want to draw the graph on the data line by line on same date. Can you please help me?

If you have
12345     22-05-2005     1:00          1:00     3:00
would you want something like
<span class="red">(12</span><span class="green">345 22-05</span>-2005)

What do you want the result to look like for overlaping data?
Avatar of sureshp

ASKER

Looking for Output page as shown below:

html code:
<html xmlns="http://www.w3.org/1999/xhtml" lang="en-US">
<head><title>Urgent!!!</title>
</head>
<body>
<style type="text/css">
SPAN.red {background-color: red}
SPAN.green {background-color: green}
</style>
<pre>
 1  2  3  4  5  6  7  8  9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24  |  1  2  3  4  5  6  7  8  9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 <br>(12345 22-05-2005)                                     <span class="red">   </span><span class="green">         </span>          (23-05-2005)  <span class="red">      </span><span class="green">            </span>                  <span class="red">      </span><span class="green">   </span>            <br>(8765 24-05-2005)      <span class="red">      </span><span class="green">         </span><br></pre></body></html>
======
That looks like (12345 22-05-2005) is red beteen 19 and 20
Which would mean your data was
12345     22-05-2005     19:00          1:00     3:00
What should it look like if your data was
12345     22-05-2005     1:00          1:00     3:00

And what would you want to do with overlaping data?

Avatar of sureshp

ASKER

ozo,

if the data is  12345     22-05-2005     1:00          1:00     3:00

first 1:00 will be starting position( 1to 24 division, points to the 1st division), next 1:00 mean it will draw a red color for 1 division from the 1st position.
The next value 3:00 will fill the green color from 2nd division till 5th division.
Hope you got me.

Another EXAMPLE:

12345     22-05-2005     7:00          2:00     4:00
MEANS should start from 7th division, and fill color red till 9th division(7+2) , then fill color green till 13th division(from 9th division to 13th ... (7+2)+4)

Thanks for your help.
next 1:00 mean it will draw a red color for 1 division from the 1st position.
So if the (12345 22-05-2005) in
 1  2  3  4  5  6  7  8  9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24  |  1  2  3  4  5  6  7  8  9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 <br>
(12345 22-05-2005)
is in the first position, does that mean you want
(<span class="red">123</span><span class="green">45 22-</span>05-2005)

And what do you want to do if the data overlap on the same date?


Avatar of sureshp

ASKER

ozo,

"is in the first position, does that mean you want
(<span class="red">123</span><span class="green">45 22-</span>05-2005)"

No, No need to display order(12345) and date in span. It should be (<span class="red"> </span><span class="green"> </span>)".

My aim is to draw the graph for each date, and if one or more than one order exists in that it should draw in the same column. If more than one data exist for each date, the graph should be draw line by line in that column for particular date.

For example: The data is given below:
Order     date                start time   set        run
78910     23-05-2005     6:00           2:00     4:00
55556     23-05-2005     6:00           1:00     3:00


Need to draw graph for date 23-05-2005, here two orders are available(78910    and  55556). Each Order is start with division 6 (1 to 24 hours scale).
The Order 78910, starts from 6th division and fill red color for 2 division(ends at 8th division) and fill green colour for 4 division, ends in 12th division([6+2]+4).

and need a line break to draw the order 55556 for same date... It should start from 6th division and fill red color for 1 division (ends at 7th division) and fill green colour for 3 division, ends in 10th division([6+1]+3).

Hope I explained properly.

Thanks for your quick response and valuable help. Your first solution is good. Can you please help me to draw for the sample data given below:

Order     date                start time   set        run
12345     22-05-2005     19:00          1:00     3:00
78910     23-05-2005     6:00           2:00     4:00
55556     23-05-2005     6:00           1:00     3:00
24689     23-05-2005     18:00          2:00     1:00
8765      24-05-2005     8:00           2:00     3:00

Thanks




in
<pre>
 1  2  3  4  5  6  7  8  9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24  |  1  2  3  4  5  6  7  8  9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 <br>
(12345 22-05-2005)

the  (12345 22-05-2005) takes up positions  1,2,3,4,5,6
if any of those positons should be red or green, what should happen?

What do you want the output to be when red or green positions overlap?
Would you want them displayed on separate lines?
(If everything is always on a separate line, then nothing can ever overlap, then why the doubt?)

                         
Avatar of sureshp

ASKER

ozo,

"Would you want them displayed on separate lines?" .. YES I want to display that in separate line.
"(If everything is always on a separate line, then nothing can ever overlap, then why the doubt?)" ... Yeah, what you said is correct.

"the  (12345 22-05-2005) takes up positions  1,2,3,4,5,6"

Consider this data,
12345     22-05-2005     19:00          1:00     3:00

12345 is an order number, 22-05-2005   is order date,   19:00   is start time(where the graph should start(19th division), 1:00    is set time need to fill color red 1 division from 19th division(that's start time position) AND  3:00 is run time need to fill color green 3 division from 20th position(ie where the red ends in the position).

Hope Now I explained well.

So I would like to print Order and Date details  and for corresponding data need to plot graph.

Thanks  

Consider this data,
12345     22-05-2005     2:00          1:00     3:00
2:00   is start time(where the graph should start(2nd division), 1:00    is set time need to fill color red 1 division from 2nd division(that's start time position)
But the "(12345     22-05-2005)" would be printed in the 2nd position, so would it be red?
As I'm now understand it, the only thing my original answer was missing was printing the "(12345     22-05-2005)"

Also, will the times always end in :00?
Avatar of sureshp

ASKER

Ozo,

Thanks for your reply.

"But the "(12345     22-05-2005)" would be printed in the 2nd position, so would it be red?
As I'm now understand it, the only thing my original answer was missing was printing the "(12345     22-05-2005)""

12345     22-05-2005 is the order number and corresponding date for that order. It's better to print before drawing the graph(one line up). No need to print order and date inside the rectangular box(color filling area). Hope I answered clearly for your question.

"Also, will the times always end in :00?" This is an important question.

For Example, set time 2:50 means (Two and half division). The ":" represents liks a Decimal point. The value comes after ":" will be treated like this (25 means quarter division, 50 means etc..).  
I think this will be very difficult to handle while drawing graph. Can we able to do that? My first aim is to draw the graph for set of data(without considering decimal part).

Thanks
   

 

Avatar of sureshp

ASKER

ozo,
Can you please help me in this problem?
Thanks
ASKER CERTIFIED SOLUTION
Avatar of ozo
ozo
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
Avatar of sureshp

ASKER

ozo,

Thanks for your reply.
Executed the given code, but output format is not correct...

Please check the output...

ozo.html
--------

<html xmlns="http://www.w3.org/1999/xhtml" lang="en-US">
<head><title>Urgent!!!</title>
</head>
<body>
<style type="text/css">
SPAN.red {background-color: red}
SPAN.green {background-color: green}
</style>
<pre>
  1  2  3  4  5  6  7  8  9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24  |  1
2  3  4  5  6  7  8  9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24<br>
(12345 22-05-2005)                                                         (2468
9 23-05-2005)                                                         <br>
                                                         <span class="red">   </
span><span class="green">         </span>
                     <span class="red">      </span><span class="green">   </spa
n>            <br>
(55556 23-05-2005)                                                         (7891
0 23-05-2005)                                                         <br>
                  <span class="red">   </span><span class="green">         </spa
n>                                                               <span class="re
d">      </span><span class="green">            </span>
              <br>
(8765 24-05-2005)                                                          <br>
                        <span class="red">      </span><span class="green">
    </span>                                    <br>
</pre></body></html>



=================================

for the data given below,
12345     22-05-2005     19:00          1:00     3:00
78910     23-05-2005     6:00          2:00     4:00
24689     23-05-2005     18:00          2:00     1:00
8765     24-05-2005     8:00          2:00     3:00

Looking for Output page as shown below:

html code:
<html xmlns="http://www.w3.org/1999/xhtml" lang="en-US">
<head><title>Urgent!!!</title>
</head>
<body>
<style type="text/css">
SPAN.red {background-color: red}
SPAN.green {background-color: green}
</style>
<pre>
 1  2  3  4  5  6  7  8  9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24  |  1  2  3  4  5  6  7  8  9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 <br>(12345 22-05-2005)                                     <span class="red">   </span><span class="green">         </span>          (23-05-2005)  <span class="red">      </span><span class="green">            </span>                  <span class="red">      </span><span class="green">   </span>            <br>(8765 24-05-2005)      <span class="red">      </span><span class="green">         </span><br></pre></body></html>
======

thanks
I thought you said
"It's better to print before drawing the graph(one line up)."
I thought that meant that the "(12345 22-05-2005) " should be one line up
If it was not one line up, then it could run into the red or green section, which is why I asked if it should be coloured red (or green) in that case.
And why don't I see "78910" or "24689" in the output you are looking for?
Avatar of sureshp

ASKER

ozo,

thanks for your help.

"And why don't I see "78910" or "24689" in the output you are looking for?"
Sorry ... I have posted the html page what I looking for...  data "78910" and  "24689" are missing .....

Avatar of sureshp

ASKER

ozo,

Is it possible to draw this kind of graph using GD module?
Avatar of sureshp

ASKER

shall I close this question. I am going to split the points and will award one part to ozo.
Avatar of sureshp

ASKER

jmcg,

I made an attempt to split the points for ozo, but its forcing me to give full points.
How can I give partial points?

Thanks