package bargraph;

sub draw {
    local(@foo)=@_;
    @values = @foo[0..(($#foo+1)/2)-1];
    @names = @foo[(($#foo+1)/2)..$#foo];
    
    print("$#values Values and $#names names\n");
    return(-1) if $#values != $#names;

    for $_ (@names) {
	if(length($_)>$max){
	    $max=length($_);
	}
    }
    for $_ (@values) {
	if($_ >$maxv){
	    $maxv=$_;
	}
    }
    print("Maxv is $maxv\n");
    
    for $i (0..$#values){
	$ticks = '-' x (65 * $values[$i] / $maxv);
	$h = $names[$i] . (' ' x (($max+1) - length($names[$i])));
	print("$h $ticks ($values[$i])\n") unless length($ticks) == 0;
#	print("$h $values[$i]\n");
    }
}

1;
