<?php
/*
 *  make the multi-line chart
 */ 
 
// include class file
require('startinclude.php');

include('include/plchart.php'); 


$camara=parametro('camara',0);
$proceso=parametro('proceso',0);
$escala_minima=parametro('escala_minima',-55);
$escala_maxima=parametro('escala_maxima',55);
$rango=parametro('rango',86400); // 24 horas = 1440 minutos * 60 =86400seg
$titulo=parametro('titulo',$camara);


$totalcamaras=0;
$maxima=0;
$minima=0;
$estado=0;
$num_temp=0;

$titulowin=array();
$id_camara=array();
$nsensores=array();
$nombre_sensor=array();
leer_sesion();

$temp=array();
$limite=array();


leer_temperatura($temp,$camara,$maxima,$minima,$estado,$nombre_sensor,$num_temp,$limite);





   
// set the array of source data
// the first array is the descriptions of x coordinate 
leer_estados_historicos($data,$camara,$proceso,$rango);
//$data = apc_fetch("grafico0_1");

/*
$data[0][count($data[0])]=$data[0][count($data[0])-1]+1;
$data["2000"][count($data["2000"])]=rand(0,100);
$data["2001"][count($data["2001"])]=rand(0,100);
$data["2002"][count($data["2002"])]=rand(0,100);
$data["2003"][count($data["2003"])]=rand(0,100);


apc_store("datos_graficos",$data);
*/
// set chart object
$chart = new plchart(); 

//echo var_dump($data["2000"]);
/*
for ($i=0;$i<count($data["2000"]);$i++) {
	$data["2000"][$i]=$data["2000"][$i]*rand();
}
*/
   
// set bgcolor
$chart->setbgcolor(255,255,255);    

// set string for title



// set chartdata



$chart->param_titulo=apc_fetch("grafico_leyenda0_1");



//$chart->setchartdata("line", 1, 800, 600, 100, $data, '');
$chart->setchartdata("line", 1, 800, 600, 100, $data, '');
    
// set title
$chart->settitle($titulo, 10, 0, 200, 50, 'fonts/arial.ttf', 0, 0, 250);

// set description
//$chart->setdesc(650, 100, 100, 300, 0, 10, 0, 'fonts/arial.ttf', 0, 0, 0);
$chart->setdesc(710, 100, 100, 1000, 0, 10, 0, 'fonts/arial.ttf', 0, 0, 0);
     
// set graphics
//$chart->setgraphics(0, 100, 600, 300, 20, 0.05);
$chart->setgraphics(0, 100, 700, 500, 20, 0.05);
    
// output chart
$chart->outputchart();    

// destroy object
unset($chart);
?>