<?php // content="text/plain; charset=utf-8"
include("../utils/phpgraphlib.php");
require_once("../classes/Mysql.php");

$m = new Mysql();
$dataArray_elektrina=array();
  


$dataArray_voda=array();
 
//get data from database
$sql="SELECT * FROM `voda` ORDER BY date DESC";
$result = $m->dotaz($sql) or die('Query failed: ' . mysql_error());
if ($result) {
  //$i = 0;
  while ($row = $m->podejRadek($result)) {
      $temp = date("d",strtotime($row->date));
      $up = $row->m_voda;
      $vysledek = $m->podejRadek($result);
      while(date("d",strtotime($vysledek->date)) == $temp){
         $down = $vysledek->m_voda;
         $date = $vysledek->date;   
         $vysledek = $m->podejRadek($result); 
      }
      $kwh = $up - $down;
      $dataArray_voda[$date]=$kwh;      
  }
}



include('phpgraphlib.php');
$graph = new PHPGraphLib(650, 200);
$graph->addData($dataArray_voda);
$graph->setBarColor('navy');
$graph->setupXAxis(20, 'blue');
$graph->setTitle('Spotreba vody za posledni mesic');
$graph->setTitleColor('black');
$graph->setGridColor('153,204,255');
//$graph->setDataValues(true);
//$graph->setDataValueColor('navy');
//$graph->setGoalLineColor('red');
$graph->createGraph();


?>


