> Yes, those lines don't make a great deal of sense. Perhaps you want something more like this?

my @word = keys %count; my @count_word = map{ $count{$_} || 0 } @word;

Brilliant, Sir , Thanks a LOT. The above code works as expected. I Now need top 5 ( highest 5 ). So I changed the code in this way.. It works. It NOW shows top 5 as expected.

my @word = ( (sort { $count{$b} <=> $count{$a} } keys %count) [0..4] ) +; my @count_word = map{ $count{$_} || 0 } @word;

I have included below lines as well. I think I don't need below lines at all. I hv commented out them now

Your IDEAS??

#for my $word ( (sort { $count{$b} <=> $count{$a} } keys %count) [0.. +4] ) { # #print "$word $count{$word}\n"; #}

The other thing I want to mention is that my ultimate goal is to have a STACK bar chart since I have another file /tmp/recipients.txt. This file is different from /tmp/senders.txt file.

So, I think I can't achieve a STACK bar chart since I can't have a bar group like first highest sender and first highest recipient , 2 nd highest , 3 rd , 4th and 5 th highest sender and 5 th highest recipient

I will have to pay attention to below lines

my $data = GD::Graph::Data->new([ [@word], [@count_word], ]) or die GD::Graph::Data->error;

If I can have a data structure in this way, I will be able to.

my $data = GD::Graph::Data->new([ [@word], [@count_word], [@count_word_recip], ]) or die GD::Graph::Data->error;

@word only contain senders, I can get @word_recip from /tmp/recipients.txt file with below code. I can include it to the same file

my $logfile_recip = '/tmp/recipients.txt'; open my $fh, '<', $logfile_recip or die "Could not open $logfile_recip + : $!"; my %count_recip=(); while (my $line = <$fh>) { foreach my $word (split /\s+/, $line) { ++$count_recip{$word}; #print "$word\n"; #print "$count_recip{$word}\n"; #print "<br />"; #print " \n"; } } #for my $word ( (sort { $count_recip{$b} <=> $count_recip{$a} } keys +%count_recip) [0..4] ) { # #print "$word $count_recip{$word}\n"; #} close $fh; my @word_recip = ( (sort { $count_recip{$b} <=> $count_recip{$a} } key +s %count_recip) [0..4] ); my @count_word_recip = map{ $count_recip{$_} || 0 } @word_recip; #my $data = GD::Graph::Data->new([ # [@word_recip], # [@count_word_recip], #]) or die GD::Graph::Data->error;

Hmm, Then, How can I have a BAR Group like first highest sender and first highest recipient , 2 nd highest , 3 rd , 4th and 5 th highest sender and 5 th highest recipient ?

This may NOT work...
my $data = GD::Graph::Data->new([ [@word @word_recip], [@count_word], [@count_word_recip], ]) or die GD::Graph::Data->error;

Perl Monks are experts. Can I achieve a stack bar chart? I think I can't get a data structure for a stack bar chart in this way. anyway If I can't have it, I can go with 2 separate charts. Hope to hear from everyone


In reply to Re^2: hbar or bar chart for my top 20 mail users with GD::Graph::hbars or GD::Graph::bars by theravadamonk
in thread hbar or bar chart for my top 20 mail users with GD::Graph::hbars or GD::Graph::bars by theravadamonk

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.