Finance-Quant-Charter

 view release on metacpan or  search on metacpan

lib/Finance/Quant/Charter.pm  view on Meta::CPAN

		
		if($ty[$#ty] < $tx[$#tx]) {
            return 1;
		}else{
		    return 0;
		}
	}
	
	sub plotlines {
		my ($file, $stock, $x, $lines, $y_format) = @_;
		my @legend;
		my ($data, $colors) = ([], []);
		
		$data->[0] = $x;   # x-axis labels
	
		for (0..$#{$lines}) {
			$data->[(1+$_)] = $lines->[$_]->{data};
			$colors->[$_] = $lines->[$_]->{color};
			$legend[$_] = $lines->[$_]->{name};
		}
	
		my $graph = GD::Graph::lines->new(1024,420);
		$graph->set (dclrs => $colors) or die $graph->error;
		$graph->set_legend(@legend) or die $graph->error;
		$graph->set (legend_placement => 'BC') or die $graph->error;
		$graph->set(y_number_format => $y_format) if $y_format;
		
		my $skipp = int(0.2*scalar(@{$data->[0]})) unless(!$data->[0]);
		
		$skipp = 0 unless($skipp);
		
		$graph->set (
			title => "stock: $stock",
			boxclr => 'black',
			bgclr => 'dgray',
			axislabelclr => 'white',
			legendclr => 'white',
			textclr => 'white',
			r_margin => 20,
			tick_length => -4,
			y_long_ticks => 1,
			axis_space => 10,
			x_labels_vertical => 1,
			x_label_skip => $skipp
		) or return;# die $graph->error;
		my $gd = $graph->plot($data) or return;# die $graph->error;
	



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