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

Re^3: doughnut charts with gd:graph

by hippo (Bishop)
on Jul 25, 2018 at 13:06 UTC ( [id://1219255]=note: print w/replies, xml ) Need Help??


in reply to Re^2: doughnut charts with gd:graph
in thread doughnut charts with gd:graph

Filesystem 1K-blocks Used Available Use% Mounted on /dev/mapper/vg_mail-lv_var 94959436 1415576 88713448 2% /var

That explains why the scalars are not set for you. If your Filesystem paths are so long as to overflow like this you will need to use -P. That will avoid the wrapping and hence the assignment errors. Note that this is a demonstrably good reason not to shell out but to use a module instead.

Here is an SSCCE demonstrating this use of -P:

#!/usr/bin/env perl use strict; use warnings; my @df = `df -P /var`; my ($used, $free) = (split (/\s+/, $df[1]))[2,3]; print "used $used, free $free\n";

The split acts on $df[1] (which is the second line returned by df) and splits it on whitespace (like awk does). You then want only the 3rd and 4th fields for your used and free figures but indexing in Perl starts at zero hence the slice of [2,3]. Hopefully that makes it clear enough?

Replies are listed 'Best First'.
Re^4: doughnut charts with gd:graph
by Tux (Canon) on Jul 26, 2018 at 11:31 UTC
Re^4: doughnut charts with gd:graph
by theravadamonk (Scribe) on Jul 26, 2018 at 10:30 UTC

    Hopefully that makes it clear enough?

    Yeah, It's pretty clear. I realized it. Thanks for it.

    You already have the image as a pie so why not just overlay a background-coloured circle on the middle?

    Whole day, I tried, But, still no success..

    Could you pls give a try? It may be easy for you. I don't Want to stop writing this code.. I want to continue..

    The other thing is How to Display values ($used and $free ) in pie chart?

    in Bar chart,We have below line

    show_values => 1,

    I need everyone's replies to complete this code.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1219255]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others surveying the Monastery: (5)
As of 2024-04-19 02:58 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found