CGIGraph

 view release on metacpan or  search on metacpan

lib/CGI/Graph.pm  view on Meta::CPAN


width and height of grid image and map

=item graph_type I<string>

indicates the type of graph. Currently, only "points" and "bar" are available.

=item zoom_type I<string>

indicates the type of zoom used for bar graphs. The default is "vertical lock",
where the vertical bounds are fixed regardless of zoom factor. Both "unlocked"
modes allow the user to change the upper bound, but the "unlocked int" mode
restricts the upper bound to an integer value.

=item histogram_type I<string>

indicates the type of histogram zoom, either "fixed" or "variable". Fixed zoom
functions similarly to the zoom style of other graph types. Variable zoom will
re-calculate the histogram of the smaller set of data which roughly corresponds
to the area in the view window.

=item dataColor,selectColor,lineColor,windowColor I<[red,green,blue], name, or hexadecimal>

lib/CGI/Graph/Layout.pm  view on Meta::CPAN

                                -default=>['--Unselect--'],
                                -size=>1,
                                -onChange => 'this.form.submit()');
	return $final;
}

sub zoom_type {
	my $self = shift;
	my $final = "bar zoom type<BR>";
	$final.= $self->{CGI}->radio_group(-name=> 'zoom_type',
                                              -values=> ['vertical lock','unlocked int','unlocked'],
                                              -default=> 'vertical lock',
					      -linebreak => 'true',
                                              -onClick=> "this.form.submit()");
	return $final;
}

sub histogram_type {
	my $self = shift;
	my $final = "histogram type<BR>";
	$final.= $self->{CGI}->radio_group(-name=> 'histogram_type',

lib/CGI/Graph/Plot/bars.pm  view on Meta::CPAN

	# use fractions for x min/max
        my ($xc,$yc,$span) = $self->resize();

        my $x_min = sprintf("%.$default{precision}f", 
		($xc-$span/2)/$self->{'divisions'});
        my $x_max = sprintf("%.$default{precision}f", 
		($xc+$span/2)/$self->{'divisions'});

        $y_max = sprintf("%.$default{precision}f", 
		$y_max*($yc+.5)/$self->{'divisions'}) 
		if ($self->{zoom_type}=~/^unlocked/);

	$y_max = ($y_max>1)?int($y_max+.5):1 
		if ($self->{zoom_type} eq 'unlocked int');

	($self->{x_min},$self->{x_max},$self->{y_min},$self->{y_max}) = 
		($x_min,$x_max,0,$y_max);
}

#       
# initializes the graph for the graphMap and drawGraph functions.
#

sub setGraph {

lib/CGI/Graph/Plot/bars.pm  view on Meta::CPAN

        my $yc = ($self->{divisions}-$center[1]+.5);

        # shift center to avoid going out of bounds
        if (($xc-$span/2) < 0) {
                $xc+=(-1*($xc-$span/2));
        }
        elsif (($xc+$span/2) > $self->{divisions}) {
                $xc-= $xc+$span/2-$self->{divisions};
        }

	$yc = $self->{divisions}/2 unless ($self->{zoom_type}=~/^unlocked/);

        # update center in object
        my $center = ($xc+.5).",".($self->{divisions}+1-($yc+.5));
        $self->{center} = $center;

        return ($xc,$yc,$span);
}

#
# adds grid lines to an image, depending on the number of divisions. Also draws

lib/CGI/Graph/Plot/bars.pm  view on Meta::CPAN

        $x2 = $center[0]*$Hinc;
        $y1 = ($center[1]-1)*$Vinc;
        $y2 = $center[1]*$Vinc;
        $image->filledRectangle($x1,$y1,$x2,$y2,$windowColor);

        # determine coordinates for view window and draw it
        $x1 = ($center[0]-.5-$span/2)*$Hinc;
        $x2 = ($center[0]-.5+$span/2)*$Hinc;

        # bar graph does not zoom in with respect to Y axis
        $y1 = ($self->{zoom_type}=~/^unlocked/)?($center[1]-1)*$Vinc:0;
	$y2 = ($self->{grid_height}-1);

        $x2-- if ($x2==$self->{grid_width});
        $y2-- if ($y2==$self->{grid_height});

        $image->rectangle($x1,$y1,$x2,$y2,$windowColor);
        $image->rectangle($x1+1,$y1+1,$x2-1,$y2-1,$windowColor);

        return $image;
}



( run in 0.657 second using v1.01-cache-2.11-cpan-49f99fa48dc )