<?php

//chdir ('../');
include_once( '../ofc-library/open-flash-chart.php' );
//include_once( '../calculadoras/functions.inc.php' );

class graficos extends graph{

        function graficos($largura=400, $altura=250)
        {
                parent::graph();     
                
                $this->bg_colour = '#FFFFFF';
                
                $this->set_width( $largura );
				$this->set_height( $altura );
				//$this->set_output_type('js');
				//$this->title_style = '{font-size: 12px; color: #898989; font-weight:bold}';
				$this->title_style = '{font-size:12px; color: #ffffff; margin: 20px 0px 20px 0px; background-color: #ff6633; padding: 5px 5px 5px 5px;text-align: center;}';
			
				$this->set_x_label_style( 10, '#464646' );
        		$this->set_y_label_style( 10, '#464646' );
        		
        	
				$this->x_axis_colour( '#CCCCCC', '#CCCCCC' );
				$this->y_axis_colour( '#CCCCCC', '#CCCCCC' );   

				$this->y_grid_colour = '#CCCCCC';
				
//y_ticks=5,5,5
//tool_tip=%23x_label%23%3Cbr%3E%23val%23
				
				$this->num_decimals='2';
				//$this->is_fixed_num_decimals_forced='';
				$this->is_decimal_separator_comma='true';
				$this->is_thousand_separator_disabled='true';
				
				

        }
        
        
        function queijo($data, $labels=array() ){
        	
				$cores=array('#ff6633','#33ccff','#7f7f7f','#b3cb35','#7f3fff','#cccccc','#ffe600','#7f3f1f','#000000');
				
        	    $this->pie_values( $data, $labels);
				
				$this->pie(80,'#FFFFFF','{display:none;}');
				
				
				
				$this->pie_slice_colours( $cores );
				
				$this->set_tool_tip( '<br>#x_label#<br>#val#%' );
        }
        
        function colunas($data, $labels=array() ){
        	$bar = new bar_glass( 80, '#ff6633', '#ff6633' );
			//$bar->key( 'Page views', 10 );
			foreach ($data as $coluna)
				$bar->data[]=$coluna;
        	
			$this->data_sets[] = $bar;
        	$this->set_x_labels( $labels);
        				
			$this->set_y_max( max($data) );
			$this->set_y_min( min($data,0) );
			
			$this->set_x_axis_steps(1);
			$this->x_grid_colour = '#FFFFFF';
        	
			$this->set_tool_tip( '<br>#x_label#<br>#val#' );
        }
        
        function colunas_cores($data, $labels=array() ){
        	
        	$cores=array('#ff6633','#33ccff','#7f7f7f','#b3cb35','#7f3fff','#cccccc','#ffe600','#7f3f1f','#000000');
        	
        	$i=0;
        	foreach ($data as $linha){
	        	$bar = new bar_glass( 80, $cores[$i], $cores[$i] );

	        	$label=array_shift($linha);
	        	$bar->key($label, 10);
	        	
	        	foreach ($linha as $coluna)
	        		$bar->data[]=$coluna;
	        		
				$this->data_sets[] = $bar;
				$tempmax[]=max($linha);
				$tempmin[]=min($linha);
				$i++;
        	}
        	$tempmin[]=0;
        	
        	$this->set_y_max( max($tempmax) );
        	$this->set_y_min( min($tempmin) );
        	
        	$this->set_x_labels( $labels);
        	
        	$this->set_x_axis_steps(1);
        	$this->x_grid_colour = '#FFFFFF';
        	
        	$this->set_tool_tip( '<br>#x_label#<br>#val#' );
        }
        
        
        function linha($data, $labels=array() ){
        	$cores=array('#ff6633','#33ccff','#7f7f7f','#b3cb35','#7f3fff','#cccccc','#ffe600','#7f3f1f','#000000');
        	
        	$this->set_data( $data );
        	$this->line( 4, $cores[0], "", 18 );
        	
        	$this->set_y_max( max($data) );
        	$this->set_y_min( min($data) );
					
			$this->set_x_labels( $labels);
			
			$tamPontos=sizeof($data);
			$nrSteps=round($tamPontos/5);
			$this->set_x_axis_steps($nrSteps);
			
		    $this->x_grid_colour = '#CCCCCC';
			
			$this->set_tool_tip( '<br>#x_label#<br>#val#' );
        }
        
        function linha_varios($data, $labels=array() ){
        	$cores=array('#ff6633','#33ccff','#7f7f7f','#b3cb35','#7f3fff','#cccccc','#ffe600','#7f3f1f','#000000');
        	
        	
        	$i=0;
        	foreach ($data as $linha){
				
	        	$label=array_shift($linha);
        		$this->set_data( $linha );
	        	$this->line( 4, $cores[$i], $label, 10 );

				$tempmax[]=max($linha);
				$tempmin[]=min($linha);
				$i++;
        	}
        	$tempmin[]=0;
        	
        	$this->set_y_max( max($tempmax) );
        	$this->set_y_min( min($tempmin) );
					
			$this->set_x_labels( $labels);
			
			$tamPontos=sizeof($data[0]);
			$nrSteps=round($tamPontos/5);
			$this->set_x_axis_steps($nrSteps);
			
		    $this->x_grid_colour = '#CCCCCC';
			
			$this->set_tool_tip( '<br>#x_label#<br>#val#' );
        }
       
}


?>