#!/usr/bin/perl ################################################################# # Author Joseph Harnish big_joe1008@yahoo.com # # Date 5/1/2001 # # # # This script is a wrapper for GD::Graph::Bars for use on # # web pages. It is a quicky that is used inside of an # # IFRAME. + # # # # Usage: piegraph.pl?cols=A,B,C&vals=1,2,3 # # It is required to have a "cols" and a "vals" but there are # # options you can also add. These options are: # + # title + # ################################################################# use GD::Graph::pie; use CGI; my $q = new CGI; my $cols = $q->param("cols"); my $title = $q->param("title"); my $vals = $q->param("vals"); my @col = split(/\,/, $cols); my @val = split(/\,/, $vals); my $temp; # Test the values comming in. foreach (@val) { $temp += $_; } if($temp != 100){ print $q->header; print "<h1>Error: The values must add up to 100</h1>Your total was +$temp<br>\n"; exit; } if($#col != $#val){ print $q->header; print "<b><h1>Error: Parameters are not balanced</h1></b>"; exit; } #create and display the graph my $graph = new GD::Graph::pie(200,200); my @data = ([@col], [@val]); $graph->set(title => "$title") if($title ne ''); $graph->set_label_font('ARIAL.TTF', 24); $graph->set_value_font('ARIAL.TTF', 24); print $q->header("image/png"); binmode STDOUT; print $graph->plot(\@data)->png;

In reply to CGI pie-graph Maker by BigJoe

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.