Ver Mensaje Individual
  #2 (permalink)  
Antiguo 02/05/2011, 10:38
russellhoff
 
Fecha de Ingreso: noviembre-2010
Ubicación: laudio
Mensajes: 61
Antigüedad: 13 años, 5 meses
Puntos: 1
Respuesta: Fatal error: Allowed memory size of 536870912 bytes exhausted (tried to al

fichero graph_historicomsmanio_histogram.php:
Código PHP:
<?php

    
include_once ('../../funciones/funciones_comunes.php');
    include_once(
'../../../jpgraph/jpgraph.php');
    include_once (
'../../../jpgraph/jpgraph_line.php');
    include_once (
'../../../jpgraph/jpgraph_utils.inc.php');
    
    if ( !isset(
$_SESSION) ){
        
crearSesion();
    }
    
    
/* Creamos las variables $fechaInicioUnix y $fechaFinUnix, inicianizandolas con los valores de $_SESSION["estadisticas_fecha_inicio_unix"] y $_SESSION["estadisticas_fecha_fin_unix"] respectivamente */
    
$fechaInicioUnix $_SESSION["estadisticas_fecha_inicio_unix"]; //time() - ( 60 * 24 * 60 * 60 );
    
$fechaFinUnix $_SESSION["estadisticas_fecha_fin_unix"]; //time();
    /* Creamos las variables $fechaInicioUnix y $fechaFinUnix, inicianizandolas con los valores de $_SESSION["estadisticas_fecha_inicio_unix"] y $_SESSION["estadisticas_fecha_fin_unix"] respectivamente */
        
    //echo $fechaInicioUnix . "<br>";
    //echo $fechaFinUnix . "<br>";
    
    
$fechaInicioMysql unixToMySQL($fechaInicioUnix);
    
$fechaFinMysql unixToMySQL($fechaFinUnix);
    
    
//echo $fechaInicioMysql . "<br>";
    //echo $fechaFinMysql . "<br>";
    
    /* Creamos las variables $mesInicio y $anioInicio y las cargamos con los siguientes substrings haciendo uso de estas funciones: 
     * (int) substr($fechaInicioMysql, 5, 2) y (int) substr($fechaInicioMysql, 0, 4), respectivamente */
    
$mesInicio = (int) substr($fechaInicioMysql52);
    
$anioInicio = (int) substr($fechaInicioMysql04);
    
/* Creamos las variables $mesInicio y $anioInicio y las cargamos con los siguientes substrings haciendo uso de estas funciones: 
     * (int) substr($fechaInicioMysql, 5, 2) y (int) substr($fechaInicioMysql, 0, 4), respectivamente */
    
    /* Hacemos una cosa parecida para las variables $mesFin y $anioFin, con lo siguiente:
     * (int) substr($fechaFinMysql, 5, 2) y (int) substr($fechaFinMysql, 0, 4), respectivamente. */
    
$mesFin = (int) substr($fechaFinMysql52);
    
$anioFin = (int) substr($fechaFinMysql04);
    
/* Hacemos una cosa parecida para las variables $mesFin y $anioFin, con lo siguiente:
     * (int) substr($fechaFinMysql, 5, 2) y (int) substr($fechaFinMysql, 0, 4), respectivamente. */
    
    /* Creamos las variables $anioAux y $mesAux, inicianizandolas con los valores/contenidos de 0, $anioInicio y $mesInicio, respectivamente. */
    
$anioAux $anioInicio;
    
$mesAux $mesInicio;
    
/* Creamos las variables $anioAux y $mesAux, inicianizandolas con los valores/contenidos de 0, $anioInicio y $mesInicio, respectivamente. */
    
    
$datosDeBd obtenerNumeroInformesIncidenciasEntre2Fechas($fechaInicioMysql$fechaFinMysql);
    
ini_set('memory_limit','512M');
    if ( 
$datosDeBd != null ){
        
/* Creamos las variables $etiquetas y $datos como arrays vacios */
        
$etiquetas = array();
        
$datos = array();
        
/* Creamos las variables $etiquetas y $datos como arrays vacios */
        
$i 0;
        while ( 
$anioAux <= $anioFin && $mesAux <= $mesFin ){
                
            
//Resolvemos la problematica que ocurre cuando tenemos un numero menor de 10, que solo ocupa una cifra y
            //nos interesa que ocupe 2:
            
if( $mesAux 10 ){
                
/* Creamos la variable $id concatenando los valores de  $anioAux, "-0" y $mesAux */
                
$id $anioAux."-0".$mesAux;
                
/* Creamos la variable $id concatenando los valores de  $anioAux, "-0" y $mesAux */
            
}else{
                
/* Creamos la variable $id concatenando los valores de $anioAux, "-" y $mesAux  */
                
$id $anioAux."-".$mesAux;
                
/* Creamos la variable $id concatenando los valores de $anioAux, "-" y $mesAux  */
            
}
        
            
/* Añadimos al array $etiquetas el contenido de $id */
            
$etiquetas[$i] = $id;
            
/* Añadimos al array $etiquetas el contenido de $id */
            
            
if ( isset($datosDeBd[$id])) {
                
/* Añadimos al array $datos el cotenido de la variable $datosDeBd[$id]["cantidad"] */
                
$datos[$i] = $datosDeBd[$id]["cantidad"];
                
/* Añadimos al array $datos el cotenido de la variable $datosDeBd[$id]["cantidad"] */
            
}else{
                
/* Añadimos al array $datos el valor 0 */
                
$datos[$i] = 0;
                
/* Añadimos al array $datos el valor 0 */
            
}
        
            
/* Aumentamos en una unidad el contenido de $mesAux */
            
$mesAux++;
            
/* Aumentamos en una unidad el contenido de $mesAux */
            
$i++;
            if( 
$mesAux 12 ){
                
/* Restamos un año a $anioAux y $mesAux lo cargamos con 12 */
                
$anioAux--;
                
$mesAux 12;
                
/* Restamos un año a $anioAux y $mesAux lo cargamos con 12 */
            
}
        }
        
        
/* 
         * En este punto ya tenemos los datos preparados.
         * 
         * PERTENECIENTE AL JPGRAPH:
         * 
         */
        //print_r($datos);
        //print_r($etiquetas);
    
        /* Creamos un objeto Graph con tamaño de 600 de ancho y 400 de alto, y lo guardamos en $graph */
        
$graph = new Graph(600,400'auto');  
        
/* Creamos un objeto Graph con tamaño de 600 de ancho y 400 de alto, y lo guardamos en $graph */
      
        
$graph->img->SetMargin(40,40,40,40);
        
$graph->SetScale("textint");/*, 0, 0, $datos[0]-20, $datos[obtenerTamanoTabla($datos)-1]+20);*/
        //$graph->SetY2OrderBack(false);
        //$graph->SetY2Scale("lin",0,90);
    
        /* Creamos un nuevo objeto LinePlot pasandole como parametro $datos y lo guardamos en $lineplot */
        
$lineplot=new LinePlot($datos);//$datosOrdenadosYPreparados);
        /* Creamos un nuevo objeto LinePlot pasandole como parametro $datos y lo guardamos en $lineplot */
    
        
$lineplot->mark->SetType(MARK_X);
    
        
$graph->Add($lineplot);
    
        
$graph->xaxis->SetTitle("Meses"'center');
        
$graph->xaxis->SetTickLabels($etiquetas);
        
$graph->yaxis->SetTitle("Cantidad de informes"'center');
        
//$graph->yaxis->SetTickPositions(array(0,30,60,90,120,150), array(15,45,75,105,135));
        //$graph->SetBox(false);
    
    
 
        
$graph->title->SetFont(FF_FONT1,FS_BOLD);
        
$graph->yaxis->title->SetFont(FF_FONT1,FS_BOLD);
        
$graph->yaxis->title->SetColor("gray");
        
$graph->xaxis->title->SetFont(FF_FONT1,FS_BOLD);
        
$graph->xaxis->title->SetColor("gray");
    
 
        
$graph->yaxis->scale->SetGrace(50,50);
    
        
$lineplot->SetColor("red");
        
$lineplot->SetWeight(4);
        
$graph->yaxis->SetWeight(2);
        
$graph->yaxis->SetColor("red");
        
$graph->xaxis->SetWeight(2);
        
$graph->xaxis->SetColor("green");
        
$graph->SetShadow();
 
        
$graph->title->Set("Historico de sucesos entre: " date("Y-M"$_SESSION["estadisticas_fecha_inicio_unix"]) . " y " date("Y-M"$_SESSION["estadisticas_fecha_fin_unix"]));
    
        
// Display the graph
        
$graph->Stroke();
    }
    
?>