Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??

Hi Perl Monks

I want to have a doughnut chart for Hard Disk. It should display Used space, Free Space and Total etc.. Now, I wrote a code for it. It's a pie chart.. How can I get a doughnut for it. I want to display with CGI.

Here's my code

#!/usr/bin/perl use CGI ':standard'; use strict; use warnings; use GD::Graph::pie; my $cmd_1 = "sudo df -h |grep /var |awk '{print \$2}' | sed -e 's/.\$/ +/'"; my $cmd_2 = "sudo df -h |grep /var |awk '{print \$3}' | sed -e 's/.\$/ +/'"; my $result_used = qx/ $cmd_1 /; #$result_used shows 1.4 my $result_free = qx/ $cmd_2 /; #$result_free shows 85 # Both the arrays should same number of entries. my @data = (['Used', 'Free'], [$result_used, $result_free]); my $mygraph = GD::Graph::pie->new(300, 300); $mygraph->set( title => '/var Partition, Size in GB', '3d' => 0, #'3d' => 1, ) or warn $mygraph->error; $mygraph->set_value_font(GD::gdMediumBoldFont); my $myimage = $mygraph->plot(\@data) or die $mygraph->error; print "Content-type: image/png\n\n"; print $myimage->png;

I think Doughnut chart is NICER. But, I can't find many docs for them.

Can U guys help me? Better methods are also welcome...


In reply to doughnut charts with gd:graph by theravadamonk

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



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others admiring the Monastery: (4)
As of 2024-03-29 05:41 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found