<?php 

include_once ("_dirinfo.php");

include_once (PATH_TO_ROOT."init.php");

include (PATH_TO_ROOT."jpgraph/src/jpgraph.php");
include (PATH_TO_ROOT."jpgraph/src/jpgraph_bar.php");

/*$data1y = array(20,80,90,40,60);
$data2y = array(80,20,10,60,40);*/
//$labels = array("total","zavrsetak prodajnog razgovora","prodajni razgovor","Zaposleni - vizuelni\nidentitet i prvi kontakt","Urednost prodajnog prostora");

$graphData =  $_SESSION['mysteryReportGraph'];
foreach ($graphData as $data) {
	if($data['checked'])
	{
		$data1y[] = intval($data['data1y']);
		$data2y[] = intval($data['data2y']);
		$labels[] = $data['gLabel'];
	}
}



// Create the graph. These two calls are always required
$graph = new Graph(870,450,"auto"); 
$graph->SetScale("textlin");

// Create the bar plots
$b1plot = new BarPlot($data1y);
$b1plot->SetFillGradient("#465623","#839F44",GRAD_VER);
$b1plot->value->SetFormat('%01.0f%%');
$b1plot->value->SetFont(FF_ARIAL,FS_BOLD,9);

$b1plot->SetValuePos('center'); 
 
$b1plot->value->SetColor("white");
$b1plot->SetLegend("Postignu&#263;e %");
$b1plot->value->Show();


$b2plot = new BarPlot($data2y);
$b2plot->SetFillGradient("#7D2725","#AD4442",GRAD_VER);
$b2plot->value->SetFormat('%01.0f%%');
$b2plot->value->SetColor("white");
$b2plot->value->SetFont(FF_ARIAL,FS_BOLD,9);
$b2plot->SetLegend("Nedostatak %");
$b2plot->value->Show();
$b2plot->SetValuePos('center');


// Create the grouped bar plot
$gbplot = new AccBarPlot(array($b1plot,$b2plot));
$gbplot->SetWidth(0.6);

$graph->yaxis->SetTextLabelInterval(1);
$graph->yaxis->SetPos('max');
//$graph->yaxis->scale->ticks->Set(10);

$graph->yaxis->SetLabelFormat('%0.0f%%');
$graph->yaxis->SetLabelSide(SIDE_RIGHT);
$graph->yaxis->SetLabelMargin(25);
$graph->yaxis->SetColor('#808080','#222222');

$graph->yaxis->SetTickSide(SIDE_RIGHT);
$graph->yaxis->SetFont(FF_ARIAL,FS_BOLD,9);



$graph->xaxis->SetTickLabels($labels);
$graph->xaxis->SetLabelMargin(8);
$graph->xaxis->SetColor('#808080','#222222');

$graph->xaxis->SetTickSide(SIDE_LEFT);
$graph->xaxis->SetFont(FF_ARIAL,FS_BOLD,10);



$graph->legend->Pos(0.28,0.9);
$graph->legend->SetLayout(LEGEND_HOR);
$graph->legend->SetFont(FF_ARIAL,FS_BOLD,9);
$graph->legend->SetColor('#222222');
$graph->legend->SetReverse();
$graph->legend->SetFillColor('white');
$graph->legend->SetFrameWeight(0);
$graph->legend->SetShadow(false);


// rotate graf
$graph->Set90AndMargin(350,50,10,70);
$graph->SetMarginColor('white');
$graph->SetFrame(true,'white',0);


// ...and add it to the graph
$graph->Add($gbplot);

// Display the graph
$graph->Stroke();


?>