';
if (self::$dataFileStatus == FILE_STATUS_NO_DATA
|| self::$dataFileStatus == FILE_STATUS_NO_FILE
|| self::$dataFileStatus == FILE_STATUS_SRV_DELETED){
$noDataAlert ="noDataAlert";
} else {
$noDataAlert ="";
}
if (self::$isArchive != true && self::$publicChart != true) {
self::displayBottomSettings($noDataAlert);
}
// Shranimo spremenjene nastavitve v bazo
SurveyUserSession::saveData(self::$sessionData, 'charts');
} // end if else ($_headFileName == null)
if (self::$returnChartAsHtml == false) {
ob_flush(); flush();
return;
} else {
$result = ob_get_clean();
ob_flush(); flush();
return $result;
}
}
static function displayCharts(){
global $lang;
global $site_path;
# polovimo frekvence
SurveyAnalysis::getFrequencys();
$vars_count = count(SurveyAnalysis::$_FILTRED_VARIABLES);
foreach (SurveyAnalysis::$_HEADERS AS $spid => $spremenljivka) {
# preverjamo ali je meta
if (isset($spremenljivka['tip']) && ($spremenljivka['tip'] != 'm'
&& in_array($spremenljivka['tip'], SurveyAnalysis::$_FILTRED_TYPES ))
&& (!isset($_spid) || (isset($_spid) && $_spid == $spid))
&& $spremenljivka['tip'] != 5) {
# ali imamo sfiltrirano spremenljivko
if ($vars_count == 0 || ($vars_count > 0 && isset(SurveyAnalysis::$_FILTRED_VARIABLES[$spid]) ) ) {
// preberemo ze nastavljene nastavitve posameznega grafa iz sessiona
if(isset(self::$sessionData[$spid][self::$current_loop]) && self::$current_loop != 'undefined'){
self::$settings = self::$sessionData[$spid][self::$current_loop];
}
else if(isset(self::$sessionData[$spid]) && self::$current_loop == 'undefined'){
self::$settings = self::$sessionData[$spid];
}
// nastavimo default nastavitve za vsak graf
else{
self::$settings = self::getDefaultSettings();
// ce imamo numeric dropdown popravimo default graf na skupinski
if($spremenljivka['tip'] == 3 && self::checkDropdownNumeric($spid)){
self::$settings['type'] = 5;
}
else{
// Ce imamo radio tip in manj kot 5 variabel in numeric oz 2 variabli - po defaultu prikazemo piechart
$vars = (isset($spremenljivka['options']) && is_countable($spremenljivka['options'])) ? count($spremenljivka['options']) : 0;
if( ($spremenljivka['tip'] == 1 || $spremenljivka['tip'] == 3) && (($vars < 5 && $spremenljivka['skala'] == 1) || $vars < 3) ){
self::$settings['type'] = 2;
}
// Ce imamo radio tip in vec kot 20 variabel -> po defaultu ne prikazujemo praznih
$vars = (isset($spremenljivka['options']) && is_countable($spremenljivka['options'])) ? count($spremenljivka['options']) : 0;
if( ($spremenljivka['tip'] == 1 || $spremenljivka['tip'] == 3) && $vars > 20 ){
self::$settings['hideEmptyVar'] = 1;
}
}
// Ce imamo checkbox ga po defaultu uredimo po velikosti
if($spremenljivka['tip'] == 2){
self::$settings['sort'] = 1;
}
// Ce imamo checkbox in vec kot 20 variabel -> po defaultu ne prikazujemo praznih
$vars = (is_countable($spremenljivka['grids'][0]['variables'])) ? count($spremenljivka['grids'][0]['variables']) : 0;
if( $spremenljivka['tip'] == 2 && $vars > 20 ){
self::$settings['hideEmptyVar'] = 1;
}
// Ce imamo multigrid ali multicheckbox in vec kot 20 variabel -> po defaultu ne prikazujemo praznih
$vars = (is_countable($spremenljivka['grids'])) ? count($spremenljivka['grids']) : 0;
if( ($spremenljivka['tip'] == 6 || $spremenljivka['tip'] == 16) && $vars > 20 ){
self::$settings['hideEmptyVar'] = 1;
}
// Ce imamo semanticni diferencial po defaultu prikazemo vertikalno crto
$vars = (isset($spremenljivka['options']) && is_countable($spremenljivka['options'])) ? count($spremenljivka['options']) : 0;
if($spremenljivka['tip'] == 6 && isset($spremenljivka['enota']) && $spremenljivka['enota'] == 1){
self::$settings['type'] = 6;
}
// Ce imamo mg tip in manj kot 4 gridov po defaultu prikazemo strukturne stolpce
elseif($spremenljivka['tip'] == 6 && $vars < 4 && $spremenljivka['enota'] != 3){
self::$settings['type'] = 2;
}
// Ce imamo MG vedno sortiramo po povprecijh razen ce imamo semanicni diferencial z 1 variablo
$vars = (is_countable($spremenljivka['grids'])) ? count($spremenljivka['grids']) : 0;
if($spremenljivka['tip'] == 6 && ($vars != 1 || $spremenljivka['enota'] != 1)){
self::$settings['sort'] = 1;
}
// Pri multigridu imamo default obrnjene gride/variable ???
/*if( $spremenljivka['tip'] == 6 ){
self::$settings['rotate'] = 1;
}*/
// pri number po defaultu prikazemo legendo
if($spremenljivka['tip'] == 7 || $spremenljivka['tip'] == 22){
self::$settings['show_legend'] = 1;
}
// Ce imamo razvrscanje ga po defaultu uredimo po velikosti
if($spremenljivka['tip'] == 17){
self::$settings['sort'] = 1;
}
// Vsota ima po novem default hor. stolpce
if($spremenljivka['tip'] == 18)
self::$settings['type'] = 2;
// Ce imamo multinumber in samo en grid po defaultu prikazemo stolpce in zarotiramo grids/vars
$vars = $spremenljivka['grids']['0']['cnt_vars'];
if( $spremenljivka['tip'] == 20 && $vars == 1 ){
self::$settings['type'] = 1;
self::$settings['rotate'] = 1;
}
}
// Spremenimo default alignment vseh tabel ce imamo vklopljeno levo poravnavo
$chartTableAlign = SurveyDataSettingProfiles :: getSetting('chartTableAlign');
if($chartTableAlign == 1){
//popravimo tabele za other
self::$settings['otherType'] = 1;
//popravimo se vse ostale tabele
if(in_array($spremenljivka['tip'], array(19,21,4))){
self::$settings['show_legend'] = 1;
}
}
else{
//popravimo tabele za other
self::$settings['otherType'] = 0;
//popravimo se vse ostale tabele
if(in_array($spremenljivka['tip'], array(19,21,4))){
self::$settings['show_legend'] = 0;
}
}
# prikazujemo v odvisnosti od kategorije spremenljivke
switch ($spremenljivka['tip']) {
case 1: # radio
case 3: # dropdown
self::displayRadioChart($spid, self::$settings);
break;
case 2: #checkbox
self::displayCheckboxChart($spid, self::$settings);
break;
case 6: # multigrid
// dvojna tabela
if(isset($spremenljivka['enota'])&&$spremenljivka['enota'] == 3)
self::displayDoubleMultigridChart($spid, self::$settings);
else
self::displayMultigridChart($spid, self::$settings);
break;
case 7: # število
case 22: # compute
self::displayNumberChart($spid, self::$settings);
break;
case 8: # datum
self::displayDateChart($spid, self::$settings);
break;
case 25: # kvota
break;
case 16: # multicheckbox
self::displayMulticheckboxChart($spid, self::$settings);
break;
case 17: # razvrščanje
self::displayRankingChart($spid, self::$settings);
break;
case 20: # multi number
self::displayMultinumberChart($spid, self::$settings);
break;
case 18: # vsota
self::displayVsotaChart($spid, self::$settings);
break;
case 4: # text
self::frequencyVertical($spid);
break;
case 5: # nagovor
/*if(self::$view == 0)
SurveyAnalysis::sumNagovor($spid,'sums');*/
break;
case 19: # multitext
self::sumMultiText($spid);
break;
case 21: # besedilo*
if ($spremenljivka['cnt_all'] == 1) {
// če je enodimenzionalna prikažemo kot frekvence
// predvsem zaradi vprašanj tipa: language, email...
self::frequencyVertical($spid);
} else {
self::frequencyVertical($spid);
}
break;
case 27:
# heatmap
SurveyAnalysis::heatmapGraph($spid,'sums',true, true);
break;
default:
break;
}
//echo ''.NEW_LINE;
}
} // end if $spremenljivka['tip'] != 'm'
} // end foreach self::$_HEADERS
}
static function displaySingle($spid){
global $site_path;
global $lang;
// Ce delamo arhiv iz custom reporta ne izvajamo ob_starta in ob_get_clean
$archiveFromCReport = (($_GET['a'] == 'submitArchiveAnaliza' || $_GET['a'] == 'createArchiveBeforeEmail') && $_POST['podstran'] == 'analysis_creport') ? true : true;
# zakeširamo vsebino, in jo nato po potrebi zapišpemo v html
if (self::$returnChartAsHtml != false && $archiveFromCReport == false) {
ob_start();
}
// prikazemo nastavitve
/*self::displaySettings();
echo " \n";
echo " \n";*/
# preberemo header
if (self::$headFileName !== null ) {
echo '
';
self::displayExportIcons($spid, $hide_button=true);
$vars_count = count(SurveyAnalysis::$_FILTRED_VARIABLES);
$spremenljivka = isset(SurveyAnalysis::$_HEADERS[$spid])?SurveyAnalysis::$_HEADERS[$spid]:array();
SurveyAnalysis::getFrequencys();
# preverjamo ali je meta
if ((isset($spremenljivka['tip']) && $spremenljivka['tip'] != 'm'
&& in_array($spremenljivka['tip'], SurveyAnalysis::$_FILTRED_TYPES ))
&& (!isset($_spid) || (isset($_spid) && $_spid == $spid))
&& $spremenljivka['tip'] != 5) {
# ali imamo sfiltrirano spremenljivko
if ($vars_count == 0 || ($vars_count > 0 && isset(SurveyAnalysis::$_FILTRED_VARIABLES[$spid]) ) ) {
echo '
';
//div za pozicijo popupa
echo '';
// defult nastavitve posameznega grafa
if(isset(self::$sessionData[$spid])){
self::$settings = self::$sessionData[$spid];
}
else{
self::$settings = self::getDefaultSettings();
// Ce imamo radio tip in manj kot 5 variabel po defaultu prikazemo piechart
$vars = count($spremenljivka['options']);
if( ($spremenljivka['tip'] == 1 || $spremenljivka['tip'] == 3) && $vars < 5 && $spremenljivka['skala'] == 1){
self::$settings['type'] = 2;
}
// Ce imamo mg tip in manj kot 5 variabel po defaultu prikazemo en strukturni stolpec
/*$vars = $spremenljivka['cnt_all'];
if( ($spremenljivka['tip'] == 6) && $vars < 5 ){
self::$settings['type'] = 2;
}*/
// Ce imamo semanticni diferencial po defaultu prikazemo vertikalno crto
if($spremenljivka['tip'] == 6 && isset($spremenljivka['enota']) && $spremenljivka['enota'] == 1){
self::$settings['type'] = 6;
}
// Ce imamo mg tip in manj kot 5 gridov po defaultu prikazemo strukturne stolpce
elseif($spremenljivka['tip'] == 6 && $vars < 5 && $spremenljivka['enota'] != 3){
self::$settings['type'] = 2;
}
// Vsota ima po novem default hor. stolpce
if($spremenljivka['tip'] == 18)
self::$settings['type'] = 2;
// Ce imamo multinumber in samo en grid po defaultu prikazemo stolpce in zarotiramo grids/vars
$vars = $spremenljivka['grids']['0']['cnt_vars'];
if( $spremenljivka['tip'] == 20 && $vars == 1 ){
self::$settings['type'] = 1;
self::$settings['rotate'] = 1;
}
}
// Spremenimo default alignment vseh tabel ce imamo vklopljeno levo poravnavo
$chartTableAlign = SurveyDataSettingProfiles :: getSetting('chartTableAlign');
if($chartTableAlign == 1){
//popravimo tabele za other
self::$settings['otherType'] = 1;
//popravimo se vse ostale tabele
if(in_array($spremenljivka['tip'], array(19,21,4))){
self::$settings['show_legend'] = 1;
}
}
else{
//popravimo tabele za other
self::$settings['otherType'] = 0;
//popravimo se vse ostale tabele
if(in_array($spremenljivka['tip'], array(19,21,4))){
self::$settings['show_legend'] = 0;
}
}
# prikazujemo v odvisnosti od kategorije spremenljivke
switch ($spremenljivka['tip']) {
case 1: # radio
case 3: # dropdown
self::displayRadioChart($spid, self::$settings);
break;
case 2: #checkbox
self::displayCheckboxChart($spid, self::$settings);
break;
case 6: # multigrid
// dvojna tabela
if(isset($spremenljivka['enota'])&&$spremenljivka['enota'] == 3)
self::displayDoubleMultigridChart($spid, self::$settings);
else
self::displayMultigridChart($spid, self::$settings);
break;
case 7: # število
case 22: # compute
self::displayNumberChart($spid, self::$settings);
break;
case 8: # datum
self::displayDateChart($spid, self::$settings);
break;
case 25: # kvota
//self::displayNumberChart($spid, self::$settings);
break;
case 16: # multicheckbox
self::displayMulticheckboxChart($spid, self::$settings);
break;
case 17: # razvrščanje
self::displayRankingChart($spid, self::$settings);
break;
case 20: # multi number
self::displayMultinumberChart($spid, self::$settings);
//self::frequencyVertical($spid);
break;
case 18: # vsota
self::displayVsotaChart($spid, self::$settings);
break;
case 4: # text
//SurveyAnalysis::sumTextVertical($spid,'sums');
self::frequencyVertical($spid);
break;
case 5: # nagovor
/*if(self::$view == 0)
SurveyAnalysis::sumNagovor($spid,'sums');*/
break;
case 19: # multitext
//SurveyAnalysis::sumMultiText($spid,'sums');
//self::frequencyVertical($spid);
self::sumMultiText($spid);
break;
case 21: # besedilo*
if (isset($spremenljivka['cnt_all'])&&$spremenljivka['cnt_all'] == 1) {
// če je enodimenzionalna prikažemo kot frekvence
// predvsem zaradi vprašanj tipa: language, email...
//SurveyAnalysis::sumTextVertical($spid,'sums');
self::frequencyVertical($spid);
} else {
//SurveyAnalysis::sumMultiText($spid,'sums');
self::frequencyVertical($spid);
}
break;
default:
break;
}
echo '
'.NEW_LINE;
// Shranimo spremenjene nastavitve v bazo
SurveyUserSession::saveData(self::$sessionData, 'charts');
}
} // end if $spremenljivka['tip'] != 'm'
echo '
';
//self::displayBottomSettings();
} // end if else ($_headFileName == null)
if (self::$returnChartAsHtml == false) {
ob_flush(); flush();
return;
}
else {
if($archiveFromCReport == false){
$result = ob_get_clean();
ob_flush(); flush();
return $result;
}
}
}
/**
* Izrise graf za posamezno spremenljivko
*/
static function displayRadioChart($spid, $settings, $refresh=0){
global $site_path;
global $lang;
$spremenljivka = SurveyAnalysis::$_HEADERS[$spid];
// Ce smo ravnokar preklopili na pieChart vklopimo sortiranje
if(self::$current_loop != 'undefined'){
if((self::$sessionData[$spid][self::$current_loop]['type'] != 2 && $settings['type'] == 2) || (self::$sessionData[$spid][self::$current_loop]['type'] != 8 && $settings['type'] == 8)){
$settings['sort'] = 1;
self::$settings['sort'] = 1;
}
}
else{
if(!isset(self::$sessionData[$spid]['type']) || (self::$sessionData[$spid]['type'] != 2 && $settings['type'] == 2) || (self::$sessionData[$spid]['type'] != 8 && $settings['type'] == 8)){
$settings['sort'] = 1;
self::$settings['sort'] = 1;
}
}
// popravimo nastavitve za numeric dropdown
if(self::$current_loop != 'undefined'){
if($spremenljivka['tip'] == 3 && self::checkDropdownNumeric($spid)){
// Ce smo ravnokar preklopili na linijski - po skupinah imamo default vse intervale
if(self::$sessionData[$spid][self::$current_loop]['type'] != 7 && $settings['type'] == 7 ){
$settings['interval'] = -1;
self::$settings['interval'] = -1;
}
// Ce smo ravnokar preklopili na navaden - po skupinah imamo default 10 intervalov
if(self::$sessionData[$spid][self::$current_loop]['type'] < 5 && $settings['type'] > 4){
$settings['interval'] = 10;
self::$settings['interval'] = 10;
}
}
}
else{
if($spremenljivka['tip'] == 3 && self::checkDropdownNumeric($spid)){
// Ce smo ravnokar preklopili na linijski - po skupinah imamo default vse intervale
if(self::$sessionData[$spid]['type'] != 7 && $settings['type'] == 7 ){
$settings['interval'] = -1;
self::$settings['interval'] = -1;
}
// Ce smo ravnokar preklopili na navaden - po skupinah imamo default 10 intervalov
if(self::$sessionData[$spid]['type'] < 5 && $settings['type'] > 4){
$settings['interval'] = 10;
self::$settings['interval'] = 10;
}
}
}
// Popravimo pri preklopu na povprecje - prikazujemo notranje vrednosti in izklopimo prikaz povprecja
if((!isset(self::$sessionData[$spid]['type']) || self::$sessionData[$spid]['type'] != 9) && $settings['type'] == 9){
$settings['barLabel'] = 1;
self::$settings['barLabel'] = 1;
$settings['show_avg'] = 0;
self::$settings['show_avg'] = 0;
}
// Napolnimo podatke za graf
$DataSet = self::getDataSet($spid, $settings);
// nimamo nobenih podatkov in imamo vklopljeno opcijo da ne prikazujemo praznih grafov - vrnemo 0
if($DataSet == 0){
self::displayEmptyWarning($spid);
return;
}
// ni variabel v vprasanju preskocimo graf
if($DataSet == -1){
return;
}
echo '
';
//div za pozicijo popupa
echo '';
// Cache
$Cache = new pCache(dirname(__FILE__).'/../../pChart/Cache/');
$ID = self::generateChartId($spid, $settings, $DataSet->GetNumerus());
//$Cache->GetFromCache($ID,$DataSet->GetData());
// Ce se nimamo zgeneriranega grafa - ali ce refreshamo grafe
$refresh = (isset($_GET['refresh'])) ? $_GET['refresh'] : $refresh;
if( (!$Cache->isInCache($ID, $DataSet->GetData())) || $refresh == 1 ){
switch($settings['type']){
// Horizontalni stolpci
case 0:
// Horizontalni stolpci - numeric dropdown
case 5:
// Horizontalen stolpec - povprecje
case 9:
$Test = self::createHorBars($DataSet, $spremenljivka);
break;
// Navpicni stolpci
case 1:
// Navpicni stolpci - numeric dropdown
case 6:
$Test = self::createVerBars($DataSet, $spremenljivka);
break;
// Pie chart
case 2:
$Test = self::createPie($DataSet, $spremenljivka, $settings['show_legend']);
break;
// 3D Pie chart
case 8:
$Test = self::create3DPie($DataSet, $spremenljivka, $settings['show_legend']);
break;
// Sestavljeni stolpec - horizontalen
case 3:
$Test = self::createHorStructBars($DataSet, $spremenljivka);
break;
// Sestavljeni stolpec - vertikalen
case 4:
$Test = self::createVerStructBars($DataSet, $spremenljivka);
break;
// Linijski graf - numeric dropdown
case 7:
case 22:
$Test = self::createLine($DataSet, $spremenljivka);
break;
}
// Shranimo v cache
$Cache->WriteToCache($ID,$DataSet->GetData(),$Test);
}
// dobimo ime slike c cache-u
$imgName = $Cache->GetHash($ID,$DataSet->GetData());
if (self::$isArchive == false) {
$imgPath = 'pChart/Cache/'.$imgName;
} else {
$imgPath = SAA_FOLDER.'/pChart/'.self::$anketa.'_'.self::$chartArchiveTime.'_'.$imgName;
copy('pChart/Cache/'.$imgName, $imgPath);
}
$imgUrl = self::$baseImageUrl . $imgPath;
// zapisemo ime slike v session za izvoze
$settings['name'] = $imgName;
if(!is_countable(SurveyAnalysis::$_LOOPS) || count(SurveyAnalysis::$_LOOPS) == 0)
self::$sessionData[$spid] = $settings;
else
self::$sessionData[$spid][SurveyAnalysis::$_CURRENT_LOOP['cnt']] = $settings;
// Naslov posameznega grafa
$stevilcenje = (self::$numbering == 1 ? $spremenljivka['variable'].' - ' : '');
$title = $spremenljivka['edit_graf'] == 0 ? $spremenljivka['naslov'] : $spremenljivka['naslov_graf'];
echo '
';
// ce imamo vklopljen nuimerus pod grafom
if(SurveyDataSettingProfiles :: getSetting('chartNumerusText') == 3)
self::displayBottomChartInfo($DataSet, $spremenljivka);
if (self::$returnChartAsHtml == false) {
flush(); ob_flush();
}
echo '
';
}
static function displayDateChart($spid, $settings, $refresh=0){
global $site_path;
global $lang;
$spremenljivka = SurveyAnalysis::$_HEADERS[$spid];
// Napolnimo podatke za graf
$DataSet = self::getDataSet($spid, $settings);
// nimamo nobenih podatkov in imamo vklopljeno opcijo da ne prikazujemo praznih grafov - vrnemo 0
if($DataSet == 0){
self::displayEmptyWarning($spid);
return;
}
// ni variabel v vprasanju preskocimo graf
if($DataSet == -1){
return;
}
echo '
';
//div za pozicijo popupa
echo '';
// Cache
$Cache = new pCache(dirname(__FILE__).'/../../pChart/Cache/');
$ID = self::generateChartId($spid, $settings, $DataSet->GetNumerus());
//$Cache->GetFromCache($ID,$DataSet->GetData());
// Ce se nimamo zgeneriranega grafa
$refresh = (isset($_GET['refresh'])) ? $_GET['refresh'] : $refresh;
if( (!$Cache->isInCache($ID, $DataSet->GetData())) || $refresh == 1 ){
switch($settings['type']){
// Horizontalni stolpci - po skupinah ali navadno
case 0:
case 3:
$Test = self::createHorBars($DataSet, $spremenljivka);
break;
// Vertikalni stolpci - po skupinah ali navadno
case 1:
case 4:
$Test = self::createVerBars($DataSet, $spremenljivka);
break;
// Line chart
case 2:
$Test = self::createLine($DataSet, $spremenljivka);
break;
}
// Shranimo v cache
$Cache->WriteToCache($ID,$DataSet->GetData(),$Test);
}
// dobimo ime slike c cache-u
$imgName = $Cache->GetHash($ID,$DataSet->GetData());
if (self::$isArchive == false) {
$imgPath = 'pChart/Cache/'.$imgName;
} else {
$imgPath = SAA_FOLDER.'/pChart/'.self::$anketa.'_'.self::$chartArchiveTime.'_'.$imgName;
copy('pChart/Cache/'.$imgName, $imgPath);
}
$imgUrl = self::$baseImageUrl . $imgPath;
// zapisemo ime slike v session za izvoze
$settings['name'] = $imgName;
if(!is_countable(SurveyAnalysis::$_LOOPS) || count(SurveyAnalysis::$_LOOPS) == 0)
self::$sessionData[$spid] = $settings;
else
self::$sessionData[$spid][SurveyAnalysis::$_CURRENT_LOOP['cnt']] = $settings;
// Naslov posameznega grafa
$stevilcenje = (self::$numbering == 1 ? $spremenljivka['variable'].' - ' : '');
$title = $spremenljivka['edit_graf'] == 0 ? $spremenljivka['naslov'] : $spremenljivka['naslov_graf'];
echo '
';
}
static function displayDoubleMultigridChart($spid, $settings, $refresh=0){
global $site_path;
global $lang;
$spremenljivka = SurveyAnalysis::$_HEADERS[$spid];
// Napolnimo podatke za graf
$DataSet = self::getDataSet($spid, $settings);
// nimamo nobenih podatkov in imamo vklopljeno opcijo da ne prikazujemo praznih grafov - vrnemo 0
if($DataSet == 0){
self::displayEmptyWarning($spid);
return;
}
// ni variabel v vprasanju preskocimo graf
if($DataSet == -1){
return;
}
echo '
';
//div za pozicijo popupa
echo '';
// Cache
$Cache = new pCache(dirname(__FILE__).'/../../pChart/Cache/');
$ID = self::generateChartId($spid, $settings, $DataSet->GetNumerus());
//$Cache->GetFromCache($ID,$DataSet->GetData());
// Ce se nimamo zgeneriranega grafa
$refresh = (isset($_GET['refresh'])) ? $_GET['refresh'] : $refresh;
if( (!$Cache->isInCache($ID, $DataSet->GetData())) || $refresh == 1 ){
switch($settings['type']){
// Horizontal chart
case 0:
$Test = self::createHorBars($DataSet, $spremenljivka, $legend=1, $settings['noFixedScale']);
break;
// Vertical chart
case 1:
$Test = self::createVerBars($DataSet, $spremenljivka, $legend=1, $settings['noFixedScale']);
break;
// Line chart
case 2:
$Test = self::createLine($DataSet, $spremenljivka, $legend=1, $settings['noFixedScale']);
break;
// Vertical line chart
case 3:
$Test = self::createVerLine($DataSet, $spremenljivka, $legend=1, $settings['noFixedScale']);
break;
// Radar chart
case 4:
$Test = self::createRadar($DataSet, $spremenljivka, $legend=1, $settings['noFixedScale']);
break;
}
// Shranimo v cache
$Cache->WriteToCache($ID,$DataSet->GetData(),$Test);
}
// dobimo ime slike c cache-u
$imgName = $Cache->GetHash($ID,$DataSet->GetData());
if (self::$isArchive == false) {
$imgPath = 'pChart/Cache/'.$imgName;
} else {
$imgPath = SAA_FOLDER.'/pChart/'.self::$anketa.'_'.self::$chartArchiveTime.'_'.$imgName;
copy('pChart/Cache/'.$imgName, $imgPath);
}
$imgUrl = self::$baseImageUrl . $imgPath;
// zapisemo ime slike v session za izvoze
$settings['name'] = $imgName;
if(!is_countable(SurveyAnalysis::$_LOOPS) || count(SurveyAnalysis::$_LOOPS) == 0)
self::$sessionData[$spid] = $settings;
else
self::$sessionData[$spid][SurveyAnalysis::$_CURRENT_LOOP['cnt']] = $settings;
// Naslov posameznega grafa
$stevilcenje = (self::$numbering == 1 ? $spremenljivka['variable'].' - ' : '');
$title = $spremenljivka['edit_graf'] == 0 ? $spremenljivka['naslov'] : $spremenljivka['naslov_graf'];
echo '
';
// ce imamo vklopljen nuimerus pod grafom
if(SurveyDataSettingProfiles :: getSetting('chartNumerusText') == 3)
self::displayBottomChartInfo($DataSet, $spremenljivka);
if (self::$returnChartAsHtml == false) {
flush(); ob_flush();
}
echo '
';
}
static function displayRankingChart($spid, $settings, $refresh=0){
global $site_path;
global $lang;
$spremenljivka = SurveyAnalysis::$_HEADERS[$spid];
// Napolnimo podatke za graf
$DataSet = self::getDataSet($spid, $settings);
// nimamo nobenih podatkov in imamo vklopljeno opcijo da ne prikazujemo praznih grafov - vrnemo 0
if($DataSet == 0){
self::displayEmptyWarning($spid);
return;
}
// ni variabel v vprasanju preskocimo graf
if($DataSet == -1){
return;
}
echo '
';
//div za pozicijo popupa
echo '';
// Cache
$Cache = new pCache(dirname(__FILE__).'/../../pChart/Cache/');
$ID = self::generateChartId($spid, $settings, $DataSet->GetNumerus());
//$Cache->GetFromCache($ID,$DataSet->GetData());
// Ce se nimamo zgeneriranega grafa
$refresh = (isset($_GET['refresh'])) ? $_GET['refresh'] : $refresh;
if( (!$Cache->isInCache($ID, $DataSet->GetData())) || $refresh == 1 ){
switch($settings['type']){
// Povprecja
case 0:
$Test = self::createHorBars($DataSet, $spremenljivka, $legend=0, $settings['noFixedScale']/*$fixedScale=1*/);
break;
// Sestavljeni stolpci - navpicni
case 1:
$Test = self::createHorStructBars($DataSet, $spremenljivka);
break;
// Sestavljeni stolpci - vodoravni
case 2:
$Test = self::createVerStructBars($DataSet, $spremenljivka);
break;
}
// Shranimo v cache
$Cache->WriteToCache($ID,$DataSet->GetData(),$Test);
}
// dobimo ime slike c cache-u
$imgName = $Cache->GetHash($ID,$DataSet->GetData());
if (self::$isArchive == false) {
$imgPath = 'pChart/Cache/'.$imgName;
} else {
$imgPath = SAA_FOLDER.'/pChart/'.self::$anketa.'_'.self::$chartArchiveTime.'_'.$imgName;
copy('pChart/Cache/'.$imgName, $imgPath);
}
$imgUrl = self::$baseImageUrl . $imgPath;
// zapisemo ime slike v session za izvoze
$settings['name'] = $imgName;
if(!is_countable(SurveyAnalysis::$_LOOPS) || count(SurveyAnalysis::$_LOOPS) == 0)
self::$sessionData[$spid] = $settings;
else
self::$sessionData[$spid][SurveyAnalysis::$_CURRENT_LOOP['cnt']] = $settings;
// Naslov posameznega grafa
$stevilcenje = (self::$numbering == 1 ? $spremenljivka['variable'].' - ' : '');
$title = $spremenljivka['edit_graf'] == 0 ? $spremenljivka['naslov'] : $spremenljivka['naslov_graf'];
echo '
';
// ce imamo vklopljen nuimerus pod grafom
if(SurveyDataSettingProfiles :: getSetting('chartNumerusText') == 3)
self::displayBottomChartInfo($DataSet, $spremenljivka);
if (self::$returnChartAsHtml == false) {
flush(); ob_flush();
}
echo '
';
}
static function displayMultinumberChart($spid, $settings, $refresh=0){
global $site_path;
global $lang;
$spremenljivka = SurveyAnalysis::$_HEADERS[$spid];
// Napolnimo podatke za graf
$DataSet = self::getDataSet($spid, $settings);
// nimamo nobenih podatkov in imamo vklopljeno opcijo da ne prikazujemo praznih grafov - vrnemo 0
if($DataSet == 0){
self::displayEmptyWarning($spid);
return;
}
// ni variabel v vprasanju preskocimo graf
if($DataSet == -1){
return;
}
echo '
';
//div za pozicijo popupa
echo '';
// Cache
$Cache = new pCache(dirname(__FILE__).'/../../pChart/Cache/');
$ID = self::generateChartId($spid, $settings, $DataSet->GetNumerus());
// Ce se nimamo zgeneriranega grafa
$refresh = (isset($_GET['refresh'])) ? $_GET['refresh'] : $refresh;
if( (!$Cache->isInCache($ID, $DataSet->GetData())) || $refresh == 1 ){
switch($settings['type']){
// Povprecja - radar
case 0:
$Test = self::createRadar($DataSet, $spremenljivka, 1);
break;
// Povprecja - vertikalni stolpci
case 1:
$Test = self::createVerBars($DataSet, $spremenljivka, 1);
break;
// Povprecja - horizontalni stolpci
case 2:
$Test = self::createHorBars($DataSet, $spremenljivka, 1);
break;
// Povprecja - linijski graf
case 3:
$Test = self::createLine($DataSet, $spremenljivka, 1);
break;
}
// Shranimo v cache
$Cache->WriteToCache($ID,$DataSet->GetData(),$Test);
}
// dobimo ime slike c cache-u
$imgName = $Cache->GetHash($ID,$DataSet->GetData());
if (self::$isArchive == false) {
$imgPath = 'pChart/Cache/'.$imgName;
} else {
$imgPath = SAA_FOLDER.'/pChart/'.self::$anketa.'_'.self::$chartArchiveTime.'_'.$imgName;
copy('pChart/Cache/'.$imgName, $imgPath);
}
$imgUrl = self::$baseImageUrl . $imgPath;
// zapisemo ime slike v session za izvoze
$settings['name'] = $imgName;
if(!is_countable(SurveyAnalysis::$_LOOPS) || count(SurveyAnalysis::$_LOOPS) == 0)
self::$sessionData[$spid] = $settings;
else
self::$sessionData[$spid][SurveyAnalysis::$_CURRENT_LOOP['cnt']] = $settings;
// Naslov posameznega grafa
$stevilcenje = (self::$numbering == 1 ? $spremenljivka['variable'].' - ' : '');
$title = $spremenljivka['edit_graf'] == 0 ? $spremenljivka['naslov'] : $spremenljivka['naslov_graf'];
echo '
';
}
// Default nastavitve grafov
public static function getDefaultSettings(){
$colors = array_fill(0, 6, '');
$limits = array('advanced_settings' => 0);
$settings = array(
'type' => 0, // tip grafa
'sort' => 0, // sortiranje po velikosti (0->brez, 1->padajoce, 2->narascajoce)
// ali MG (0->brez, 1->kategorije (trenutno), 2->povprecje, 3->prva ketegorija)
'value_type' => 0, // tip vrednosti (veljavni, frekvence, procenti...)
'base' => 0, // checkbox / multicheckbox osnova (enote / navedbe)
'show_legend' => 0, // prikaz legende
'scale_limit' => 1, // zacni skalo z 0 / z najmanjso vrednostjo pri numericih ALI prikazi desno skalo pri semanticnem diferencialu
'interval' => 10, // stevilo intervalov pri numericih
'min' => '0', // minimalna vrednost po kateri delamo intervale pri numericih (max-min)/interval
'max' => '', // maximalna vrednost po kateri delamo intervale pri numericih (max-min)/interval
'open_up' => 0, // polodprt interval navzgor (ce so vrednosti nad max) pri numericih
'open_down' => 0, // polodprt interval navzdol (ce so vrednosti pod min) pri numericih
'limits' => $limits, // napredne meje number grafov (custom intervali) - ce je $limits['advanced_settings']==1
'radar_type' => 0, // tip radarja (crte / liki)
'radar_scale' => 0, // skala pri radarju (na osi / diagonalno)
'3d_pie' => 0, // tip kroznega grafa (navaden / 3d)
'labelWidth' => 50, // sirina label (50% / 20%)
'barLabel' => 1, // prikaz label v stolpicnih grafih
'barLabelSmall' => 1, // prikaz label pod 5% v stolpicnih grafih (zraven stolpca)
'rotate' => 0, // obrnjeni gridi in variable (pri vseh MG - multiradio, multinumber...)
'colors' => $colors, // custom barve grafa
'show_avg' => -1, // prikaz povprecja na grafu (samo pri ordinalnih radio)
'show_numerus' => 1, // prikaz numerusa na grafu
'otherType' => 0, // poravnava other tabel
'otherFreq' => 0, // izpis frekvenc v other tabeli
'hideEmptyVar' => 0, // ali izpuscamo prazne opcije brez odgovora (ce je nad 20 variabel -> default 1)
'noFixedScale' => 0, // ce izklopimo skalo ki se zacne z 1 (samo pri multigrid povprecjih in ranking povprecjih) ALI prikazi polno skalo pri checkboxu (ce je 1)
);
return $settings;
}
// Zgeneriramo ID grafa za hash
public static function generateChartId($spid, $settings, $numerus){
// ce posebej prizgemo legendo pri pie chartu
if($settings['show_legend'] == 1 && $settings['type'] == 2)
$legend = '_legend';
else
$legend = '';
$ID = self::$anketa.'_chart_'.$spid.'_mv_'.SurveyAnalysis::$missingProfileData['display_mv_type'];
foreach ($settings AS $key => $val) {
if($key == 'colors'){
$ID .= '_colors';
foreach ($val AS $colKey => $color){
$ID .= '_'.$color;
}
}
elseif($key != 'name')
$ID = !is_array($val) ? $ID .= '_'.$key.'_'.$val : $ID .= '_'.$key.'_';
}
$ID .= '_skin_'.self::$skin;
$ID .= '_numerus_'.$numerus.'_numerusText_'.SurveyDataSettingProfiles :: getSetting('chartNumerusText');
$ID .= '_chartAvgText_'.SurveyDataSettingProfiles :: getSetting('chartAvgText');
$ID .= '_pieZeros_'.SurveyDataSettingProfiles :: getSetting('chartPieZeros');
$ID .= '_chartFontSize_'.SurveyDataSettingProfiles :: getSetting('chartFontSize');
$ID .= '_hq_'.self::$quality;
return $ID;
}
// nastavimo prave barve ustrezne skinu
public static function setChartColors($chart, $skin){
// Ce nimmo posebej nastavljenih barv
if(self::$settings['colors'][0] == ''){
// ce je nastavljen globalen custom skin
if(is_numeric($skin)){
$skin = self::getCustomSkin($skin);
$colors = explode('_', $skin['colors']);
$count = 0;
foreach($colors as $color){
$rgb = self::html2rgb($color);
$chart->setColorPalette($count,$rgb[0],$rgb[1],$rgb[2]);
$chart->setColorPalette($count+7,$rgb[0]+50,$rgb[1]+50,$rgb[2]+50);
$chart->setColorPalette($count+14,$rgb[0]+100,$rgb[1]+100,$rgb[2]+100);
$count++;
}
}
// imamo nastavljenega enega od default skinov
else{
switch ($skin){
// nov 1ka default skin
case '1ka':
default:
$chart->setColorPalette(0,30,136,229);
$chart->setColorPalette(1,255,166,8);
$chart->setColorPalette(2,72,229,194);
$chart->setColorPalette(3,242,87,87);
$chart->setColorPalette(4,117,70,68);
$chart->setColorPalette(5,248,202,0);
$chart->setColorPalette(6,255,112,166);
$chart->setColorPalette(7,63,81,180);
$chart->setColorPalette(8,76,174,80);
$chart->setColorPalette(9,204,219,57);
$chart->setColorPalette(10,255,235,59);
$chart->setColorPalette(11,0,149,135);
$chart->setColorPalette(12,121,85,72);
$chart->setColorPalette(13,157,157,157);
$chart->setColorPalette(14,96,125,138);
$chart->setColorPalette(15,155,39,175);
$chart->setColorPalette(16,103,58,182);
$chart->setColorPalette(17,255,255,103);
$chart->setColorPalette(18,255,249,100);
$chart->setColorPalette(19,100,255,255);
$chart->setColorPalette(20,255,100,255);
break;
// zivahen skin
case 'lively':
$chart->setColorPalette(0,224,9,13);
$chart->setColorPalette(1,4,23,227);
$chart->setColorPalette(2,0,255,8);
$chart->setColorPalette(3,255,247,3);
$chart->setColorPalette(4,255,149,0);
$chart->setColorPalette(5,0,251,255);
$chart->setColorPalette(6,166,0,255);
$chart->setColorPalette(7,255,59,63);
$chart->setColorPalette(8,54,73,255);
$chart->setColorPalette(9,50,255,58);
$chart->setColorPalette(10,255,255,53);
$chart->setColorPalette(11,255,199,35);
$chart->setColorPalette(12,50,255,255);
$chart->setColorPalette(13,216,50,255);
$chart->setColorPalette(14,255,109,113);
$chart->setColorPalette(15,104,123,255);
$chart->setColorPalette(16,100,255,108);
$chart->setColorPalette(17,255,255,103);
$chart->setColorPalette(18,255,249,100);
$chart->setColorPalette(19,100,255,255);
$chart->setColorPalette(20,255,100,255);
break;
// blag skin
case 'mild':
$chart->setColorPalette(0,188,224,46);
$chart->setColorPalette(1,224,100,46);
$chart->setColorPalette(2,224,214,46);
$chart->setColorPalette(3,46,151,224);
$chart->setColorPalette(4,176,46,224);
$chart->setColorPalette(5,224,46,117);
$chart->setColorPalette(6,92,224,46);
$chart->setColorPalette(7,238,255,96);
$chart->setColorPalette(8,255,150,96);
$chart->setColorPalette(9,255,255,96);
$chart->setColorPalette(10,96,201,255);
$chart->setColorPalette(11,226,96,255);
$chart->setColorPalette(12,255,96,167);
$chart->setColorPalette(13,142,255,96);
$chart->setColorPalette(14,255,255,146);
$chart->setColorPalette(15,255,200,146);
$chart->setColorPalette(16,255,255,146);
$chart->setColorPalette(17,146,251,255);
$chart->setColorPalette(18,255,146,255);
$chart->setColorPalette(19,255,146,217);
$chart->setColorPalette(20,192,255,146);
break;
// Office skin
case 'office':
$chart->setColorPalette(0,79,129,189);
$chart->setColorPalette(1,192,80,77);
$chart->setColorPalette(2,155,187,89);
$chart->setColorPalette(3,128,100,162);
$chart->setColorPalette(4,75,172,198);
$chart->setColorPalette(5,247,150,70);
$chart->setColorPalette(6,146,169,207);
$chart->setColorPalette(7,129,179,239);
$chart->setColorPalette(8,242,130,127);
$chart->setColorPalette(9,205,237,139);
$chart->setColorPalette(10,178,150,212);
$chart->setColorPalette(11,125,222,248);
$chart->setColorPalette(12,255,200,120);
$chart->setColorPalette(13,196,219,255);
$chart->setColorPalette(14,179,229,255);
$chart->setColorPalette(15,255,180,177);
$chart->setColorPalette(16,255,255,189);
$chart->setColorPalette(17,228,200,255);
$chart->setColorPalette(18,175,255,255);
$chart->setColorPalette(19,255,250,170);
$chart->setColorPalette(20,226,255,255);
break;
// Pastel skin
case 'pastel':
$chart->setColorPalette(0,121,159,11);
$chart->setColorPalette(1,215,161,37);
$chart->setColorPalette(2,146,100,190);
$chart->setColorPalette(3,24,132,132);
$chart->setColorPalette(4,76,198,139);
$chart->setColorPalette(5,138,136,35);
$chart->setColorPalette(6,108,153,210);
$chart->setColorPalette(7,171,209,61);
$chart->setColorPalette(8,255,211,87);
$chart->setColorPalette(9,196,150,240);
$chart->setColorPalette(10,74,182,182);
$chart->setColorPalette(11,126,255,189);
$chart->setColorPalette(12,188,186,85);
$chart->setColorPalette(13,158,203,255);
$chart->setColorPalette(14,221,255,111);
$chart->setColorPalette(15,255,255,137);
$chart->setColorPalette(16,246,200,255);
$chart->setColorPalette(17,124,232,255);
$chart->setColorPalette(18,176,255,239);
$chart->setColorPalette(19,238,236,135);
$chart->setColorPalette(20,208,253,255);
break;
// zelen skin
case 'green':
$chart->createColorGradientPalette(168,188,56,248,255,136,5);
$chart->setColorPalette(5,255,255,0);
$chart->setColorPalette(6,232,3,182);
$chart->setColorPalette(7,$chart->Palette['0']['R'],$chart->Palette['0']['G'],$chart->Palette['0']['B']);
$chart->setColorPalette(8,$chart->Palette['1']['R'],$chart->Palette['1']['G'],$chart->Palette['1']['B']);
$chart->setColorPalette(9,$chart->Palette['2']['R'],$chart->Palette['2']['G'],$chart->Palette['2']['B']);
$chart->setColorPalette(10,$chart->Palette['3']['R'],$chart->Palette['3']['G'],$chart->Palette['3']['B']);
$chart->setColorPalette(11,$chart->Palette['4']['R'],$chart->Palette['4']['G'],$chart->Palette['4']['B']);
$chart->setColorPalette(12,$chart->Palette['5']['R'],$chart->Palette['5']['G'],$chart->Palette['5']['B']);
$chart->setColorPalette(13,$chart->Palette['6']['R'],$chart->Palette['6']['G'],$chart->Palette['6']['B']);
$chart->setColorPalette(14,$chart->Palette['0']['R'],$chart->Palette['0']['G'],$chart->Palette['0']['B']);
$chart->setColorPalette(15,$chart->Palette['1']['R'],$chart->Palette['1']['G'],$chart->Palette['1']['B']);
$chart->setColorPalette(16,$chart->Palette['2']['R'],$chart->Palette['2']['G'],$chart->Palette['2']['B']);
$chart->setColorPalette(17,$chart->Palette['3']['R'],$chart->Palette['3']['G'],$chart->Palette['3']['B']);
$chart->setColorPalette(18,$chart->Palette['4']['R'],$chart->Palette['4']['G'],$chart->Palette['4']['B']);
$chart->setColorPalette(19,$chart->Palette['5']['R'],$chart->Palette['5']['G'],$chart->Palette['5']['B']);
$chart->setColorPalette(20,$chart->Palette['6']['R'],$chart->Palette['6']['G'],$chart->Palette['6']['B']);
break;
// moder skin
case 'blue':
//$chart->createColorGradientPalette(82,124,148,174,216,240,5);
$chart->setColorPalette(0,30,136,229);
$chart->setColorPalette(1,59,151,234);
$chart->setColorPalette(2,110,166,238);
$chart->setColorPalette(3,137,181,243);
$chart->setColorPalette(4,162,196,247);
$chart->setColorPalette(5,186,211,251);
$chart->setColorPalette(6,209,227,255);
$chart->setColorPalette(7,$chart->Palette['0']['R'],$chart->Palette['0']['G'],$chart->Palette['0']['B']);
$chart->setColorPalette(8,$chart->Palette['1']['R'],$chart->Palette['1']['G'],$chart->Palette['1']['B']);
$chart->setColorPalette(9,$chart->Palette['2']['R'],$chart->Palette['2']['G'],$chart->Palette['2']['B']);
$chart->setColorPalette(10,$chart->Palette['3']['R'],$chart->Palette['3']['G'],$chart->Palette['3']['B']);
$chart->setColorPalette(11,$chart->Palette['4']['R'],$chart->Palette['4']['G'],$chart->Palette['4']['B']);
$chart->setColorPalette(12,$chart->Palette['5']['R'],$chart->Palette['5']['G'],$chart->Palette['5']['B']);
$chart->setColorPalette(13,$chart->Palette['6']['R'],$chart->Palette['6']['G'],$chart->Palette['6']['B']);
$chart->setColorPalette(14,$chart->Palette['0']['R'],$chart->Palette['0']['G'],$chart->Palette['0']['B']);
$chart->setColorPalette(15,$chart->Palette['1']['R'],$chart->Palette['1']['G'],$chart->Palette['1']['B']);
$chart->setColorPalette(16,$chart->Palette['2']['R'],$chart->Palette['2']['G'],$chart->Palette['2']['B']);
$chart->setColorPalette(17,$chart->Palette['3']['R'],$chart->Palette['3']['G'],$chart->Palette['3']['B']);
$chart->setColorPalette(18,$chart->Palette['4']['R'],$chart->Palette['4']['G'],$chart->Palette['4']['B']);
$chart->setColorPalette(19,$chart->Palette['5']['R'],$chart->Palette['5']['G'],$chart->Palette['5']['B']);
$chart->setColorPalette(20,$chart->Palette['6']['R'],$chart->Palette['6']['G'],$chart->Palette['6']['B']);
break;
// rdeč skin
case 'red':
$chart->createColorGradientPalette(255,0,0,80,10,10,5);
$chart->setColorPalette(5,255,255,0);
$chart->setColorPalette(6,232,3,182);
$chart->setColorPalette(7,$chart->Palette['0']['R'],$chart->Palette['0']['G'],$chart->Palette['0']['B']);
$chart->setColorPalette(8,$chart->Palette['1']['R'],$chart->Palette['1']['G'],$chart->Palette['1']['B']);
$chart->setColorPalette(9,$chart->Palette['2']['R'],$chart->Palette['2']['G'],$chart->Palette['2']['B']);
$chart->setColorPalette(10,$chart->Palette['3']['R'],$chart->Palette['3']['G'],$chart->Palette['3']['B']);
$chart->setColorPalette(11,$chart->Palette['4']['R'],$chart->Palette['4']['G'],$chart->Palette['4']['B']);
$chart->setColorPalette(12,$chart->Palette['5']['R'],$chart->Palette['5']['G'],$chart->Palette['5']['B']);
$chart->setColorPalette(13,$chart->Palette['6']['R'],$chart->Palette['6']['G'],$chart->Palette['6']['B']);
$chart->setColorPalette(14,$chart->Palette['0']['R'],$chart->Palette['0']['G'],$chart->Palette['0']['B']);
$chart->setColorPalette(15,$chart->Palette['1']['R'],$chart->Palette['1']['G'],$chart->Palette['1']['B']);
$chart->setColorPalette(16,$chart->Palette['2']['R'],$chart->Palette['2']['G'],$chart->Palette['2']['B']);
$chart->setColorPalette(17,$chart->Palette['3']['R'],$chart->Palette['3']['G'],$chart->Palette['3']['B']);
$chart->setColorPalette(18,$chart->Palette['4']['R'],$chart->Palette['4']['G'],$chart->Palette['4']['B']);
$chart->setColorPalette(19,$chart->Palette['5']['R'],$chart->Palette['5']['G'],$chart->Palette['5']['B']);
$chart->setColorPalette(20,$chart->Palette['6']['R'],$chart->Palette['6']['G'],$chart->Palette['6']['B']);
break;
// skin za vec kot 5 moznosti
case 'multi':
$chart->setColorPalette(0,140,0,0);
$chart->setColorPalette(1,240,8,0);
$chart->setColorPalette(2,255,138,130);
$chart->setColorPalette(3,242,196,200);
$chart->setColorPalette(4,11,3,135);
$chart->setColorPalette(5,4,0,252);
$chart->setColorPalette(6,151,148,242);
$chart->setColorPalette(7,0,133,31);
$chart->setColorPalette(8,24,217,3);
$chart->setColorPalette(9,139,245,157);
$chart->setColorPalette(10,237,202,45);
$chart->setColorPalette(11,253,255,120);
$chart->setColorPalette(12,156,0,125);
$chart->setColorPalette(13,255,0,246);
$chart->setColorPalette(14,242,3,162);
$chart->setColorPalette(15,237,154,216);
$chart->setColorPalette(16,0,123,145);
$chart->setColorPalette(17,0,204,250);
$chart->setColorPalette(18,174,238,245);
$chart->setColorPalette(19,0,255,200);
$chart->setColorPalette(20,255,111,0);
$chart->setColorPalette(21,255,162,0);
$chart->setColorPalette(22,255,201,120);
$chart->setColorPalette(23,161,92,133);
$chart->setColorPalette(24,205,159,245);
$chart->setColorPalette(25,179,245,103);
$chart->setColorPalette(26,135,171,108);
$chart->setColorPalette(27,73,132,145);
$chart->setColorPalette(28,70,96,99);
$chart->setColorPalette(29,156,95,103);
break;
}
}
}
// Graf ima posebej nastavljen skin
else{
for($i=0; $i<7; $i++){
$color = self::$settings['colors'][$i];
$rgb = self::html2rgb($color);
$chart->setColorPalette($i,$rgb[0],$rgb[1],$rgb[2]);
$chart->setColorPalette($i+7,$rgb[0]+50,$rgb[1]+50,$rgb[2]+50);
$chart->setColorPalette($i+14,$rgb[0]+100,$rgb[1]+100,$rgb[2]+100);
}
}
return $chart;
}
public static function getDefaultColors($skin){
// ce je nastavljen globalen custom skin
if(is_numeric($skin)){
$skin = self::getCustomSkin($skin);
$default_colors = explode('_', $skin['colors']);
}
else{
switch($skin){
case '1ka':
$default_colors = array(0=>'#1e88e5', 1=>'#ffa608', 2=>'#48e5c2', 3=>'#f25757', 4=>'#754668', 5=>'#f8ca00', 6=>'#ff70a6');
break;
case 'lively':
$default_colors = array(0=>'#e9090d', 1=>'#0417e3', 2=>'#00ff08', 3=>'#fff703', 4=>'#ff9500', 5=>'#00fbff', 6=>'#a600ff');
break;
case 'mild':
$default_colors = array(0=>'#bce02e', 1=>'#e0642e', 2=>'#e0d62e', 3=>'#2e97e0', 4=>'#b02ee0', 5=>'#00fbff', 6=>'#5ce02e');
break;
case 'office':
$default_colors = array(0=>'#4f81bd', 1=>'#c0504d', 2=>'#9bbb59', 3=>'#8064a2', 4=>'#4bacc6', 5=>'#f79646', 6=>'#92a9cf');
break;
case 'pastel':
$default_colors = array(0=>'#799f0b', 1=>'#d7a125', 2=>'#9264be', 3=>'#188484', 4=>'#4cc68b', 5=>'#8a8823', 6=>'#6c99d2');
break;
case 'green':
$default_colors = array(0=>'#a8bc38', 1=>'#b8c948', 2=>'#c8d658', 3=>'#d8e468', 4=>'#e8e178', 5=>'#ffff00', 6=>'#e803b6');
break;
case 'blue':
$default_colors = array(0=>'#1e88e5', 1=>'#4f97ea', 2=>'#6ea6ee', 3=>'#89b5f3', 4=>'#a2c4f7', 5=>'#bad3fb', 6=>'#d1e3ff');
break;
case 'red':
$default_colors = array(0=>'#ff0000', 1=>'#dc0202', 2=>'#b90404', 3=>'#960606', 4=>'#730808', 5=>'#ffff00', 6=>'#e803b6');
break;
case 'multi':
$default_colors = array(0=>'#8c0000', 1=>'#f00800', 2=>'#ff8a82', 3=>'#f2c4c8', 4=>'#0b0387', 5=>'#0400fc', 6=>'#9794f2');
break;
}
}
return $default_colors;
}
public static function html2rgb($color){
if ($color[0] == '#')
$color = substr($color, 1);
if (strlen($color) == 6)
list($r, $g, $b) = array($color[0].$color[1],
$color[2].$color[3],
$color[4].$color[5]);
elseif (strlen($color) == 3)
list($r, $g, $b) = array($color[0].$color[0], $color[1].$color[1], $color[2].$color[2]);
else
return false;
$r = hexdec($r);
$g = hexdec($g);
$b = hexdec($b);
return array($r, $g, $b);
}
// Napolnimo podatke za posamezen graf
public static function getDataSet($spid, $settings){
global $site_path;
global $lang;
$spremenljivka = SurveyAnalysis::$_HEADERS[$spid];
$dataArray = array();
$fullPercent = 0;
self::$numerusText = '';
$_answersOther = array();
$emptyData = true;
// napolnimo podatke za DROPDOWN, ki ima samo numeric variable
if($spremenljivka['tip'] == 3 && self::checkDropdownNumeric($spid)){
$dataArray = array();
$i=0;
$N = 0;
if (count($spremenljivka['grids']) > 0)
foreach ($spremenljivka['grids'] AS $gid => $grid) {
$legendTitle = '';
$_variables_count = count($grid['variables']);
$avg_count = 0;
$avg_sum = 0;
# dodamo dodatne vrstice z albelami grida
if ($_variables_count > 0 )
foreach ($grid['variables'] AS $vid => $variable ){
$legendTitle = substr($variable['variable'],0,strpos($variable['variable'],'_'));
$_sequence = $variable['sequence']; # id kolone z podatki
if (($variable['text'] != true && $variable['other'] != true) || (in_array($spremenljivka['tip'],array(4,8,21)))){
if (is_countable(SurveyAnalysis::$_FREQUENCYS[$_sequence]['valid']) && count(SurveyAnalysis::$_FREQUENCYS[$_sequence]['valid']) > 0) {
$N = SurveyAnalysis::$_FREQUENCYS[$_sequence]['validCnt'];
foreach (SurveyAnalysis::$_FREQUENCYS[$_sequence]['valid'] AS $vkey => $vAnswer) {
if ($vAnswer['cnt'] > 0 || true) { # izpisujemo samo tiste ki nisno 0
$_valid = (SurveyAnalysis::$_FREQUENCYS[$_sequence]['validCnt'] > 0 ) ? 100*$vAnswer['cnt'] / SurveyAnalysis::$_FREQUENCYS[$_sequence]['validCnt'] : 0;
$_percent = (SurveyAnalysis::$_FREQUENCYS[$_sequence]['allCnt'] > 0 ) ? 100*$vAnswer['cnt'] / SurveyAnalysis::$_FREQUENCYS[$_sequence]['allCnt'] : 0;
$tempArray = array();
$tempArray['freq'] = $vAnswer['cnt'];
$tempArray['percent'] = $_percent;
$tempArray['valid'] = $_valid;
$tempArray['key'] = $vkey;
// ce je znotraj nastavljenih mej
if( ($settings['max'] == '' || ($settings['open_up'] == 1 || (int)$vAnswer['text'] <= (int)$settings['max']))
&& ($settings['min'] == '' || ($settings['open_down'] == 1 || (int)$vAnswer['text'] >= (int)$settings['min'])) ){
$avg_count += $vAnswer['cnt'];
$avg_sum += $vAnswer['cnt'] * (int)$vAnswer['text'];
}
else{
$N -= $vAnswer['cnt'];
}
// nastavimo da graf ni prazen
$emptyData = false;
$text = $spremenljivka['edit_graf'] == 0 ? $vAnswer['text'] : $vAnswer['text_graf'];
$tempArray['variable'] = $text;
$dataArray[] = $tempArray;
}
}
}
}
}
$displayMV = ((int)SurveyAnalysis::$missingProfileData['display_mv_type'] === 2) ? TRUE : FALSE;
if ( (count(SurveyAnalysis::$_FREQUENCYS[$_sequence]['invalid'])> 0) && $displayMV) {
foreach (SurveyAnalysis::$_FREQUENCYS[$_sequence]['invalid'] AS $ikey => $iAnswer) {
if ($iAnswer['cnt'] > 0 ) { # izpisujemo samo tiste ki nisno 0
$_percent = (SurveyAnalysis::$_FREQUENCYS[$_sequence]['allCnt'] > 0 ) ? 100*$vAnswer['cnt'] / SurveyAnalysis::$_FREQUENCYS[$_sequence]['allCnt'] : 0;
$_invalid = (SurveyAnalysis::$_FREQUENCYS[$_sequence]['invalidCnt'] > 0 ) ? 100*$vAnswer['cnt'] / SurveyAnalysis::$_FREQUENCYS[$_sequence]['invalidCnt'] : 0;
$tempArray = array();
$tempArray['freq'] = $iAnswer['cnt'];
//$N = ($settings['value_type'] == 0) ? SurveyAnalysis::$_FREQUENCYS[$_sequence]['invalidCnt'] : SurveyAnalysis::$_FREQUENCYS[$_sequence]['allCnt'];
$tempArray['percent'] = $_percent;
$tempArray['valid'] = $_invalid;
$tempArray['key'] = $ikey;
$tempArray['variable'] = $iAnswer['text'];
$dataArray[] = $tempArray;
}
}
}
$i++;
}
// zascita pred praznimi vprasanji (brez variabel)
if($_variables_count == 0)
return -1;
//polnimo podatke
$DataSet = new pData;
//nastavimo numerus, ki se izpise pod legendo
$N = ((int)$N > 0) ? $N : 0;
$DataSet->SetNumerus($N);
// nastavimo POVPRECJE
$avg = ($avg_count > 0) ? $avg_sum / $avg_count : 0;
$DataSet->SetAverage(round($avg, 1));
// Sortiramo podatke - ce imamo izpis vsakega vnosa posebej sortiramo po freq, ce pa po skupinah pa po key
if($settings['type'] > 4){
$tmp = Array();
foreach($dataArray as &$data)
$tmp[] = &$data['key'];
array_multisort($tmp, SORT_NUMERIC, SORT_ASC, $dataArray);
}
elseif($settings['sort'] == 1){
$tmp = Array();
foreach($dataArray as &$data)
$tmp[] = &$data['freq'];
array_multisort($tmp, SORT_NUMERIC, SORT_DESC, $dataArray);
}
elseif($settings['sort'] == 2){
$tmp = Array();
foreach($dataArray as &$data)
$tmp[] = &$data['freq'];
array_multisort($tmp, SORT_NUMERIC, SORT_ASC, $dataArray);
}
$max = (int)$dataArray[count($dataArray,0)-1]['variable'];
$min = (int)$dataArray[0]['variable'];
$stIntervalov = ((int)$settings['interval'] == 0 ? 10 : (int)$settings['interval']);
// Ce imamo napredno napredne intervale
if($settings['limits']['advanced_settings'] == 1){
$limits = $settings['limits'];
$max = $limits['interval_'. ($stIntervalov-1) ]['max'];
$min = $limits['interval_0']['min'];
}
// Ce imamo osnovne intervale
else{
// Nastavimo custom zgornjo mejo skale (razen v primeru ko ne ignoriramo vrednosti ki padejo ven in ce je max vnos vecji od nastavljenega max)
if($settings['max'] != '' /*&& ($settings['open_up'] == 0 || (int)$settings['max'] > $max)*/)
$max = (int)$settings['max'];
// Nastavimo custom spodnjo mejo skale (razen v primeru ko ne ignoriramo vrednosti ki padejo ven in ce je min vnos manjsi od nastavljenega min)
if($settings['min'] != '' /*&& ($settings['open_down'] == 0 || (int)$settings['min'] < $min)*/)
$min = (int)$settings['min'];
$stIntervalov = ($stIntervalov == -1 ? $max-$min : $stIntervalov);
$part = ($max-$min) / $stIntervalov;
$part = ($part < 1) ? 1 : round($part);
}
// Poberemo podatke v posamezne tabele - po intervalih oz normalno
if($settings['type'] > 4){
// Ce imamo polodprt intrerval navzdol
if($settings['open_down'] == 1){
$count = 0;
$percent = 0;
$valid = 0;
// loop cez vse podatke
for($i=0; $i 0 ? $min + ($interval * $part) + 1 : $min);
}
// prekinemo ce zaradi zaokrozevanja pride do min > max
if($minVal > $maxVal)
break;
// loop cez vse podatke
for($i=0; $i= $minVal && $dataArray[$i]['field'] == 0){
$count += $dataArray[$i]['freq'];
$percent += $dataArray[$i]['percent'];
$valid += $dataArray[$i]['valid'];
}
}
// vnesemo podatke za interval
$vrednosti[] = $count;
$vrednostiPercent[] = $percent;
$vrednostiValid[] = $valid;
// Ce imamo napredne intervale (custom dolocene labele)
if($settings['limits']['advanced_settings'] == 1 && $limits['interval_'.$interval]['label'] != ''){
$vrednostiKey[] = $limits['interval_'.$interval]['label'];
$vrednostiVariable[] = $limits['interval_'.$interval]['label'];
}
elseif($minVal == $maxVal){
$vrednostiKey[] = $minVal;
$vrednostiVariable[] = $minVal;
}
else{
$vrednostiKey[] = $minVal.'-'.$maxVal;
$vrednostiVariable[] = $minVal.'-'.$maxVal;
}
}
// Ce imamo polodprt intrerval navzgor
if($settings['open_up'] == 1){
$count = 0;
$percent = 0;
$valid = 0;
// loop cez vse podatke
for($i=0; $i $max){
$count += $dataArray[$i]['freq'];
$percent += $dataArray[$i]['percent'];
$valid += $dataArray[$i]['valid'];
}
}
// vnesemo podatke za interval
$vrednosti[] = $count;
$vrednostiPercent[] = $percent;
$vrednostiValid[] = $valid;
$vrednostiKey[] = $lang['srv_chart_more'].' '.$max;
$vrednostiVariable[] = $lang['srv_chart_more'].' '.$max;
}
}
else{
for($i=0; $i 0){
if($settings['value_type'] == 0){
$DataSet->AddPoint($vrednosti,'Vrednosti');
}
elseif($settings['value_type'] == 1){
$DataSet->AddPoint($vrednostiPercent,'Vrednosti');
}
elseif($settings['value_type'] == 2){
$DataSet->AddPoint($vrednostiValid,'Vrednosti');
}
}
else
$DataSet->AddPoint(array(0),'Vrednosti');
$DataSet->AddSerie('Vrednosti');
$var_title[0] = ($var_title[0] == '' ? 'Vrednosti' : $var_title[0]);
$DataSet->SetSerieName($var_title[0],'Vrednosti');
// Vedno izpisemo cela imena variabel
$DataSet->AddPoint($vrednostiVariable,"Variable");
//$DataSet->AddPoint($vrednostiKey,"Variable");
$DataSet->SetAbsciseLabelSerie("Variable");
if($settings['value_type'] > 0){
$DataSet->SetYAxisUnit("%");
$DataSet->SetYAxisFormat("number");
}
}
// napolnimo podatke za RADIO, DROPDOWN
elseif($spremenljivka['tip'] == 1 || $spremenljivka['tip'] == 3){
$dataArray = array();
$i=0;
$N = 0;
$N_average = 0;
if (count($spremenljivka['grids']) > 0)
foreach ($spremenljivka['grids'] AS $gid => $grid) {
$legendTitle = '';
$_variables_count = count($grid['variables']);
# dodamo dodatne vrstice z albelami grida
if ($_variables_count > 0 )
foreach ($grid['variables'] AS $vid => $variable ){
$legendTitle = substr($variable['variable'],0,strpos($variable['variable'],'_'));
$_sequence = $variable['sequence']; # id kolone z podatki
// Ce skrivamo prazne vrednosti
if($settings['hideEmptyVar'] == 1){
foreach (SurveyAnalysis::$_FREQUENCYS[$_sequence]['valid'] AS $key => $valid) {
if ((int)$valid['cnt'] == 0) {
unset (SurveyAnalysis::$_FREQUENCYS[$_sequence]['valid'][$key]);
}
}
}
if (($variable['text'] != true && $variable['other'] != true) || (in_array($spremenljivka['tip'],array(4,8,21)))){
if (is_countable(SurveyAnalysis::$_FREQUENCYS[$_sequence]['valid']) && count(SurveyAnalysis::$_FREQUENCYS[$_sequence]['valid']) > 0) {
foreach (SurveyAnalysis::$_FREQUENCYS[$_sequence]['valid'] AS $vkey => $vAnswer) {
if ($vAnswer['cnt'] > 0 || true) { # izpisujemo samo tiste ki nisno 0
$_valid = (isset(SurveyAnalysis::$_FREQUENCYS[$_sequence]['validCnt']) && SurveyAnalysis::$_FREQUENCYS[$_sequence]['validCnt'] > 0) ? 100*$vAnswer['cnt'] / SurveyAnalysis::$_FREQUENCYS[$_sequence]['validCnt'] : 0;
$_percent = (isset(SurveyAnalysis::$_FREQUENCYS[$_sequence]['allCnt']) && SurveyAnalysis::$_FREQUENCYS[$_sequence]['allCnt'] > 0) ? 100*$vAnswer['cnt'] / SurveyAnalysis::$_FREQUENCYS[$_sequence]['allCnt'] : 0;
$tempArray = array();
$tempArray['freq'] = $vAnswer['cnt'];
// nastavimo da graf ni prazen
if($vAnswer['cnt'] > 0)
$emptyData = false;
$N = ($settings['value_type'] == 0 && isset(SurveyAnalysis::$_FREQUENCYS[$_sequence]['validCnt'])) ? SurveyAnalysis::$_FREQUENCYS[$_sequence]['validCnt'] : SurveyAnalysis::$_FREQUENCYS[$_sequence]['allCnt'];
$tempArray['percent'] = $_percent;
$tempArray['valid'] = $_valid;
$tempArray['key'] = $vkey;
$text = $spremenljivka['edit_graf'] == 0 ? $vAnswer['text'] : $vAnswer['text_graf'];
$tempArray['variable'] = $text;
$fullPercent += $tempArray['percent'];
// ce imamo vklopljeno da izpuscamo 0 in prikazujemo pie chart spustimo nicelne vrednosti
if($_valid != 0 || SurveyDataSettingProfiles :: getSetting('chartPieZeros') == 1 || ($settings['type'] != 2 && $settings['type'] != 8)){
$dataArray[] = $tempArray;
}
// Ce je ordinalen racunamo povprecje
if($spremenljivka['skala'] != 1){
$xi = (int)$vkey;
$fi = (int)$vAnswer['cnt'];
$sum_xi_fi = isset($sum_xi_fi) ? $sum_xi_fi += $xi * $fi : $xi * $fi;
$N_average += $fi;
}
}
}
}
}
// polnimo array za drugo
else{
$_answersOther[] = array('spid'=>$spid,'gid'=>$gid,'vid'=>$vid,'sequence'=>$_sequence);
}
}
$displayMV = ((int)SurveyAnalysis::$missingProfileData['display_mv_type'] === 2) ? TRUE : FALSE;
if ( (count(SurveyAnalysis::$_FREQUENCYS[$_sequence]['invalid'])> 0) && $displayMV) {
foreach (SurveyAnalysis::$_FREQUENCYS[$_sequence]['invalid'] AS $ikey => $iAnswer) {
if ($iAnswer['cnt'] > 0 ) { # izpisujemo samo tiste ki nisno 0
$_percent = (SurveyAnalysis::$_FREQUENCYS[$_sequence]['allCnt'] > 0 ) ? 100*$vAnswer['cnt'] / SurveyAnalysis::$_FREQUENCYS[$_sequence]['allCnt'] : 0;
$_invalid = (SurveyAnalysis::$_FREQUENCYS[$_sequence]['invalidCnt'] > 0 ) ? 100*$vAnswer['cnt'] / SurveyAnalysis::$_FREQUENCYS[$_sequence]['invalidCnt'] : 0;
$tempArray = array();
$tempArray['freq'] = $iAnswer['cnt'];
$N = ($settings['value_type'] == 0) ? SurveyAnalysis::$_FREQUENCYS[$_sequence]['invalidCnt'] : SurveyAnalysis::$_FREQUENCYS[$_sequence]['allCnt'];
$tempArray['percent'] = $_percent;
$tempArray['valid'] = $_invalid;
$tempArray['key'] = $ikey;
$tempArray['variable'] = $iAnswer['text'];
$fullPercent += $tempArray['percent'];
// ce imamo vklopljeno da izpuscamo 0 in prikazujemo pie chart spustimo nicelne vrednosti
if($_invalid != 0 || SurveyDataSettingProfiles :: getSetting('chartPieZeros') == 1 || ($settings['type'] != 2 && $settings['type'] != 8))
$dataArray[] = $tempArray;
}
}
}
$i++;
}
// zascita pred praznimi vprasanji (brez variabel)
if($_variables_count == 0)
return -1;
//polnimo podatke
$DataSet = new pData;
//nastavimo numerus, ki se izpise pod legendo
$N = ((int)$N > 0) ? $N : 0;
$DataSet->SetNumerus($N);
self::$numerusText = ($settings['value_type'] == 0) ? ' ('.$lang['srv_analiza_frekvence_titleVeljavni'].')' : '';
//nastavimo povprecje ce je ordinalen
if($spremenljivka['skala'] != 1){
$avg = ($N_average > 0) ? $sum_xi_fi / $N_average : 0;
$DataSet->SetAverage(round($avg, 1));
}
// Sortiramo podatke ce je potrebno
if($settings['sort'] == 1){
$tmp = Array();
foreach($dataArray as &$data)
$tmp[] = &$data['freq'];
array_multisort($tmp, SORT_NUMERIC, SORT_DESC, $dataArray);
}
elseif($settings['sort'] == 2){
$tmp = Array();
foreach($dataArray as &$data)
$tmp[] = &$data['freq'];
array_multisort($tmp, SORT_NUMERIC, SORT_ASC, $dataArray);
}
// Poberemo podatke v posamezne tabele
for($i=0; $i 0){
if($settings['type'] < 3 || $settings['type'] == 8){
if($settings['value_type'] == 1){
$DataSet->AddPoint($vrednosti,'Vrednosti');
//$DataSet->SetYAxisName($lang['srv_chart_freq']);
}
elseif($settings['value_type'] == 2){
$DataSet->AddPoint($vrednostiPercent,'Vrednosti');
//$DataSet->SetYAxisName($lang['srv_chart_percent']);
}
elseif($settings['value_type'] == 0){
$DataSet->AddPoint($vrednostiValid,'Vrednosti');
//$DataSet->SetYAxisName($lang['srv_chart_valid']);
}
$DataSet->AddSerie('Vrednosti');
$DataSet->SetSerieName('Frekvence','Vrednosti');
// Vedno izpisemo cela imena variabel
$DataSet->AddPoint($vrednostiVariable,"Variable");
//$DataSet->AddPoint($vrednostiKey,"Variable");
}
// Graf povprecja
elseif($settings['type'] == 9){
$DataSet->AddPoint(round($avg, 1),'Vrednosti');
$DataSet->AddSerie('Vrednosti');
$DataSet->SetSerieName('Frekvence','Vrednosti');
}
else{
for($i=0; $iAddPoint($vrednosti[$i],'Vrednosti_'.$i);
//$DataSet->SetYAxisName($lang['srv_chart_freq']);
}
elseif($settings['value_type'] == 2){
$DataSet->AddPoint($vrednostiPercent[$i],'Vrednosti_'.$i);
//$DataSet->SetYAxisName($lang['srv_chart_percent']);
}
elseif($settings['value_type'] == 0){
$DataSet->AddPoint($vrednostiValid[$i],'Vrednosti_'.$i);
//$DataSet->SetYAxisName($lang['srv_chart_valid']);
}
$DataSet->AddSerie('Vrednosti_'.$i);
$DataSet->SetSerieName($vrednostiVariable[$i],'Vrednosti_'.$i);
}
$DataSet->AddPoint('','Variable');
//$DataSet->AddPoint($vrednostiKey,"Variable");
}
}
else
$DataSet->AddPoint(array(0),'Vrednosti');
$DataSet->SetAbsciseLabelSerie('Variable');
if($settings['value_type'] != 1 && $settings['type'] != 9){
$DataSet->SetYAxisUnit("%");
$DataSet->SetYAxisFormat("number");
}
}
// napolnimo podatke za CHECKBOX
elseif($spremenljivka['tip'] == 2){
$dataArray = array();
$fullPercent = 0;
$i=0;
$nValid = 0;
$nAll = 0;
$nNavedbe = 0;
if (count($spremenljivka['grids']) > 0)
foreach ($spremenljivka['grids'] AS $gid => $grid) {
$legendTitle = '';
$_variables_count = count($grid['variables']);
# dodamo dodatne vrstice z albelami grida
if ($_variables_count > 0 )
foreach ($grid['variables'] AS $vid => $variable ){
if ($variable['text'] != true && $variable['other'] != true){
$_sequence = $variable['sequence']; # id kolone z podatki
$legendTitle = substr($variable['variable'],0,strpos($variable['variable'],'_'));
$vAnswer = (int)SurveyAnalysis::$_FREQUENCYS[$_sequence]['valid'][1]['cnt'];
$_valid = (SurveyAnalysis::$_FREQUENCYS[$_sequence]['validCnt'] > 0 ) ? 100*$vAnswer / SurveyAnalysis::$_FREQUENCYS[$_sequence]['validCnt'] : 0;
$_percent = (SurveyAnalysis::$_FREQUENCYS[$_sequence]['allCnt'] > 0 ) ? 100*$vAnswer / SurveyAnalysis::$_FREQUENCYS[$_sequence]['allCnt'] : 0;
$tempArray = array();
$tempArray['freq'] = (int)SurveyAnalysis::$_FREQUENCYS[$_sequence]['valid'][1]['cnt'];
// nastavimo da graf ni prazen
if($tempArray['freq'] > 0)
$emptyData = false;
$nValid = (SurveyAnalysis::$_FREQUENCYS[$_sequence]['validCnt'] > $nValid) ? SurveyAnalysis::$_FREQUENCYS[$_sequence]['validCnt'] : $nValid;
$nAll = SurveyAnalysis::$_FREQUENCYS[$_sequence]['allCnt'];
$nNavedbe += (int)SurveyAnalysis::$_FREQUENCYS[$_sequence]['valid'][1]['cnt'];
$tempArray['percent'] = $_percent;
$tempArray['valid'] = $_valid;
$tempArray['key'] = $variable['variable'];
$text = $spremenljivka['edit_graf'] == 0 ? $variable['naslov'] : $variable['naslov_graf'];
$tempArray['variable'] = $text;
$fullPercent += $tempArray['percent'];
// ce imamo vklopljeno da izpuscamo 0 spustimo nicelne vrednosti
if(($_valid != 0 || SurveyDataSettingProfiles :: getSetting('chartPieZeros') == 1 || ($settings['type'] != 2 && $settings['type'] != 7))
&& ((int)SurveyAnalysis::$_FREQUENCYS[$_sequence]['valid']['1']['cnt'] > 0) || $settings['hideEmptyVar'] == 0)
$dataArray[] = $tempArray;
}
// polnimo array za drugo
else{
$_answersOther[] = array('spid'=>$spid,'gid'=>$gid,'vid'=>$vid,'sequence'=>$_sequence);
}
}
$displayMV = ((int)SurveyAnalysis::$missingProfileData['display_mv_type'] === 2) ? TRUE : FALSE;
if ( (count(SurveyAnalysis::$_FREQUENCYS[$_sequence]['invalid'])> 0) && $displayMV) {
foreach (SurveyAnalysis::$_FREQUENCYS[$_sequence]['invalid'] AS $ikey => $iAnswer) {
if ($iAnswer['cnt'] > 0 ) { # izpisujemo samo tiste ki nisno 0
$_percent = (SurveyAnalysis::$_FREQUENCYS[$_sequence]['allCnt'] > 0 ) ? 100*$vAnswer['cnt'] / SurveyAnalysis::$_FREQUENCYS[$_sequence]['allCnt'] : 0;
$_invalid = (SurveyAnalysis::$_FREQUENCYS[$_sequence]['invalidCnt'] > 0 ) ? 100*$vAnswer['cnt'] / SurveyAnalysis::$_FREQUENCYS[$_sequence]['invalidCnt'] : 0;
$tempArray = array();
$tempArray['freq'] = (int)$iAnswer['cnt'];
//$nValid = SurveyAnalysis::$_FREQUENCYS[$_sequence]['invalidCnt'];
$nAll = SurveyAnalysis::$_FREQUENCYS[$_sequence]['allCnt'];
$nNavedbe += (int)$iAnswer['cnt'];
$tempArray['percent'] = $_percent;
$tempArray['valid'] = $_invalid;
$tempArray['key'] = $ikey;
$tempArray['variable'] = $iAnswer['text'];
$fullPercent += $tempArray['percent'];
// ce imamo vklopljeno da izpuscamo 0 in prikazujemo pie chart spustimo nicelne vrednosti
if($_invalid != 0 || SurveyDataSettingProfiles :: getSetting('chartPieZeros') == 1 || ($settings['type'] != 2 && $settings['type'] != 7))
$dataArray[] = $tempArray;
}
}
}
$i++;
}
// zascita pred praznimi vprasanji (brez variabel)
if($_variables_count == 0)
return -1;
//polnimo podatke
$DataSet = new pData;
// Sortiramo podaatke ce je potrebno
if($settings['sort'] == 1){
$tmp = Array();
foreach($dataArray as &$data)
$tmp[] = &$data['freq'];
array_multisort($tmp, SORT_NUMERIC, SORT_DESC, $dataArray);
}
elseif($settings['sort'] == 2){
$tmp = Array();
foreach($dataArray as &$data)
$tmp[] = &$data['freq'];
array_multisort($tmp, SORT_NUMERIC, SORT_ASC, $dataArray);
}
// Poberemo podatke v posamezne tabele
for($i=0; $i 0) ? $numerus : 0;
$DataSet->SetNumerus($numerus);
//$valid = ($fullPercent * $dataArray[$i]['percent'] > 0) ? 100 / $fullPercent * $dataArray[$i]['percent'] : 0;
$valid = ($nValid > 0 ) ? $dataArray[$i]['freq'] * 100 / $nValid : 0;
$vrednosti[] = $dataArray[$i]['freq'];
$vrednostiPercent[] = $dataArray[$i]['percent'];
$vrednostiValid[] = $valid;
$vrednostiKey[] = $dataArray[$i]['key'];
$vrednostiVariable[] = $dataArray[$i]['variable'];
}
else{
//nastavimo numerus, ki se izpise pod legendo
$nNavedbe = ((int)$nNavedbe > 0) ? $nNavedbe : 0;
$DataSet->SetNumerus($nNavedbe);
self::$numerusText = ' ('.$lang['srv_analiza_opisne_arguments'].')';
$percent = ($fullPercent * $dataArray[$i]['percent'] > 0) ? 100 / $fullPercent * $dataArray[$i]['percent'] : 0;
$vrednosti[] = $dataArray[$i]['freq'];
$vrednostiPercent[] = $percent;
$vrednostiValid[] = $percent;
$vrednostiKey[] = $dataArray[$i]['key'];
$vrednostiVariable[] = $dataArray[$i]['variable'];
}
}
if(count($vrednosti) > 0){
if($settings['type'] < 3 || $settings['type'] == 5 || $settings['type'] == 6 || $settings['type'] == 7){
if($settings['value_type'] == 1 || ($settings['value_type'] == 0 && $settings['base'] == 1)){
$DataSet->AddPoint($vrednosti,'Vrednosti');
//$DataSet->SetYAxisName($lang['srv_chart_freq']);
}
elseif($settings['value_type'] == 2){
$DataSet->AddPoint($vrednostiPercent,'Vrednosti');
//$DataSet->SetYAxisName($lang['srv_chart_percent']);
}
elseif($settings['value_type'] == 0){
$DataSet->AddPoint($vrednostiValid,'Vrednosti');
//$DataSet->SetYAxisName($lang['srv_chart_valid']);
}
$DataSet->AddSerie('Vrednosti');
$DataSet->SetSerieName('Frekvence','Vrednosti');
// Vedno izpisemo cela imena variabel
$DataSet->AddPoint($vrednostiVariable,"Variable");
//$DataSet->AddPoint($vrednostiKey,"Variable");
}
else{
for($i=0; $iAddPoint($vrednosti[$i],'Vrednosti_'.$i);
//$DataSet->SetYAxisName($lang['srv_chart_freq']);
}
elseif($settings['value_type'] == 2){
$DataSet->AddPoint($vrednostiPercent[$i],'Vrednosti_'.$i);
//$DataSet->SetYAxisName($lang['srv_chart_percent']);
}
elseif($settings['value_type'] == 0){
$DataSet->AddPoint($vrednostiValid[$i],'Vrednosti_'.$i);
//$DataSet->SetYAxisName($lang['srv_chart_valid']);
}
$DataSet->AddSerie('Vrednosti_'.$i);
$DataSet->SetSerieName($vrednostiVariable[$i],'Vrednosti_'.$i);
}
$DataSet->AddPoint('','Variable');
//$DataSet->AddPoint($vrednostiKey,"Variable");
}
}
else
$DataSet->AddPoint(array(0),'Vrednosti');
$DataSet->SetAbsciseLabelSerie('Variable');
if(($settings['value_type'] == 0 && $settings['base'] == 0) || $settings['value_type'] == 2){
$DataSet->SetYAxisUnit("%");
$DataSet->SetYAxisFormat("number");
}
}
// napolnimo podatke za DVOJNI MULTIGRID
elseif(isset($spremenljivka['enota']) && $spremenljivka['tip'] == 6 && $spremenljivka['enota'] == 3){
$DataSet = new pData;
$dataArray = array();
$fullPercent = array();
$gridCount=0;
$sql = sisplet_query("SELECT count(*) AS count FROM srv_grid WHERE spr_id='$spid'");
$row = mysqli_fetch_array($sql);
$_variables_count = $row['count'];
$nArray = array();
if (count($spremenljivka['grids']) > 0)
foreach ($spremenljivka['grids'] AS $gid => $grid) {
// Prva podtabela
if($grid['part'] == 1){
# dodamo dodatne vrstice z albelami grida
foreach ($grid['variables'] AS $vid => $variable ){
if ($variable['text'] != true && $variable['other'] != true){
$_sequence = $variable['sequence']; # id kolone z podatki
$sum_xi_fi=0;
$N = 0;
$div=0;
if (count($spremenljivka['options']) > 0) {
foreach ( $spremenljivka['options'] as $key => $kategorija) {
$xi = $key;
$fi = SurveyAnalysis::$_FREQUENCYS[$_sequence]['valid'][$key]['cnt'];
$sum_xi_fi += $xi * $fi ;
$N += $fi;
}
}
$avg = ($N > 0) ? $sum_xi_fi / $N : 0;
$nArray[] = $N;
$tempArray = array();
// nastavimo da graf ni prazen
if($N > 0)
$emptyData = false;
$avg = $avg < 1 ? 1 : $avg;
$tempArray['freq'] = $avg;
$tempArray['percent'] = $avg;
$tempArray['valid'] = $avg;
$tempArray['key'] = $variable['variable'];
$text = $spremenljivka['edit_graf'] == 0 ? $variable['naslov'] : $variable['naslov_graf'];
$tempArray['variable'] = $text;
$dataArray[] = $tempArray;
}
// polnimo array za drugo
if ($variable['text'] == true || $variable['other'] == true){
$_answersOther[] = array('spid'=>$spid,'gid'=>$gid,'vid'=>$vid,'sequence'=>$_sequence);
}
}
$displayMV = ((int)SurveyAnalysis::$missingProfileData['display_mv_type'] === 2) ? TRUE : FALSE;
if ( (count(SurveyAnalysis::$_FREQUENCYS[$_sequence]['invalid'])> 0) && $displayMV) {
foreach (SurveyAnalysis::$_FREQUENCYS[$_sequence]['invalid'] AS $ikey => $iAnswer) {
if ($iAnswer['cnt'] > 0 ) { # izpisujemo samo tiste ki nisno 0
$_percent = (SurveyAnalysis::$_FREQUENCYS[$_sequence]['allCnt'] > 0 ) ? 100*$vAnswer['cnt'] / SurveyAnalysis::$_FREQUENCYS[$_sequence]['allCnt'] : 0;
$_invalid = (SurveyAnalysis::$_FREQUENCYS[$_sequence]['invalidCnt'] > 0 ) ? 100*$vAnswer['cnt'] / SurveyAnalysis::$_FREQUENCYS[$_sequence]['invalidCnt'] : 0;
$tempArray = array();
$tempArray['freq'] = $iAnswer['cnt'];
$tempArray['percent'] = $_percent;
$tempArray['valid'] = $_invalid;
$tempArray['key'] = $ikey;
$tempArray['variable'] = $iAnswer['text'];
$tempArray['grid'] = $grid['variables'][0]['naslov'];
$dataArray[] = $tempArray;
}
}
}
$gridCount++;
}
else{
# dodamo dodatne vrstice z albelami grida
foreach ($grid['variables'] AS $vid => $variable ){
if ($variable['text'] != true && $variable['other'] != true){
$_sequence = $variable['sequence']; # id kolone z podatki
$sum_xi_fi=0;
$N = 0;
$div=0;
if (count($spremenljivka['options']) > 0) {
foreach ( $spremenljivka['options'] as $key => $kategorija) {
$xi = $key;
$fi = SurveyAnalysis::$_FREQUENCYS[$_sequence]['valid'][$key]['cnt'];
$sum_xi_fi += $xi * $fi ;
$N += $fi;
}
}
$avg = ($N > 0) ? $sum_xi_fi / $N : 0;
$nArray[] = $N;
$tempArray = array();
// nastavimo da graf ni prazen
if($N > 0)
$emptyData = false;
$avg = $avg < 1 ? 1 : $avg;
$tempArray['freq'] = $avg;
$tempArray['percent'] = $avg;
$tempArray['valid'] = $avg;
$tempArray['key'] = $variable['variable'];
$text = $spremenljivka['edit_graf'] == 0 ? $variable['naslov'] : $variable['naslov_graf'];
$tempArray['variable'] = $text;
$dataArray2[] = $tempArray;
}
// polnimo array za drugo
if ($variable['text'] == true || $variable['other'] == true){
$_answersOther[] = array('spid'=>$spid,'gid'=>$gid,'vid'=>$vid,'sequence'=>$_sequence);
}
}
$displayMV = ((int)SurveyAnalysis::$missingProfileData['display_mv_type'] === 2) ? TRUE : FALSE;
if ( (count(SurveyAnalysis::$_FREQUENCYS[$_sequence]['invalid'])> 0) && $displayMV) {
foreach (SurveyAnalysis::$_FREQUENCYS[$_sequence]['invalid'] AS $ikey => $iAnswer) {
if ($iAnswer['cnt'] > 0 ) { # izpisujemo samo tiste ki nisno 0
$_percent = (SurveyAnalysis::$_FREQUENCYS[$_sequence]['allCnt'] > 0 ) ? 100*$vAnswer['cnt'] / SurveyAnalysis::$_FREQUENCYS[$_sequence]['allCnt'] : 0;
$_invalid = (SurveyAnalysis::$_FREQUENCYS[$_sequence]['invalidCnt'] > 0 ) ? 100*$vAnswer['cnt'] / SurveyAnalysis::$_FREQUENCYS[$_sequence]['invalidCnt'] : 0;
$tempArray = array();
$tempArray['freq'] = $iAnswer['cnt'];
$tempArray['percent'] = $_percent;
$tempArray['valid'] = $_invalid;
$tempArray['key'] = $ikey;
$tempArray['variable'] = $iAnswer['text'];
$tempArray['grid'] = $grid['variables'][0]['naslov'];
$dataArray2[] = $tempArray;
}
}
}
}
}
// zascita pred praznimi vprasanji (brez variabel)
if(count($spremenljivka['grids']) == 0)
return -1;
//nastavimo numerus, ki se izpise pod legendo
rsort($nArray);
$numerus = ((int)$nArray[0] > 0) ? $nArray[0] : 0;
$DataSet->SetNumerus($numerus);
self::$numerusText = ($settings['value_type'] == 0) ? ' ('.$lang['srv_analiza_frekvence_titleVeljavni'].')' : '';
// Poberemo podatke v posamezne tabele
for($i=0; $i 0){
if($settings['value_type'] == 1){
$DataSet->AddPoint($vrednosti,'Vrednosti');
$DataSet->AddPoint($vrednosti2,'Vrednosti2');
//$DataSet->SetYAxisName($lang['srv_chart_freq']);
}
elseif($settings['value_type'] == 2){
$DataSet->AddPoint($vrednostiPercent,'Vrednosti');
$DataSet->AddPoint($vrednostiPercent2,'Vrednosti2');
//$DataSet->SetYAxisName($lang['srv_chart_percent']);
}
elseif($settings['value_type'] == 0){
$DataSet->AddPoint($vrednostiValid,'Vrednosti');
$DataSet->AddPoint($vrednostiValid2,'Vrednosti2');
//$DataSet->SetYAxisName($lang['srv_chart_valid']);
}
}
else{
$DataSet->AddPoint(array(0),'Vrednosti');
$DataSet->AddPoint(array(0),'Vrednosti2');
}
$title1 = ($spremenljivka['double'][1]['subtitle'] != '') ? $spremenljivka['double'][1]['subtitle'] : 'Tabela 1';
$title2 = ($spremenljivka['double'][2]['subtitle'] != '') ? $spremenljivka['double'][2]['subtitle'] : 'Tabela 2';
$DataSet->AddSerie('Vrednosti');
$DataSet->SetSerieName($title1,'Vrednosti');
$DataSet->AddSerie('Vrednosti2');
$DataSet->SetSerieName($title2,'Vrednosti2');
$DataSet->AddPoint($vrednostiVariable,"Variable");
$DataSet->SetAbsciseLabelSerie("Variable");
}
// napolnimo podatke za MULTIGRID
elseif($spremenljivka['tip'] == 6){
$DataSet = new pData;
$dataArray = array();
$fullPercent = array();
$gridCount=0;
// Prefiltriramo other, ki so manjkajoci
$_invalidAnswers = SurveyAnalysis :: getInvalidAnswers (2);
$noOthers = (isset($_invalidAnswers['-99'])) ? ' AND other!=-99' : '';
$noOthers .= (isset($_invalidAnswers['-98'])) ? ' AND other!=-98' : '';
$noOthers .= (isset($_invalidAnswers['-97'])) ? ' AND other!=-97' : '';
// Napolnimo vse gride, ki jih obravnavamo
$stolpci = array();
$sqlG = sisplet_query("SELECT * FROM srv_grid WHERE spr_id='$spid' ".$noOthers." ");
while($rowG = mysqli_fetch_array($sqlG)){
$stolpci[] = $rowG;
}
$_variables_count = count($stolpci);
$gidsCanShow=array();
# odstranimo še možne nepotrebne zapise za multigride
if($settings['hideEmptyVar'] == 1){
$allGrids = count($spremenljivka['grids']);
if (count($spremenljivka['grids']) > 0) {
foreach ($spremenljivka['grids'] AS $gid => $grid) {
$cntValidInGrid = 0;
# dodamo dodatne vrstice z labelami grida
if (count($grid['variables']) > 0 ) {
foreach ($grid['variables'] AS $vid => $variable ){
$_sequence = $variable['sequence']; # id kolone z podatki
foreach(SurveyAnalysis::$_FREQUENCYS[$_sequence]['valid'] AS $valid){
$cntValidInGrid+= (int)$valid['cnt'];
}
}
}
# preverjamo ali lahko prikazujemo podkategorije
if((int)$cntValidInGrid > 0) {
$gidsCanShow[$gid] = true;
} else {
$gidsCanShow[$gid] = false;
}
}
}
}
$nArray = array();
if (count($spremenljivka['grids']) > 0)
foreach ($spremenljivka['grids'] AS $gid => $grid) {
$legendTitle = '';
// Kontrola ce ne prikazujemo praznih variabel
if (!isset($gidsCanShow[$gid]) || (isset($gidsCanShow[$gid]) && $gidsCanShow[$gid]== true)){
# dodamo dodatne vrstice z albelami grida
foreach ($grid['variables'] AS $vid => $variable ){
if ($variable['text'] != true && $variable['other'] != true){
$legendTitle = substr($variable['variable'],0,strpos($variable['variable'],'_'));
$_sequence = $variable['sequence']; # id kolone z podatki
// Ce izrisujemo graf za povprecja
if($settings['type'] == 0 || $settings['type'] == 5 || $settings['type'] == 6){
$sum_xi_fi=0;
$N = 0;
$div=0;
if (count($spremenljivka['options']) > 0) {
foreach ( $spremenljivka['options'] as $key => $kategorija) {
$xi = $key;
$fi = SurveyAnalysis::$_FREQUENCYS[$_sequence]['valid'][$key]['cnt'];
$sum_xi_fi += $xi * $fi ;
$N += $fi;
}
}
$avg = ($N > 0) ? $sum_xi_fi / $N : 0;
$nArray[] = $N;
$tempArray = array();
// nastavimo da graf ni prazen
if($N > 0)
$emptyData = false;
$avg = $avg < 1 ? 1 : $avg;
$tempArray['freq'] = $avg;
$tempArray['percent'] = $avg;
$tempArray['valid'] = $avg;
$tempArray['key'] = $variable['variable'];
$text = $spremenljivka['edit_graf'] == 0 ? $variable['naslov'] : $variable['naslov_graf'];
$tempArray['variable'] = $text;
// dodamo vrednosti na desni ce imamo vklopljen diferencial
if(isset($spremenljivka['enota']) && $spremenljivka['enota'] == 1){
$sqlV = sisplet_query("SELECT naslov2 FROM srv_vrednost WHERE spr_id='$spid' AND id='$variable[vr_id]'");
$rowV = mysqli_fetch_array($sqlV);
$tempArray['variable2'] = strip_tags($rowV['naslov2']);
}
$dataArray[] = $tempArray;
}
// izpisujemo navaden graf (ne povprecij)
else{
if (is_countable(SurveyAnalysis::$_FREQUENCYS[$_sequence]['valid']) && count(SurveyAnalysis::$_FREQUENCYS[$_sequence]['valid']) > 0) {
foreach ($stolpci as $key => $stolpec) {
$vkey = $stolpec['vrstni_red'];
// imamo OTHER grid (ne vem, zavrnil...)
if($stolpec['other'] != 0){
$vAnswer = SurveyAnalysis::$_FREQUENCYS[$_sequence]['valid'][$stolpec['other']];
if($vAnswer != null){
$_valid = (SurveyAnalysis::$_FREQUENCYS[$_sequence]['validCnt'] > 0 ) ? 100*$vAnswer['cnt'] / SurveyAnalysis::$_FREQUENCYS[$_sequence]['validCnt'] : 0;
$_percent = (SurveyAnalysis::$_FREQUENCYS[$_sequence]['allCnt'] > 0 ) ? 100*$vAnswer['cnt'] / SurveyAnalysis::$_FREQUENCYS[$_sequence]['allCnt'] : 0;
$tempArray = array();
if($settings['value_type'] == 0){
$nArray[] = SurveyAnalysis::$_FREQUENCYS[$_sequence]['validCnt'];
}
else{
$nArray[] = SurveyAnalysis::$_FREQUENCYS[$_sequence]['allCnt'];
}
// nastavimo da graf ni prazen
if($vAnswer['cnt'] > 0)
$emptyData = false;
$tempArray['freq'] = $vAnswer['cnt'];
$tempArray['percent'] = $_percent;
$tempArray['valid'] = $_valid;
}
// ce missling (-99, -98...) nima nobene vrednosti potem ga ni v tabeli - zato ga rocno napolnimo
else{
$tempArray = array();
$nArray[] = 0;
$tempArray['freq'] = 0;
$tempArray['percent'] = 0;
$tempArray['valid'] = 0;
}
$tempArray['key'] = $vkey;
$text = $stolpec['other'].' '.$stolpec['naslov'];
$tempArray['variable'] = $text;
$textGrid = $spremenljivka['edit_graf'] == 0 ? $grid['variables'][0]['naslov'] : $grid['variables'][0]['naslov_graf'];
$tempArray['grid'] = $textGrid;
$dataArray[] = $tempArray;
$fullPercent[$gridCount] += $tempArray['percent'];
}
// imamo NAVADEN GRID
else{
$vAnswer = SurveyAnalysis::$_FREQUENCYS[$_sequence]['valid'][$vkey];
$_valid = (SurveyAnalysis::$_FREQUENCYS[$_sequence]['validCnt'] > 0 ) ? 100*$vAnswer['cnt'] / SurveyAnalysis::$_FREQUENCYS[$_sequence]['validCnt'] : 0;
$_percent = (SurveyAnalysis::$_FREQUENCYS[$_sequence]['allCnt'] > 0 ) ? 100*$vAnswer['cnt'] / SurveyAnalysis::$_FREQUENCYS[$_sequence]['allCnt'] : 0;
// Za sortiranje po povprecju
$sum_xi_fi=0;
$N = 0;
if (count($spremenljivka['options']) > 0) {
foreach ( $spremenljivka['options'] as $key => $kategorija) {
$xi = $key;
$fi = SurveyAnalysis::$_FREQUENCYS[$_sequence]['valid'][$key]['cnt'];
$sum_xi_fi += $xi * $fi ;
$N += $fi;
}
}
$avg = ($N > 0) ? $sum_xi_fi / $N : 0;
$avg = $avg < 1 ? 1 : $avg;
$tempArray = array();
if($settings['value_type'] == 0){
$nArray[] = SurveyAnalysis::$_FREQUENCYS[$_sequence]['validCnt'];
}
else{
$nArray[] = SurveyAnalysis::$_FREQUENCYS[$_sequence]['allCnt'];
}
// nastavimo da graf ni prazen
if($vAnswer['cnt'] > 0)
$emptyData = false;
$tempArray['avg'] = $avg;
$tempArray['freq'] = $vAnswer['cnt'];
$tempArray['percent'] = $_percent;
$tempArray['valid'] = $_valid;
$tempArray['key'] = $vkey;
$text = ($spremenljivka['edit_graf'] == 0) ? $vAnswer['text'] : $vAnswer['text_graf'];
$tempArray['variable'] = ($text == '') ? $vkey : $text;
$textGrid = $spremenljivka['edit_graf'] == 0 ? $grid['variables'][0]['naslov'] : $grid['variables'][0]['naslov_graf'];
$tempArray['grid'] = $textGrid;
// dodamo vrednosti na desni ce imamo vklopljen diferencial
if(isset($spremenljivka['enota'])&&$spremenljivka['enota'] == 1){
$sqlV = sisplet_query("SELECT naslov2 FROM srv_vrednost WHERE spr_id='$spid' AND id='$variable[vr_id]'");
$rowV = mysqli_fetch_array($sqlV);
$tempArray['variable2'] = strip_tags($rowV['naslov2']);
}
$dataArray[] = $tempArray;
$fullPercent[$gridCount] = isset($fullPercent[$gridCount]) ? $fullPercent[$gridCount] += $tempArray['percent'] : $tempArray['percent'];
}
}
}
}
}
// polnimo array za drugo
if ($variable['text'] == true || $variable['other'] == true){
$_answersOther[] = array('spid'=>$spid,'gid'=>$gid,'vid'=>$vid,'sequence'=>$_sequence);
}
}
$displayMV = ((int)SurveyAnalysis::$missingProfileData['display_mv_type'] === 2) ? TRUE : FALSE;
if ( (count(SurveyAnalysis::$_FREQUENCYS[$_sequence]['invalid'])> 0) && $displayMV) {
foreach (SurveyAnalysis::$_FREQUENCYS[$_sequence]['invalid'] AS $ikey => $iAnswer) {
if ($iAnswer['cnt'] > 0 ) { # izpisujemo samo tiste ki nisno 0
$_percent = (SurveyAnalysis::$_FREQUENCYS[$_sequence]['allCnt'] > 0 ) ? 100*$vAnswer['cnt'] / SurveyAnalysis::$_FREQUENCYS[$_sequence]['allCnt'] : 0;
$_invalid = (SurveyAnalysis::$_FREQUENCYS[$_sequence]['invalidCnt'] > 0 ) ? 100*$vAnswer['cnt'] / SurveyAnalysis::$_FREQUENCYS[$_sequence]['invalidCnt'] : 0;
$tempArray = array();
$tempArray['freq'] = $iAnswer['cnt'];
$tempArray['percent'] = $_percent;
$tempArray['valid'] = $_invalid;
$tempArray['key'] = $ikey;
$tempArray['variable'] = $iAnswer['text'];
$tempArray['grid'] = $grid['variables'][0]['naslov'];
$dataArray[] = $tempArray;
$fullPercent[$gridCount] = isset($fullPercent[$gridCount]) ? $fullPercent[$gridCount] += $tempArray['percent'] : $tempArray['percent'];
}
}
}
$gridCount++;
}
}
// zascita pred praznimi vprasanji (brez variabel)
if(count($spremenljivka['grids']) == 0)
return -1;
//nastavimo numerus, ki se izpise pod legendo
rsort($nArray);
$numerus = ((int)$nArray[0] > 0) ? $nArray[0] : 0;
$DataSet->SetNumerus($numerus);
self::$numerusText = ($settings['value_type'] == 0) ? ' ('.$lang['srv_analiza_frekvence_titleVeljavni'].')' : '';
// Ce prikazujemo POVPRECJA napolnimo podatke samo na koncu
if($settings['type'] == 0 || $settings['type'] == 5 || $settings['type'] == 6){
// Sortiramo podaatke ce je potrebno
if($settings['sort'] == 1){
$tmp = Array();
foreach($dataArray as &$data)
$tmp[] = &$data['freq'];
array_multisort($tmp, SORT_NUMERIC, SORT_DESC, $dataArray);
}
elseif($settings['sort'] == 2){
$tmp = Array();
foreach($dataArray as &$data)
$tmp[] = &$data['freq'];
array_multisort($tmp, SORT_NUMERIC, SORT_ASC, $dataArray);
}
// Poberemo podatke v posamezne tabele
for($i=0; $i 0){
if($settings['value_type'] == 1){
$DataSet->AddPoint($vrednosti,'Vrednosti');
//$DataSet->SetYAxisName($lang['srv_chart_freq']);
}
elseif($settings['value_type'] == 2){
$DataSet->AddPoint($vrednostiPercent,'Vrednosti');
//$DataSet->SetYAxisName($lang['srv_chart_percent']);
}
elseif($settings['value_type'] == 0){
$DataSet->AddPoint($vrednostiValid,'Vrednosti');
//$DataSet->SetYAxisName($lang['srv_chart_valid']);
}
}
else
$DataSet->AddPoint(array(0),'Vrednosti');
$DataSet->AddSerie('Vrednosti');
$DataSet->SetSerieName('Povprečja','Vrednosti');
// Pri povprecjih vedno izpisemo cela imena variabel
$DataSet->AddPoint($vrednostiVariable,"Variable");
//$DataSet->AddPoint($vrednostiKey,"Variable");
// se vrednosti na desni pri sem. diferencialu
if(isset($spremenljivka['enota']) && $spremenljivka['enota'] == 1){
$DataSet->AddPoint($vrednostiVariable2,"Variable2");
$DataSet->SetRightLabelSerie("Variable2");
}
$DataSet->SetAbsciseLabelSerie("Variable");
}
// Prikazujemo navadne podatke
else{
// Normalno obrnjen graf - gridi v stolpcih, variable v legendi (deli stolpcev)
if($settings['rotate'] != 1){
// Sortiramo podaatke ce je potrebno - Po kategorijah
if($settings['sort'] == 1){
$tmp = Array();
// preberemo prve vrednosti iz vsakega stolpca
for($j=0; $j<$_variables_count; $j++){
$offset = $j;
$tmp[] = (int)$dataArray[$offset]['valid'];
}
// sortiramo vrednosti in preberemo kljuce
arsort($tmp);
$sorted_keys = array_keys($tmp);
}
// Sort po povprecjih
elseif($settings['sort'] == 2){
$tmp = Array();
// preberemo povprecje iz vsake prve vrednosti vrstice
for($j=0; $j<$gridCount; $j++){
$offset = $j*$_variables_count;
$tmp[] = $dataArray[$offset]['avg'];
}
// sortiramo vrednosti in preberemo kljuce
arsort($tmp);
$sorted_keys = array_keys($tmp);
}
// Sort po prvi kategoriji
elseif($settings['sort'] == 3){
$tmp = Array();
// preberemo prve vrednosti iz vsake vrstice
for($j=0; $j<$gridCount; $j++){
$offset = $j*$_variables_count;
$tmp[] = (int)$dataArray[$offset]['valid'];
}
// sortiramo vrednosti in preberemo kljuce
arsort($tmp);
$sorted_keys = array_keys($tmp);
}
for($i=0; $i<$_variables_count; $i++){
unset($vrednosti);
unset($vrednostiPercent);
unset($vrednostiValid);
unset($vrednostiKey);
unset($vrednostiVariable);
unset($vrednostiGrid);
unset($vrednostiVariable2);
// Poberemo podatke v posamezne tabele
for($j=0; $j<$gridCount; $j++){
// ce sortiramo uporabimo sortirane kljuce
if($settings['sort'] == 1)
$offset = $sorted_keys[$i] + ($j*$_variables_count);
// sort po povprecjih
elseif($settings['sort'] == 2)
$offset = ($sorted_keys[$j]*$_variables_count) + $i;
// sort po prvi kategoriji
elseif($settings['sort'] == 3)
$offset = ($sorted_keys[$j]*$_variables_count) + $i;
else
$offset = $i + ($j*$_variables_count);
$vrednosti[] = $dataArray[$offset]['freq'];
$vrednostiPercent[] = $dataArray[$offset]['percent'];
$vrednostiValid[] = $dataArray[$offset]['valid'];
$vrednostiKey[] = $dataArray[$offset]['key'];
$vrednostiVariable[] = $dataArray[$offset]['variable'];
$vrednostiGrid[] = $dataArray[$offset]['grid'];
// se vrednosti na desni pri sem. diferencialu
if(isset($spremenljivka['enota']) && $spremenljivka['enota'] == 1)
$vrednostiVariable2[] = $dataArray[$offset]['variable2'];
}
if(count($vrednosti) > 0){
if($settings['value_type'] == 1){
$DataSet->AddPoint($vrednosti,'Vrednosti_'.$i);
//$DataSet->SetYAxisName($lang['srv_chart_freq']);
}
elseif($settings['value_type'] == 2){
$DataSet->AddPoint($vrednostiPercent,'Vrednosti_'.$i);
//$DataSet->SetYAxisName($lang['srv_chart_percent']);
}
elseif($settings['value_type'] == 0){
$DataSet->AddPoint($vrednostiValid,'Vrednosti_'.$i);
//$DataSet->SetYAxisName($lang['srv_chart_valid']);
}
}
else
$DataSet->AddPoint(array(0),'Vrednosti_'.$i);
$DataSet->AddSerie('Vrednosti_'.$i);
$DataSet->SetSerieName($vrednostiVariable[0],'Vrednosti_'.$i);
}
// Vedno izpisemo cela imena variabel
$DataSet->AddPoint($vrednostiGrid,"Variable");
// se vrednosti na desni pri sem. diferencialu
if(isset($spremenljivka['enota']) && $spremenljivka['enota'] == 1){
$DataSet->AddPoint($vrednostiVariable2,"Variable2");
$DataSet->SetRightLabelSerie("Variable2");
}
$DataSet->SetAbsciseLabelSerie("Variable");
}
// Obratno obrnjen graf - gridi v legendi (deli stolpca), variable v stolpcih - default ce imamo samo en grid
else{
// prej moramo napolniti imena serij (variabel)
for($i=0; $i<$gridCount; $i++){
$vrednostiGrid[] = $dataArray[$i*$_variables_count]['grid'];
}
// Sortiramo podaatke ce je potrebno
if($settings['sort'] == 1){
$tmp = Array();
// preberemo prve vrednosti iz vsakega stolpca
for($j=0; $j<$gridCount; $j++){
$offset = $j*$_variables_count;
$tmp[] = (int)$dataArray[$offset]['valid'];
}
// sortiramo vrednosti in preberemo kljuce
arsort($tmp);
$sorted_keys = array_keys($tmp);
}
// Sort po prvi kategoriji
elseif($settings['sort'] == 3){
$tmp = Array();
// preberemo prve vrednosti iz vsake vrstice
for($j=0; $j<$_variables_count; $j++){
$offset = $j;
$tmp[] = (int)$dataArray[$offset]['valid'];
}
// sortiramo vrednosti in preberemo kljuce
arsort($tmp);
$sorted_keys = array_keys($tmp);
}
for($i=0; $i<$gridCount; $i++){
unset($vrednosti);
unset($vrednostiPercent);
unset($vrednostiValid);
unset($vrednostiKey);
unset($vrednostiVariable);
unset($vrednostiVariable2);
// Poberemo podatke v posamezne tabele
for($j=0; $j<$_variables_count; $j++){
// ce sortiramo uporabimo sortirane kljuce
if($settings['sort'] == 1)
$offset = ($sorted_keys[$i]*$_variables_count) + $j;
// sort po prvi kategoriji
elseif($settings['sort'] == 3)
$offset = $sorted_keys[$j] + ($i*$_variables_count);
else
$offset = ($i*$_variables_count) + $j;
$vrednosti[] = $dataArray[$offset]['freq'];
$vrednostiPercent[] = $dataArray[$offset]['percent'];
$vrednostiValid[] = $dataArray[$offset]['valid'];
$vrednostiKey[] = $dataArray[$offset]['key'];
$vrednostiVariable[] = $dataArray[$offset]['variable'];
// se vrednosti na desni pri sem. diferencialu
if(isset($spremenljivka['enota']) && $spremenljivka['enota'] == 1)
$vrednostiVariable2[] = $dataArray[$offset]['variable2'];
}
if(count($vrednosti) > 0){
if($settings['value_type'] == 1){
$DataSet->AddPoint($vrednosti,'Vrednosti_'.$i);
//$DataSet->SetYAxisName($lang['srv_chart_freq']);
}
elseif($settings['value_type'] == 2){
$DataSet->AddPoint($vrednostiPercent,'Vrednosti_'.$i);
//$DataSet->SetYAxisName($lang['srv_chart_percent']);
}
elseif($settings['value_type'] == 0){
$DataSet->AddPoint($vrednostiValid,'Vrednosti_'.$i);
//$DataSet->SetYAxisName($lang['srv_chart_valid']);
}
}
else
$DataSet->AddPoint(array(0),'Vrednosti_'.$i);
$DataSet->AddSerie('Vrednosti_'.$i);
if($settings['sort'] == 1)
$DataSet->SetSerieName($vrednostiGrid[$sorted_keys[$i]],'Vrednosti_'.$i);
else
$DataSet->SetSerieName($vrednostiGrid[$i],'Vrednosti_'.$i);
}
// Vedno izpisemo cela imena variabel
$DataSet->AddPoint($vrednostiVariable,"Variable");
// se vrednosti na desni pri sem. diferencialu
if(isset($spremenljivka['enota']) && $spremenljivka['enota'] == 1){
$DataSet->AddPoint($vrednostiVariable2,"Variable2");
$DataSet->SetRightLabelSerie("Variable2");
}
$DataSet->SetAbsciseLabelSerie("Variable");
}
}
if( $settings['value_type'] != 1 && $settings['type'] != 0 && $settings['type'] != 6 ){
$DataSet->SetYAxisUnit("%");
$DataSet->SetYAxisFormat("number");
}
}
// napolnimo podatke za NUMBER
elseif($spremenljivka['tip'] == 7 || $spremenljivka['tip'] == 22){
$dataArray = array();
$has_decimal = false;
$i=0;
$N=0;
if (count($spremenljivka['grids']) > 0)
foreach ($spremenljivka['grids'] AS $gid => $grid) {
$legendTitle = '';
$_variables_count = count($grid['variables']);
$field = 0;
$avg_count = 0;
$avg_sum = 0;
$avg_count2 = 0;
$avg_sum2 = 0;
# dodamo dodatne vrstice z albelami grida
if ($_variables_count > 0 )
foreach ($grid['variables'] AS $vid => $variable ){
$legendTitle = substr($variable['variable'],0,strpos($variable['variable'],'_'));
$var_title[] = $spremenljivka['edit_graf'] == 0 ? $variable['naslov'] : $variable['naslov_graf'];
$_sequence = $variable['sequence']; # id kolone z podatki
if ($spremenljivka['tip'] == 22 || (($variable['text'] != true && $variable['other'] != true) || (in_array($spremenljivka['tip'],array(4,8,21))))){
if (isset(SurveyAnalysis::$_FREQUENCYS[$_sequence]['valid']) && is_countable(SurveyAnalysis::$_FREQUENCYS[$_sequence]['valid']) && count(SurveyAnalysis::$_FREQUENCYS[$_sequence]['valid']) > 0) {
if($field == 0)
$N = SurveyAnalysis::$_FREQUENCYS[$_sequence]['validCnt'];
foreach ( SurveyAnalysis::$_FREQUENCYS[$_sequence]['valid'] AS $vkey => $vAnswer) {
if ($vAnswer['cnt'] > 0 || true) { # izpisujemo samo tiste ki nisno 0
$_valid = (SurveyAnalysis::$_FREQUENCYS[$_sequence]['validCnt'] > 0 ) ? 100*$vAnswer['cnt'] / SurveyAnalysis::$_FREQUENCYS[$_sequence]['validCnt'] : 0;
$_percent = (SurveyAnalysis::$_FREQUENCYS[$_sequence]['allCnt'] > 0 ) ? 100*$vAnswer['cnt'] / SurveyAnalysis::$_FREQUENCYS[$_sequence]['allCnt'] : 0;
$tempArray = array();
$tempArray['freq'] = $vAnswer['cnt'];
$tempArray['percent'] = $_percent;
$tempArray['valid'] = $_valid;
$tempArray['key'] = $vkey;
if(floor($vkey) != $vkey)
$has_decimal = true;
// racunamo povprecje (za prvo variablo)
if($field == 0){
// ce je znotraj nastavljenih mej
if( ($settings['max'] == '' || ($settings['open_up'] == 1 || (int)$vAnswer['text'] <= (int)$settings['max']))
&& ($settings['min'] == '' || ($settings['open_down'] == 1 || (int)$vAnswer['text'] >= (int)$settings['min'])) ){
$avg_count += $vAnswer['cnt'];
$avg_sum += $vAnswer['cnt'] * (int)$vAnswer['text'];
}
else{
$N--;
}
}
// racunamo povprecje (samo za drugo variablo)
if($field == 1){
// ce je znotraj nastavljenih mej
if( ($settings['max'] == '' || ($settings['open_up'] == 1 || (int)$vAnswer['text'] <= (int)$settings['max']))
&& ($settings['min'] == '' || ($settings['open_down'] == 1 || (int)$vAnswer['text'] >= (int)$settings['min'])) ){
$avg_count2 += $vAnswer['cnt'];
$avg_sum2 += $vAnswer['cnt'] * (int)$vAnswer['text'];
}
else{
$N--;
}
}
// nastavimo da graf ni prazen
$emptyData = false;
$text = $vAnswer['text'];
$tempArray['variable'] = $text;
$tempArray['field'] = $field;
$dataArray[] = $tempArray;
}
}
}
}
$field++;
}
$displayMV = ((int)SurveyAnalysis::$missingProfileData['display_mv_type'] === 2) ? TRUE : FALSE;
if ( (count(SurveyAnalysis::$_FREQUENCYS[$_sequence]['invalid'])> 0) && $displayMV) {
foreach (SurveyAnalysis::$_FREQUENCYS[$_sequence]['invalid'] AS $ikey => $iAnswer) {
if ($iAnswer['cnt'] > 0 ) { # izpisujemo samo tiste ki nisno 0
$_percent = (SurveyAnalysis::$_FREQUENCYS[$_sequence]['allCnt'] > 0 ) ? 100*$vAnswer['cnt'] / SurveyAnalysis::$_FREQUENCYS[$_sequence]['allCnt'] : 0;
$_invalid = (SurveyAnalysis::$_FREQUENCYS[$_sequence]['invalidCnt'] > 0 ) ? 100*$vAnswer['cnt'] / SurveyAnalysis::$_FREQUENCYS[$_sequence]['invalidCnt'] : 0;
$tempArray = array();
//$N = ($settings['value_type'] == 2) ? SurveyAnalysis::$_FREQUENCYS[$_sequence]['invalidCnt'] : SurveyAnalysis::$_FREQUENCYS[$_sequence]['allCnt'];
$tempArray['freq'] = $iAnswer['cnt'];
$tempArray['percent'] = $_percent;
$tempArray['valid'] = $_invalid;
$tempArray['key'] = $ikey;
$tempArray['variable'] = $iAnswer['text'];
$dataArray[] = $tempArray;
}
}
}
$i++;
}
// zascita pred praznimi vprasanji (brez variabel)
if($_variables_count == 0)
return -1;
//polnimo podatke
$DataSet = new pData;
// nastavimo NUMERUS, ki se izpise pod legendo
$N = ((int)$N > 0) ? $N : 0;
$DataSet->SetNumerus($N);
// nastavimo POVPRECJE
$avg = ($avg_count > 0) ? $avg_sum / $avg_count : 0;
$DataSet->SetAverage(round($avg, 1));
// Povprecje za 2. variablo (rabimo pri grafu povprecja)
$avg2 = ($avg_count2 > 0) ? $avg_sum2 / $avg_count2 : 0;
// Sortiramo podatke - ce imamo izpis vsakega vnosa posebej sortiramo po freq, ce pa po skupinah pa po key
if($settings['type'] <= 2){
$tmp = Array();
foreach($dataArray as &$data)
$tmp[] = &$data['key'];
array_multisort($tmp, SORT_NUMERIC, SORT_ASC, $dataArray);
}
elseif($settings['sort'] == 1){
$tmp = Array();
foreach($dataArray as &$data)
$tmp[] = &$data['freq'];
array_multisort($tmp, SORT_NUMERIC, SORT_DESC, $dataArray);
}
elseif($settings['sort'] == 2){
$tmp = Array();
foreach($dataArray as &$data)
$tmp[] = &$data['freq'];
array_multisort($tmp, SORT_NUMERIC, SORT_ASC, $dataArray);
}
$max = isset($dataArray[count($dataArray,0)-1]['variable']) ? (double)$dataArray[count($dataArray,0)-1]['variable'] : 0;
$min = isset($dataArray[0]['variable']) ? (double)$dataArray[0]['variable'] : 0;
$stIntervalov = ((int)$settings['interval'] == 0 ? 10 : (int)$settings['interval']);
// Ce imamo napredno napredne intervale
if($settings['limits']['advanced_settings'] == 1){
$limits = $settings['limits'];
$max = $limits['interval_'. ($stIntervalov-1) ]['max'];
$min = $limits['interval_0']['min'];
}
// Ce imamo osnovne intervale
else{
// Nastavimo custom zgornjo mejo skale (razen v primeru ko ne ignoriramo vrednosti ki padejo ven in ce je max vnos vecji od nastavljenega max)
if($settings['max'] != '' /*&& ($settings['open_up'] == 0 || (int)$settings['max'] > $max)*/)
$max = (double)$settings['max'];
// Nastavimo custom spodnjo mejo skale (razen v primeru ko ne ignoriramo vrednosti ki padejo ven in ce je min vnos manjsi od nastavljenega min)
if($settings['min'] != '' /*&& ($settings['open_down'] == 0 || (int)$settings['min'] < $min)*/)
$min = (double)$settings['min'];
$stIntervalov = ($stIntervalov == -1 ? $max-$min : $stIntervalov);
$part = ($max-$min) / $stIntervalov;
if(!$has_decimal)
$part = ($part < 1) ? 1 : round($part);
}
// Poberemo podatke v posamezne tabele - po intervalih oz normalno
if($settings['type'] <= 2){
// Ce imamo polodprt intrerval navzdol
if($settings['open_down'] == 1){
$count = 0;
$percent = 0;
$valid = 0;
// loop cez vse podatke
for($i=0; $i 0 ? $min + ($interval * $part) : $min);
}
else{
$maxVal = ($interval < ($stIntervalov-1) ? $min + (($interval+1) * $part) : $max);
$minVal = ($interval > 0 ? $min + ($interval * $part) + 1 : $min);
}
}
// prekinemo ce zaradi zaokrozevanja pride do min > max
if($minVal > $maxVal)
break;
// loop cez vse podatke
for($i=0; $i= $minVal && $dataArray[$i]['field'] == 0){
$count += $dataArray[$i]['freq'];
$percent += $dataArray[$i]['percent'];
$valid += $dataArray[$i]['valid'];
}
}
// vnesemo podatke za interval
$vrednosti[] = $count;
$vrednostiPercent[] = $percent;
$vrednostiValid[] = $valid;
// Ce imamo napredne intervale (custom dolocene labele)
if($settings['limits']['advanced_settings'] == 1 && $limits['interval_'.$interval]['label'] != ''){
$vrednostiKey[] = $limits['interval_'.$interval]['label'];
$vrednostiVariable[] = $limits['interval_'.$interval]['label'];
}
elseif($minVal == $maxVal){
$vrednostiKey[] = $minVal;
$vrednostiVariable[] = $minVal;
}
else{
$vrednostiKey[] = $minVal.'-'.$maxVal;
$vrednostiVariable[] = $minVal.'-'.$maxVal;
}
}
// Ce imamo polodprt intrerval navzgor
if($settings['open_up'] == 1){
$count = 0;
$percent = 0;
$valid = 0;
// loop cez vse podatke
for($i=0; $i $max && $dataArray[$i]['field'] == 0){
$count += $dataArray[$i]['freq'];
$percent += $dataArray[$i]['percent'];
$valid += $dataArray[$i]['valid'];
}
}
// vnesemo podatke za interval
$vrednosti[] = $count;
$vrednostiPercent[] = $percent;
$vrednostiValid[] = $valid;
$vrednostiKey[] = $lang['srv_chart_more'].' '.$max;
$vrednostiVariable[] = $lang['srv_chart_more'].' '.$max;
}
//ponovimo ce imamo 2 polja
if($field == 2){
// Ce imamo polodprt intrerval navzdol
if($settings['open_down'] == 1){
$count = 0;
$percent = 0;
$valid = 0;
// loop cez vse podatke
for($i=0; $i 0 ? $min + ($interval * $part) : $min);
}
else{
$maxVal = ($interval < ($stIntervalov-1) ? $min + (($interval+1) * $part) : $max);
$minVal = ($interval > 0 ? $min + ($interval * $part) + 1 : $min);
}
}
// prekinemo ce zaradi zaokrozevanja pride do min > max
if($minVal > $maxVal)
break;
// loop cez vse podatke
for($i=0; $i= $minVal && $dataArray[$i]['field'] == 1){
$count += $dataArray[$i]['freq'];
$percent += $dataArray[$i]['percent'];
$valid += $dataArray[$i]['valid'];
}
}
// vnesemo podatke za interval
$vrednosti2[] = $count;
$vrednostiPercent2[] = $percent;
$vrednostiValid2[] = $valid;
}
// Ce imamo polodprt intrerval navzgor
if($settings['open_up'] == 1){
$count = 0;
$percent = 0;
$valid = 0;
// loop cez vse podatke
for($i=0; $i $max && $dataArray[$i]['field'] == 1){
$count += $dataArray[$i]['freq'];
$percent += $dataArray[$i]['percent'];
$valid += $dataArray[$i]['valid'];
}
}
// vnesemo podatke za interval
$vrednosti2[] = $count;
$vrednostiPercent2[] = $percent;
$vrednostiValid2[] = $valid;
}
}
}
else{
for($i=0; $i 0){
// Graf povprecja
if($settings['type'] == 9){
$DataSet->AddPoint(round($avg, 1),'Vrednosti');
if($field == 2)
$DataSet->AddPoint(round($avg2, 1),'Vrednosti2');
}
else{
if($settings['value_type'] == 0){
$DataSet->AddPoint($vrednosti,'Vrednosti');
if($field == 2)
$DataSet->AddPoint($vrednosti2,'Vrednosti2');
//$DataSet->SetYAxisName($lang['srv_chart_freq']);
}
elseif($settings['value_type'] == 1){
$DataSet->AddPoint($vrednostiPercent,'Vrednosti');
if($field == 2)
$DataSet->AddPoint($vrednostiPercent2,'Vrednosti2');
//$DataSet->SetYAxisName($lang['srv_chart_percent']);
}
elseif($settings['value_type'] == 2){
$DataSet->AddPoint($vrednostiValid,'Vrednosti');
if($field == 2)
$DataSet->AddPoint($vrednostiValid2,'Vrednosti2');
//$DataSet->SetYAxisName($lang['srv_chart_valid']);
}
}
}
else
$DataSet->AddPoint(array(0),'Vrednosti');
$DataSet->AddSerie('Vrednosti');
$var_title[0] = ($var_title[0] == '' ? 'Vrednosti' : $var_title[0]);
$DataSet->SetSerieName($var_title[0],'Vrednosti');
if($field == 2){
$DataSet->AddSerie('Vrednosti2');
$var_title[1] = ($var_title[1] == '' ? 'Vrednosti 2' : $var_title[1]);
$DataSet->SetSerieName($var_title[1],'Vrednosti2');
}
// Vedno izpisemo cela imena variabel
if($settings['type'] != 9)
$DataSet->AddPoint($vrednostiVariable,"Variable");
//$DataSet->AddPoint($vrednostiKey,"Variable");
$DataSet->SetAbsciseLabelSerie("Variable");
if($settings['value_type'] > 0){
$DataSet->SetYAxisUnit("%");
$DataSet->SetYAxisFormat("number");
}
}
// napolnimo podatke za DATUM
elseif($spremenljivka['tip'] == 8){
$dataArray = array();
$i=0;
$N=0;
if (count($spremenljivka['grids']) > 0)
foreach ($spremenljivka['grids'] AS $gid => $grid) {
$legendTitle = '';
$_variables_count = count($grid['variables']);
# dodamo dodatne vrstice z albelami grida
if ($_variables_count > 0 )
foreach ($grid['variables'] AS $vid => $variable ){
$legendTitle = substr($variable['variable'],0,strpos($variable['variable'],'_'));
$var_title[] = $spremenljivka['edit_graf'] == 0 ? $variable['naslov'] : $variable['naslov_graf'];
$_sequence = $variable['sequence']; # id kolone z podatki
if (($variable['text'] != true && $variable['other'] != true) || (in_array($spremenljivka['tip'],array(4,8,21)))){
if (is_countable(SurveyAnalysis::$_FREQUENCYS[$_sequence]['valid']) && count(SurveyAnalysis::$_FREQUENCYS[$_sequence]['valid']) > 0) {
$N = SurveyAnalysis::$_FREQUENCYS[$_sequence]['validCnt'];
foreach ( SurveyAnalysis::$_FREQUENCYS[$_sequence]['valid'] AS $vkey => $vAnswer) {
if ($vAnswer['cnt'] > 0 || true) { # izpisujemo samo tiste ki nisno 0
$_valid = (SurveyAnalysis::$_FREQUENCYS[$_sequence]['validCnt'] > 0 ) ? 100*$vAnswer['cnt'] / SurveyAnalysis::$_FREQUENCYS[$_sequence]['validCnt'] : 0;
$_percent = (SurveyAnalysis::$_FREQUENCYS[$_sequence]['allCnt'] > 0 ) ? 100*$vAnswer['cnt'] / SurveyAnalysis::$_FREQUENCYS[$_sequence]['allCnt'] : 0;
$tempArray = array();
// ce je zunaj nastavljenih mej
if( ($settings['max'] != '' && ($settings['open_up'] == 0 && (int)$vAnswer['text'] > (int)$settings['max']))
|| ($settings['min'] != '' && ($settings['open_down'] == 0 && (int)$vAnswer['text'] < (int)$settings['min'])) ){
$N--;
}
$date = strtotime($vkey);
$tempArray['day'] = date('j', $date);
$tempArray['month'] = date('n', $date);
$tempArray['year'] = date('Y', $date);
$tempArray['freq'] = $vAnswer['cnt'];
// nastavimo da graf ni prazen
$emptyData = false;
$text = $vAnswer['text'];
$tempArray['variable'] = $text;
$dataArray[] = $tempArray;
}
}
}
}
}
$displayMV = ((int)SurveyAnalysis::$missingProfileData['display_mv_type'] === 2) ? TRUE : FALSE;
if ( (count(SurveyAnalysis::$_FREQUENCYS[$_sequence]['invalid'])> 0) && $displayMV) {
foreach (SurveyAnalysis::$_FREQUENCYS[$_sequence]['invalid'] AS $ikey => $iAnswer) {
if ($iAnswer['cnt'] > 0 ) { # izpisujemo samo tiste ki nisno 0
$_percent = (SurveyAnalysis::$_FREQUENCYS[$_sequence]['allCnt'] > 0 ) ? 100*$vAnswer['cnt'] / SurveyAnalysis::$_FREQUENCYS[$_sequence]['allCnt'] : 0;
$_invalid = (SurveyAnalysis::$_FREQUENCYS[$_sequence]['invalidCnt'] > 0 ) ? 100*$vAnswer['cnt'] / SurveyAnalysis::$_FREQUENCYS[$_sequence]['invalidCnt'] : 0;
$tempArray = array();
//$N = ($settings['value_type'] == 2) ? SurveyAnalysis::$_FREQUENCYS[$_sequence]['invalidCnt'] : SurveyAnalysis::$_FREQUENCYS[$_sequence]['allCnt'];
$date = strtotime($ikey);
$tempArray['day'] = date('j', $date);
$tempArray['month'] = date('n', $date);
$tempArray['year'] = date('Y', $date);
$tempArray['freq'] = $iAnswer['cnt'];
$tempArray['variable'] = $iAnswer['text'];
$dataArray[] = $tempArray;
}
}
}
$i++;
}
if($settings['value_type'] == 0)
$key = 'day';
elseif($settings['value_type'] == 1)
$key = 'month';
else
$key = 'year';
//polnimo podatke
$DataSet = new pData;
//nastavimo numerus, ki se izpise pod legendo
$N = ((int)$N > 0) ? $N : 0;
$DataSet->SetNumerus($N);
// Sortiramo podatke - ce imamo izpis vsakega vnosa posebej sortiramo po datumu, ce pa po skupinah pa po key
if($settings['type'] < 3){
if($settings['value_type'] == 0){
$tmp = Array();
foreach($dataArray as &$data)
$tmp[] = &$data['day'];
array_multisort($tmp, SORT_NUMERIC, SORT_ASC, $dataArray);
}
elseif($settings['value_type'] == 1){
$tmp = Array();
foreach($dataArray as &$data)
$tmp[] = &$data['month'];
array_multisort($tmp, SORT_NUMERIC, SORT_ASC, $dataArray);
}
elseif($settings['value_type'] == 2){
$tmp = Array();
foreach($dataArray as &$data)
$tmp[] = &$data['year'];
array_multisort($tmp, SORT_NUMERIC, SORT_ASC, $dataArray);
}
}
elseif($settings['sort'] == 1 ){
$tmp = Array();
foreach($dataArray as &$data)
$tmp[] = &$data['freq'];
array_multisort($tmp, SORT_NUMERIC, SORT_DESC, $dataArray);
}
elseif($settings['sort'] == 2 ){
$tmp = Array();
foreach($dataArray as &$data)
$tmp[] = &$data['freq'];
array_multisort($tmp, SORT_NUMERIC, SORT_ASC, $dataArray);
}
$max = (int)$dataArray[count($dataArray,0)-1][$key];
$min = (int)$dataArray[0][$key];
$stIntervalov = ((int)$settings['interval'] == 0 ? 10 : (int)$settings['interval']);
// Ce imamo napredno napredne intervale
if($settings['limits']['advanced_settings'] == 1){
$limits = $settings['limits'];
$max = $limits['interval_'. ($stIntervalov-1) ]['max'];
$min = $limits['interval_0']['min'];
}
// Ce imamo osnovne intervale
else{
// Nastavimo custom zgornjo mejo skale (razen v primeru ko ne ignoriramo vrednosti ki padejo ven in ce je max vnos vecji od nastavljenega max)
if($settings['max'] != '' /*&& ($settings['open_up'] == 0 || (int)$settings['max'] > $max)*/)
$max = (int)$settings['max'];
// Nastavimo custom spodnjo mejo skale (razen v primeru ko ne ignoriramo vrednosti ki padejo ven in ce je min vnos manjsi od nastavljenega min)
if($settings['min'] != '' /*&& ($settings['open_down'] == 0 || (int)$settings['min'] < $min)*/)
$min = (int)$settings['min'];
$stIntervalov = ($stIntervalov == -1 ? $max-$min : $stIntervalov);
$part = round( ($max-$min) / $stIntervalov );
}
// Poberemo podatke v posamezne tabele - po intervalih oz normalno
if($settings['type'] < 3){
// Ce imamo polodprt intrerval navzdol
if($settings['open_down'] == 1){
$value = 0;
// loop cez vse podatke
for($i=0; $i 0 ? $min + ($interval * $part) + 1 : $min);
}
// prekinemo ce zaradi zaokrozevanja pride do min > max
if($minVal > $maxVal)
break;
// loop cez vse podatke
for($i=0; $i= $minVal){
$value ++;
}
}
// vnesemo podatke za interval
$vrednosti[] = $value;
// Ce imamo napredne intervale (custom dolocene labele)
if($settings['limits']['advanced_settings'] == 1 && $limits['interval_'.$interval]['label'] != ''){
$vrednostiVariable[] = $limits['interval_'.$interval]['label'];
}
elseif($minVal == $maxVal){
$vrednostiVariable[] = $minVal;
}
else{
$vrednostiVariable[] = $minVal.'-'.$maxVal;
}
}
// Ce imamo polodprt intrerval navzgor
if($settings['open_up'] == 1){
$value = 0;
// loop cez vse podatke
for($i=0; $i $max){
$value ++;
}
}
// vnesemo podatke za interval
$vrednosti[] = $value;
$vrednostiVariable[] = $lang['srv_chart_more'].' '.$max;
}
}
else{
for($i=0; $i 0){
$DataSet->AddPoint($vrednosti,'Vrednosti');
}
else
$DataSet->AddPoint(array(0),'Vrednosti');
$DataSet->AddSerie('Vrednosti');
$var_title[0] = ($var_title[0] == '' ? 'Vrednosti' : $var_title[0]);
$DataSet->SetSerieName($var_title[0],'Vrednosti');
// Vedno izpisemo cela imena variabel
$DataSet->AddPoint($vrednostiVariable,"Variable");
$DataSet->SetAbsciseLabelSerie("Variable");
}
// napolnimo podatke za MULTICHECKBOX
elseif($spremenljivka['tip'] == 16){
$DataSet = new pData;
$dataArray = array();
$fullPercent = array();
$gidsCanShow = array();
$vrednostiGrid = array();
# odstranimo še možne nepotrebne zapise
if($settings['hideEmptyVar'] == 1){
$allGrids = count($spremenljivka['grids']);
if (count($spremenljivka['grids']) > 0) {
foreach ($spremenljivka['grids'] AS $gid => $grid) {
$cntValidInGrid = 0;
# dodamo dodatne vrstice z labelami grida
if (count($grid['variables']) > 0 ) {
foreach ($grid['variables'] AS $vid => $variable ){
$_sequence = $variable['sequence']; # id kolone z podatki
foreach(SurveyAnalysis::$_FREQUENCYS[$_sequence]['valid'] AS $valid){
$cntValidInGrid+= (int)$valid['cnt'];
}
}
}
# preverjamo ali lahko prikazujemo podkategorije
if((int)$cntValidInGrid > 0) {
$gidsCanShow[$gid] = true;
}
else {
$gidsCanShow[$gid] = false;
}
}
}
}
$gridCount=0;
$_variables_count=0;
$nValid = array();
$nAll = 0;
$nNavedbe = array();
if (count($spremenljivka['grids']) > 0)
foreach ($spremenljivka['grids'] AS $gid => $grid) {
$legendTitle = '';
// Kontrola ce ne prikazujemo praznih variabel
if (!isset($gidsCanShow[$gid]) || (isset($gidsCanShow[$gid]) && $gidsCanShow[$gid]== true)){
$_variables_count=0;
# dodamo dodatne vrstice z albelami grida
foreach ($grid['variables'] AS $vid => $variable ){
if ($variable['text'] != true && $variable['other'] != true){
$legendTitle = substr($variable['variable'],0,strpos($variable['variable'],'_'));
$_sequence = $variable['sequence']; # id kolone z podatki
$legendTitle = substr($variable['variable'],0,strpos($variable['variable'],'_'));
$vAnswer = SurveyAnalysis::$_FREQUENCYS[$_sequence]['valid'][1]['cnt'];
$_valid = ( isset(SurveyAnalysis::$_FREQUENCYS[$_sequence]['validCnt']) && SurveyAnalysis::$_FREQUENCYS[$_sequence]['validCnt'] > 0 ) ? 100*$vAnswer / SurveyAnalysis::$_FREQUENCYS[$_sequence]['validCnt'] : 0;
$_percent = ( isset(SurveyAnalysis::$_FREQUENCYS[$_sequence]['allCnt']) && SurveyAnalysis::$_FREQUENCYS[$_sequence]['allCnt'] > 0 ) ? 100*$vAnswer / SurveyAnalysis::$_FREQUENCYS[$_sequence]['allCnt'] : 0;
$tempArray = array();
$nValid[] = isset(SurveyAnalysis::$_FREQUENCYS[$_sequence]['validCnt']) ? SurveyAnalysis::$_FREQUENCYS[$_sequence]['validCnt'] : 0;
$nAll = SurveyAnalysis::$_FREQUENCYS[$_sequence]['allCnt'];
$nNavedbe[$gid] += SurveyAnalysis::$_FREQUENCYS[$_sequence]['valid'][1]['cnt'];
$tempArray['freq'] = SurveyAnalysis::$_FREQUENCYS[$_sequence]['valid'][1]['cnt'];
$tempArray['percent'] = $_percent;
$tempArray['valid'] = $_valid;
// nastavimo da graf ni prazen
if($vAnswer > 0)
$emptyData = false;
$tempArray['key'] = $variable['variable'];
$text = $spremenljivka['edit_graf'] == 0 ? $variable['naslov'] : $variable['naslov_graf'];
$tempArray['variable'] = $text;
$textGrid = $spremenljivka['edit_graf'] == 0 ? $grid['naslov'] : $grid['naslov_graf'];
$tempArray['grid'] = $textGrid;
$dataArray[] = $tempArray;
if(isset($fullPercent[$gridCount]))
$fullPercent[$gridCount] += $tempArray['percent'];
else
$fullPercent[$gridCount] = $tempArray['percent'];
if(isset($fullPercentReverse[$_variables_count]))
$fullPercentReverse[$_variables_count] += $tempArray['percent'];
else
$fullPercentReverse[$_variables_count] = $tempArray['percent'];
$_variables_count++;
}
// polnimo array za drugo
if ($variable['text'] == true || $variable['other'] == true){
$_answersOther[] = array('spid'=>$spid,'gid'=>$gid,'vid'=>$vid,'sequence'=>$_sequence);
}
}
$displayMV = ((int)SurveyAnalysis::$missingProfileData['display_mv_type'] === 2) ? TRUE : FALSE;
if ( (count(SurveyAnalysis::$_FREQUENCYS[$_sequence]['invalid'])> 0) && $displayMV) {
foreach (SurveyAnalysis::$_FREQUENCYS[$_sequence]['invalid'] AS $ikey => $iAnswer) {
if ($iAnswer['cnt'] > 0 ) { # izpisujemo samo tiste ki nisno 0
$_percent = (SurveyAnalysis::$_FREQUENCYS[$_sequence]['allCnt'] > 0 ) ? 100*$vAnswer['cnt'] / SurveyAnalysis::$_FREQUENCYS[$_sequence]['allCnt'] : 0;
$_invalid = (SurveyAnalysis::$_FREQUENCYS[$_sequence]['invalidCnt'] > 0 ) ? 100*$vAnswer['cnt'] / SurveyAnalysis::$_FREQUENCYS[$_sequence]['invalidCnt'] : 0;
$tempArray = array();
$tempArray['freq'] = $iAnswer['cnt'];
$tempArray['percent'] = $_percent;
$tempArray['valid'] = $_invalid;
$tempArray['key'] = $ikey;
$tempArray['variable'] = $iAnswer['text'];
$tempArray['grid'] = $grid['naslov'];
$fullPercent[$gridCount] += $tempArray['percent'];
$fullPercentReverse[$_variables_count] += $tempArray['percent'];
$dataArray[] = $tempArray;
}
}
}
$gridCount++;
}
}
// zascita pred praznimi vprasanji (brez variabel)
if(count($spremenljivka['grids']) == 0)
return -1;
// Normalno obrnjen graf - gridi v stolpcih, variable v legendi (deli stolpcev)
if($settings['rotate'] != 1){
// Sortiramo podaatke ce je potrebno
if($settings['sort'] == 1){
$tmp = Array();
// preberemo prve vrednosti iz vsakega stolpca
for($j=0; $j<$_variables_count; $j++){
$offset = $j;
$tmp[] = (int)$dataArray[$offset]['valid'];
}
// sortiramo vrednosti in preberemo kljuce
arsort($tmp);
$sorted_keys = array_keys($tmp);
}
// Sort po prvi kategoriji
elseif($settings['sort'] == 3){
$tmp = Array();
// preberemo prve vrednosti iz vsake vrstice
for($j=0; $j<$gridCount; $j++){
$offset = $j*$_variables_count;
$tmp[] = (int)$dataArray[$offset]['valid'];
}
// sortiramo vrednosti in preberemo kljuce
arsort($tmp);
$sorted_keys = array_keys($tmp);
}
// Prikazujemo podatke
for($i=0; $i<$_variables_count; $i++){
unset($vrednosti);
unset($vrednostiPercent);
unset($vrednostiValid);
unset($vrednostiKey);
unset($vrednostiVariable);
unset($vrednostiGrid);
// Poberemo podatke v posamezne tabele
for($j=0; $j<$gridCount; $j++){
// ce sortiramo uporabimo sortirane kljuce
if($settings['sort'] == 1)
$offset = $sorted_keys[$i] + ($j*$_variables_count);
// sort po prvi kategoriji
elseif($settings['sort'] == 3)
$offset = ($sorted_keys[$j]*$_variables_count) + $i;
else
$offset = $i + ($j*$_variables_count);
// Enote
if($settings['base'] != 1){
$vrednosti[] = $dataArray[$offset]['freq'];
$vrednostiPercent[] = $dataArray[$offset]['percent'];
$vrednostiValid[] = $dataArray[$offset]['valid'];
//nastavimo numerus, ki se izpise pod legendo
if($settings['value_type'] == 0){
rsort($nValid);
$numerus = ((int)$nValid[0] > 0) ? $nValid[0] : 0;
$DataSet->SetNumerus($numerus);
self::$numerusText = ' ('.$lang['srv_analiza_frekvence_titleVeljavni'].')';
}
else
$numerus = ((int)$nAll > 0) ? $nAll : 0;
$DataSet->SetNumerus($numerus);
}
// Navedbe
else{
$percent = ($fullPercent[$j] * $dataArray[$offset]['percent'] > 0) ? 100 / $fullPercent[$j] * $dataArray[$offset]['percent'] : 0;
$vrednosti[] = $dataArray[$offset]['freq'];
$vrednostiPercent[] = $percent;
$vrednostiValid[] = $percent;
//nastavimo numerus, ki se izpise pod legendo
rsort($nNavedbe);
$numerus = ((int)$nNavedbe[0] > 0) ? $nNavedbe[0] : 0;
$DataSet->SetNumerus($numerus);
self::$numerusText = ' ('.$lang['srv_analiza_opisne_arguments'].')';
}
$vrednostiKey[] = $dataArray[$offset]['key'];
$vrednostiVariable[] = $dataArray[$offset]['variable'];
$vrednostiGrid[] = $dataArray[$offset]['grid'];
}
if(count($vrednosti) > 0){
if($settings['value_type'] == 2){
$DataSet->AddPoint($vrednosti,'Vrednosti_'.$i);
//$DataSet->SetYAxisName($lang['srv_chart_freq']);
}
elseif($settings['value_type'] == 1){
$DataSet->AddPoint($vrednostiPercent,'Vrednosti_'.$i);
//$DataSet->SetYAxisName($lang['srv_chart_percent']);
}
elseif($settings['value_type'] == 0){
$DataSet->AddPoint($vrednostiValid,'Vrednosti_'.$i);
//$DataSet->SetYAxisName($lang['srv_chart_valid']);
}
}
else
$DataSet->AddPoint(array(0),'Vrednosti_'.$i);
$DataSet->AddSerie('Vrednosti_'.$i);
$DataSet->SetSerieName($vrednostiVariable[0],'Vrednosti_'.$i);
}
// Vedno izpisemo cela imena variabel
$DataSet->AddPoint($vrednostiGrid,"Variable");
$DataSet->SetAbsciseLabelSerie("Variable");
}
// Obratno obrnjen graf - gridi v legendi (deli stolpca), variable v stolpcih - default ce imamo samo en grid
else{
// prej moramo napolniti imena serij (variabel)
for($i=0; $i<$gridCount; $i++){
$vrednostiGrid[] = $dataArray[$i*$_variables_count]['grid'];
}
// Sortiramo podaatke ce je potrebno
if($settings['sort'] == 1){
$tmp = Array();
// preberemo prve vrednosti iz vsakega stolpca
for($j=0; $j<$gridCount; $j++){
$offset = $j*$_variables_count;
$tmp[] = (int)$dataArray[$offset]['valid'];
}
// sortiramo vrednosti in preberemo kljuce
arsort($tmp);
$sorted_keys = array_keys($tmp);
}
// Sort po prvi kategoriji
elseif($settings['sort'] == 3){
$tmp = Array();
// preberemo prve vrednosti iz vsake vrstice
for($j=0; $j<$_variables_count; $j++){
$offset = $j;
$tmp[] = (int)$dataArray[$offset]['valid'];
}
// sortiramo vrednosti in preberemo kljuce
arsort($tmp);
$sorted_keys = array_keys($tmp);
}
for($i=0; $i<$gridCount; $i++){
unset($vrednosti);
unset($vrednostiPercent);
unset($vrednostiValid);
unset($vrednostiKey);
unset($vrednostiVariable);
// Poberemo podatke v posamezne tabele
for($j=0; $j<$_variables_count; $j++){
if($settings['sort'] == 1)
$offset = ($sorted_keys[$i]*$_variables_count) + $j;
// sort po prvi kategoriji
elseif($settings['sort'] == 3)
$offset = $sorted_keys[$j] + ($i*$_variables_count);
else
$offset = ($i*$_variables_count) + $j;
// Enote
if($settings['base'] != 1){
$vrednosti[] = $dataArray[$offset]['freq'];
$vrednostiPercent[] = $dataArray[$offset]['percent'];
$vrednostiValid[] = $dataArray[$offset]['valid'];
//nastavimo numerus, ki se izpise pod legendo
if($settings['value_type'] == 0){
rsort($nValid);
$numerus = ((int)$nValid[0] > 0) ? $nValid[0] : 0;
$DataSet->SetNumerus($numerus);
self::$numerusText = ' ('.$lang['srv_analiza_frekvence_titleVeljavni'].')';
}
else
$numerus = ((int)$nAll > 0) ? $nAll : 0;
$DataSet->SetNumerus($numerus);
}
// Navedbe
else{
$percent = ($fullPercentReverse[$j] * $dataArray[$offset]['percent'] > 0) ? 100 / $fullPercentReverse[$j] * $dataArray[$offset]['percent'] : 0;
$vrednosti[] = $dataArray[$offset]['freq'];
$vrednostiPercent[] = $percent;
$vrednostiValid[] = $percent;
//nastavimo numerus, ki se izpise pod legendo
rsort($nNavedbe);
$numerus = ((int)$nNavedbe[0] > 0) ? $nNavedbe[0] : 0;
$DataSet->SetNumerus($numerus);
self::$numerusText = ' ('.$lang['srv_analiza_opisne_arguments'].')';
}
$vrednostiKey[] = $dataArray[$offset]['key'];
$vrednostiVariable[] = $dataArray[$offset]['variable'];
}
if(count($vrednosti) > 0){
if($settings['value_type'] == 2){
$DataSet->AddPoint($vrednosti,'Vrednosti_'.$i);
//$DataSet->SetYAxisName($lang['srv_chart_freq']);
}
elseif($settings['value_type'] == 1){
$DataSet->AddPoint($vrednostiPercent,'Vrednosti_'.$i);
//$DataSet->SetYAxisName($lang['srv_chart_percent']);
}
elseif($settings['value_type'] == 0){
$DataSet->AddPoint($vrednostiValid,'Vrednosti_'.$i);
//$DataSet->SetYAxisName($lang['srv_chart_valid']);
}
}
else
$DataSet->AddPoint(array(0),'Vrednosti_'.$i);
$DataSet->AddSerie('Vrednosti_'.$i);
if($settings['sort'] == 1)
$DataSet->SetSerieName($vrednostiGrid[$sorted_keys[$i]],'Vrednosti_'.$i);
else
$DataSet->SetSerieName($vrednostiGrid[$i],'Vrednosti_'.$i);
}
// Vedno izpisemo cela imena variabel
$DataSet->AddPoint($vrednostiVariable,"Variable");
$DataSet->SetAbsciseLabelSerie("Variable");
}
if($settings['value_type'] == 1 || $settings['value_type'] == 0){
$DataSet->SetYAxisUnit("%");
$DataSet->SetYAxisFormat("number");
}
}
// napolnimo podatke za VSOTO
elseif($spremenljivka['tip'] == 18){
$dataArray = array();
$i=0;
$numerus=0;
if (count($spremenljivka['grids']) > 0)
foreach ($spremenljivka['grids'] AS $gid => $grid) {
$legendTitle = '';
$_variables_count = count($grid['variables']);
# dodamo dodatne vrstice z albelami grida
if ($_variables_count > 0 )
foreach ($grid['variables'] AS $vid => $variable ){
$legendTitle = substr($variable['variable'],0,strpos($variable['variable'],'_'));
$_sequence = $variable['sequence']; # id kolone z podatki
if (($variable['text'] != true && $variable['other'] != true) || (in_array($spremenljivka['tip'],array(4,8,21)))){
if (isset(SurveyAnalysis::$_FREQUENCYS[$_sequence]['valid']) && is_countable(SurveyAnalysis::$_FREQUENCYS[$_sequence]['valid']) && count(SurveyAnalysis::$_FREQUENCYS[$_sequence]['valid']) > 0) {
# za povprečje
$sum_xi_fi=0;
$N = 0;
$div=0;
$min = null;
$max = null;
foreach ( SurveyAnalysis::$_FREQUENCYS[$_sequence]['valid'] AS $vkey => $vAnswer) {
$fi = $vAnswer['cnt'];
$sum_xi_fi += $vkey * $fi ;
$N += $fi;
$min = $min != null ? min($min,$vkey) : $vkey;
$max = max($max,$vkey);
}
#povprečje
$avg = ($N > 0) ? $sum_xi_fi / $N : 0;
// nastavimo da graf ni prazen
if($avg > 0)
$emptyData = false;
$numerus = ($numerus > $N) ? $numerus : $N;
$tempArray = array();
$tempArray['avg'] = $avg;
$tempArray['max'] = $max;
$tempArray['min'] = $min;
$tempArray['key'] = $variable['variable'];
$text = $spremenljivka['edit_graf'] == 0 ? $variable['naslov'] : $variable['naslov_graf'];
$tempArray['variable'] = $text;
// ce imamo vklopljeno da izpuscamo 0 in prikazujemo pie chart spustimo nicelne vrednosti
if($avg != 0 || SurveyDataSettingProfiles :: getSetting('chartPieZeros') == 1 || ($settings['type'] != 0 && $settings['type'] != 5))
$dataArray[] = $tempArray;
}
}
}
$i++;
}
// zascita pred praznimi vprasanji (brez variabel)
if($_variables_count == 0)
return -1;
//polnimo podatke
$DataSet = new pData;
//nastavimo numerus, ki se izpise pod legendo
$numerus = ((int)$numerus > 0) ? $numerus : 0;
$DataSet->SetNumerus($numerus);
// Sortiramo podatke in jih razvrstimo po skupinah
if($settings['sort'] == 1){
$tmp = Array();
foreach($dataArray as &$data)
$tmp[] = &$data['avg'];
array_multisort($tmp, SORT_NUMERIC, SORT_DESC, $dataArray);
}
elseif($settings['sort'] == 2){
$tmp = Array();
foreach($dataArray as &$data)
$tmp[] = &$data['avg'];
array_multisort($tmp, SORT_NUMERIC, SORT_ASC, $dataArray);
}
// Poberemo podatke v posamezne tabele
for($i=0; $i 0){
if($settings['value_type'] == 0){
$DataSet->AddPoint($vrednosti,'Vrednosti');
//$DataSet->SetYAxisName($lang['srv_chart_freq']);
}
elseif($settings['value_type'] == 1){
$DataSet->AddPoint($vrednostiMax,'Vrednosti');
//$DataSet->SetYAxisName($lang['srv_chart_percent']);
}
elseif($settings['value_type'] == 2){
$DataSet->AddPoint($vrednostiMin,'Vrednosti');
//$DataSet->SetYAxisName($lang['srv_chart_valid']);
}
}
else
$DataSet->AddPoint(array(0),'Vrednosti');
$DataSet->AddSerie('Vrednosti');
$DataSet->SetSerieName('Povprečja','Vrednosti');
// Vedno izpisemo cela imena variabel
$DataSet->AddPoint($vrednostiVariable,"Variable");
//$DataSet->AddPoint($vrednostiKey,"Variable");
$DataSet->SetAbsciseLabelSerie("Variable");
if($settings['type'] != 2)
$DataSet->SetYAxisName($lang['srv_analiza_sums_average']);
}
// napolnimo podatke za RANKING
elseif($spremenljivka['tip'] == 17){
$dataArray = array();
$i=0;
$numerus=0;
if (count($spremenljivka['grids']) > 0)
foreach ($spremenljivka['grids'] AS $gid => $grid) {
$legendTitle = '';
$_variables_count = count($grid['variables']);
# dodamo dodatne vrstice z albelami grida
if ($_variables_count > 0 )
foreach ($grid['variables'] AS $vid => $variable ){
$legendTitle = substr($variable['variable'],0,strpos($variable['variable'],'_'));
$_sequence = $variable['sequence']; # id kolone z podatki
if (($variable['text'] != true && $variable['other'] != true) || (in_array($spremenljivka['tip'],array(4,8,21)))){
if (is_countable(SurveyAnalysis::$_FREQUENCYS[$_sequence]['valid']) && count(SurveyAnalysis::$_FREQUENCYS[$_sequence]['valid']) > 0) {
$rankingArray = array();
$_variables_count=0;
# za povprečje
$sum_xi_fi=0;
$N = 0;
$div=0;
$min = null;
$max = null;
foreach ( SurveyAnalysis::$_FREQUENCYS[$_sequence]['valid'] AS $vkey => $vAnswer) {
$fi = $vAnswer['cnt'];
$sum_xi_fi += $vkey * $fi ;
$N += $fi;
$min = $min != null ? min($min,$vkey) : $vkey;
$max = max($max,$vkey);
$rankingArray[] = $vAnswer['cnt'];
$_variables_count++;
}
// nastavimo da graf ni prazen
if($N > 0)
$emptyData = false;
#povprečje
$avg = ($N > 0) ? $sum_xi_fi / $N : 0;
$avg = $avg < 1 ? 1 : $avg;
if($settings['type'] == 0){
$numerus = ($numerus > $N) ? $numerus : $N;
}
else{
$numerus = SurveyAnalysis::$_FREQUENCYS[$_sequence]['allCnt'];
}
$tempArray = array();
$tempArray['cnt'] = $N;
$tempArray['avg'] = $avg;
$tempArray['max'] = $max;
$tempArray['min'] = $min;
$tempArray['rankings'] = $rankingArray;
$tempArray['key'] = $variable['variable'];
$text = $spremenljivka['edit_graf'] == 0 ? $variable['naslov'] : $variable['naslov_graf'];
$tempArray['variable'] = $text;
$dataArray[] = $tempArray;
}
}
}
$i++;
}
//polnimo podatke
$DataSet = new pData;
// zascita pred praznimi vprasanji (brez variabel)
if($_variables_count == 0)
return -1;
//nastavimo numerus, ki se izpise pod legendo
$numerus = ((int)$numerus > 0) ? $numerus : 0;
$DataSet->SetNumerus($numerus);
// Sortiramo podatke in jih razvrstimo po skupinah
if($settings['sort'] == 1){
$tmp = Array();
foreach($dataArray as &$data)
$tmp[] = &$data['avg'];
array_multisort($tmp, SORT_NUMERIC, SORT_DESC, $dataArray);
}
elseif($settings['sort'] == 2){
$tmp = Array();
foreach($dataArray as &$data)
$tmp[] = &$data['avg'];
array_multisort($tmp, SORT_NUMERIC, SORT_ASC, $dataArray);
}
if($settings['type'] == 0){
// Poberemo podatke v posamezne tabele
for($i=0; $i 0){
if($settings['value_type'] == 0){
$DataSet->AddPoint($vrednosti,'Vrednosti');
//$DataSet->SetYAxisName($lang['srv_chart_freq']);
}
elseif($settings['value_type'] == 1){
$DataSet->AddPoint($vrednostiMax,'Vrednosti');
//$DataSet->SetYAxisName($lang['srv_chart_percent']);
}
elseif($settings['value_type'] == 2){
$DataSet->AddPoint($vrednostiMin,'Vrednosti');
//$DataSet->SetYAxisName($lang['srv_chart_valid']);
}
}
else
$DataSet->AddPoint(array(0),'Vrednosti');
$DataSet->AddSerie('Vrednosti');
$DataSet->SetSerieName('Povprečja','Vrednosti');
}
//polnimo podatke po posameznih serijah
else{
// loop cez variable za posamezno serijo
for($i=0; $i<$_variables_count; $i++){
unset($vrednosti);
unset($vrednostiPercent);
unset($vrednostiKey);
unset($vrednostiVariable);
for($j=0; $j 0)
$percent = $dataArray[$j]['rankings'][$i] / $dataArray[$j]['cnt'] * 100;
else
$percent = 0;
$vrednostiPercent[] = $percent;
$vrednostiKey[] = $dataArray[$j]['key'];
$vrednostiVariable[] = $dataArray[$j]['variable'];
}
if(count($vrednosti) > 0){
if($settings['value_type'] == 0){
$DataSet->AddPoint($vrednosti,'Vrednosti'.$i);
//$DataSet->SetYAxisName($lang['srv_chart_freq']);
}
elseif($settings['value_type'] == 1){
$DataSet->AddPoint($vrednostiPercent,'Vrednosti'.$i);
//$DataSet->SetYAxisName($lang['srv_chart_percent']);
}
elseif($settings['value_type'] == 2){
$DataSet->AddPoint($vrednostiPercent,'Vrednosti'.$i);
//$DataSet->SetYAxisName($lang['srv_chart_valid']);
}
}
else
$DataSet->AddPoint(array(0),'Vrednosti'.$i);
$DataSet->AddSerie('Vrednosti'.$i);
$DataSet->SetSerieName($i+1,'Vrednosti'.$i);
}
}
// Vedno izpisemo cela imena variabel
$DataSet->AddPoint($vrednostiVariable,"Variable");
//$DataSet->AddPoint($vrednostiKey,"Variable");
$DataSet->SetAbsciseLabelSerie("Variable");
if($settings['type'] > 1)
$DataSet->SetYAxisName("Povprečje");
}
// napolnimo podatke za MULTINUMBER
elseif($spremenljivka['tip'] == 20){
$dataArray = array();
$i=0;
$numerus=0;
$sql = sisplet_query("SELECT count(*) AS count FROM srv_grid WHERE spr_id='$spid'");
$row = mysqli_fetch_array($sql);
$_variables_count = $row['count'];
$vrednostiGrid = array();
if (count($spremenljivka['grids']) > 0)
foreach ($spremenljivka['grids'] AS $gid => $grid) {
$legendTitle = '';
$vrednostiGrid[] = $spremenljivka['edit_graf'] == 0 ? $grid['naslov'] : $grid['naslov_graf'];
//$_variables_count = count($grid['variables']);
# dodamo dodatne vrstice z albelami grida
if ($_variables_count > 0 )
foreach ($grid['variables'] AS $vid => $variable ){
$legendTitle = substr($variable['variable'],0,strpos($variable['variable'],'_'));
$_sequence = $variable['sequence']; # id kolone z podatki
if (($variable['text'] != true && $variable['other'] != true) || (in_array($spremenljivka['tip'],array(4,8,21)))){
if (isset(SurveyAnalysis::$_FREQUENCYS[$_sequence]['valid']) && is_countable(SurveyAnalysis::$_FREQUENCYS[$_sequence]['valid']) && count(SurveyAnalysis::$_FREQUENCYS[$_sequence]['valid']) > 0) {
# za povprečje
$sum_xi_fi=0;
$N = 0;
$div=0;
$min = null;
$max = null;
foreach ( SurveyAnalysis::$_FREQUENCYS[$_sequence]['valid'] AS $vkey => $vAnswer) {
$fi = $vAnswer['cnt'];
$sum_xi_fi += $vkey * $fi ;
$N += $fi;
$min = $min != null ? min($min,$vkey) : $vkey;
$max = max($max,$vkey);
}
#povprečje
$avg = ($N > 0) ? $sum_xi_fi / $N : 0;
// nastavimo da graf ni prazen
if($avg > 0)
$emptyData = false;
$numerus = ($numerus > $N) ? $numerus : $N;
$tempArray = array();
$tempArray['avg'] = $avg;
$tempArray['max'] = $max;
$tempArray['min'] = $min;
$tempArray['key'] = $variable['variable'];
$text = $spremenljivka['edit_graf'] == 0 ? $variable['naslov'] : $variable['naslov_graf'];
$tempArray['variable'] = $text;
$dataArray[] = $tempArray;
}
// ce missling (-99, -98...) nima nobene vrednosti potem ga ni v tabeli - zato ga rocno napolnimo
else{
$tempArray = array();
$tempArray['avg'] = 0;
$tempArray['max'] = 0;
$tempArray['min'] = 0;
$tempArray['key'] = $variable['variable'];
$text = $spremenljivka['edit_graf'] == 0 ? $variable['naslov'] : $variable['naslov_graf'];
$tempArray['variable'] = $text;
$dataArray[] = $tempArray;
}
}
// polnimo array za drugo
if ($variable['text'] == true || $variable['other'] == true){
$_answersOther[] = array('spid'=>$spid,'gid'=>$gid,'vid'=>$vid,'sequence'=>$_sequence);
}
}
$i++;
}
// zascita pred praznimi vprasanji (brez variabel)
if($_variables_count == 0)
return -1;
//polnimo podatke
$DataSet = new pData;
//nastavimo numerus, ki se izpise pod legendo
$numerus = ((int)$numerus > 0) ? $numerus : 0;
$DataSet->SetNumerus($numerus);
// Normalno obrnjen graf - gridi v stolpcih, variable v legendi (deli stolpcev)
if($settings['rotate'] != 1 /*$_variables_count > 1*/){
// Sortiramo podaatke ce je potrebno
if($settings['sort'] == 1){
$tmp = Array();
// preberemo prve vrednosti iz vsakega stolpca
for($j=0; $j<$_variables_count; $j++){
$offset = $j*$_variables_count;
$tmp[] = (int)$dataArray[$offset]['avg'];
}
// sortiramo vrednosti in preberemo kljuce
arsort($tmp);
$sorted_keys = array_keys($tmp);
}
// Sortiramo podaatke po prvi kategoriji
elseif($settings['sort'] == 3){
$tmp = Array();
// preberemo prve vrednosti iz vsakega stolpca
for($j=0; $j<$_variables_count; $j++){
$offset = $j;
$tmp[] = (int)$dataArray[$offset]['avg'];
}
// sortiramo vrednosti in preberemo kljuce
arsort($tmp);
$sorted_keys = array_keys($tmp);
}
else{
for($j=0; $j<(count($spremenljivka['grids'])*$_variables_count); $j++){
$sorted_keys[] = $j;
}
}
// Poberemo podatke v posamezne tabele
for($j=0; $j 0)
$DataSet->AddPoint($vrednosti,'Vrednosti'.$sorted_keys[$j]);
else
$DataSet->AddPoint(array(0),'Vrednosti'.$sorted_keys[$j]);
$DataSet->AddSerie('Vrednosti'.$sorted_keys[$j]);
$DataSet->SetSerieName($vrednostiGrid[$sorted_keys[$j]],'Vrednosti'.$sorted_keys[$j]);
// Vedno izpisemo cela imena variabel
$DataSet->AddPoint($vrednostiVariable,'Variable'.$sorted_keys[$j]);
//$DataSet->AddPoint($vrednostiKey,"Variable");
$DataSet->SetAbsciseLabelSerie('Variable'.$sorted_keys[$j]);
}
// sort po prvi kategoriji
else{
for($i=0; $i<$_variables_count; $i++){
$vrednosti[] = $dataArray[$j*$_variables_count + $sorted_keys[$i]]['avg'];
$vrednostiMax[] = $dataArray[$j*$_variables_count + $sorted_keys[$i]]['max'];
$vrednostiMin[] = $dataArray[$j*$_variables_count + $sorted_keys[$i]]['min'];
$vrednostiKey[] = $dataArray[$j*$_variables_count + $sorted_keys[$i]]['key'];
$vrednostiVariable[] = $dataArray[$j*$_variables_count + $sorted_keys[$i]]['variable'];
}
if(count($vrednosti) > 0)
$DataSet->AddPoint($vrednosti,'Vrednosti'.$j);
else
$DataSet->AddPoint(array(0),'Vrednosti'.$j);
$DataSet->AddSerie('Vrednosti'.$j);
$DataSet->SetSerieName($vrednostiGrid[$j],'Vrednosti'.$j);
// Vedno izpisemo cela imena variabel
$DataSet->AddPoint($vrednostiVariable,'Variable'.$j);
//$DataSet->AddPoint($vrednostiKey,"Variable");
$DataSet->SetAbsciseLabelSerie('Variable'.$j);
}
}
}
// Obratno obrnjen graf - gridi v legendi (deli stolpca), variable v stolpcih - default ce imamo samo en grid
else{
// Sortiramo podaatke ce je potrebno
if($settings['sort'] == 1){
$tmp = Array();
// preberemo prve vrednosti iz vsakega stolpca
for($j=0; $j<$_variables_count; $j++){
$offset = $j;
$tmp[] = (int)$dataArray[$offset]['avg'];
}
// sortiramo vrednosti in preberemo kljuce
arsort($tmp);
$sorted_keys = array_keys($tmp);
}
// Sortiramo podaatke po prvi kategoriji
elseif($settings['sort'] == 3){
$tmp = Array();
// preberemo prve vrednosti iz vsakega stolpca
for($j=0; $j 0)
$DataSet->AddPoint($vrednosti,'Vrednosti'.$vrednostiKey[0]);
else
$DataSet->AddPoint(array(0),'Vrednosti'.$vrednostiKey[0]);
$DataSet->AddSerie('Vrednosti'.$vrednostiKey[0]);
$DataSet->SetSerieName($vrednostiVariable[0],'Vrednosti'.$vrednostiKey[0]);
// Vedno izpisemo cela imena variabel
$DataSet->AddPoint($vrednostiGrid,'Variable'.$vrednostiKey[0]);
//$DataSet->AddPoint($vrednostiKey,"Variable");
$DataSet->SetAbsciseLabelSerie('Variable'.$vrednostiKey[0]);
}
// sort po prvi kategoriji
else{
$offset = $sorted_keys[$j];
unset($vrednosti);
unset($vrednostiKey);
unset($vrednostiVariable);
for($i=0; $i 0)
$DataSet->AddPoint($vrednosti,'Vrednosti'.$vrednostiKey[0]);
else
$DataSet->AddPoint(array(0),'Vrednosti'.$vrednostiKey[0]);
$DataSet->AddSerie('Vrednosti'.$vrednostiKey[0]);
$DataSet->SetSerieName($vrednostiVariable[0],'Vrednosti'.$vrednostiKey[0]);
// Vedno izpisemo cela imena variabel
$DataSet->AddPoint($vrednostiGrid,'Variable'.$vrednostiKey[0]);
//$DataSet->AddPoint($vrednostiKey,"Variable");
$DataSet->SetAbsciseLabelSerie('Variable'.$vrednostiKey[0]);
}
}
}
//$DataSet->SetYAxisName($lang['srv_analiza_sums_average']);
}
// Nastavimo other vrednosti
$DataSet->SetOther($_answersOther);
// ce imamo prazno in de prikazujemo praznih grafov
$hideEmpty = SurveyDataSettingProfiles :: getSetting('hideEmpty');
if($emptyData && $hideEmpty == 1)
return 0;
else
return $DataSet;
}
// Preverimo ce ima dropdown samo numeric vrednosti -> potem ga obravnavamo kot tip number
static function checkDropdownNumeric($spid){
$spremenljivka = SurveyAnalysis::$_HEADERS[$spid];
$check = true;
foreach ($spremenljivka['options'] AS $option) {
if(!is_numeric($option))
$check = false;
}
return $check;
}
// Funkcije za izris posameznih tipov grafov - vertikalni stolpci
static function createVerBars($DataSet, $spremenljivka, $show_legend=0, $fixedScale=0){
$Data = $DataSet->GetData();
$countGrids = count($Data);
$angle = 0;
$addHeight = 0;
$roundText = 15;
if($countGrids > 5){
$angle = 45;
$addHeight = 110;
$roundText = 25;
}
if($show_legend == 1)
$addHeight += 70;
// Initialise the graph
$Test = new pChart(self::$quality*800,self::$quality*(250+$addHeight));
// Nastavimo barve grafu glede na skin
$Test = self::setChartColors($Test, self::$skin);
$Test->setLineStyle(self::$quality,$DotSize=0);
$Test->setFontProperties(dirname(__FILE__).'/../../pChart/Fonts/verdana.ttf',self::$quality*self::$fontSize);
$Test->setGraphArea(self::$quality*100,self::$quality*40,self::$quality*650,self::$quality*220);
$Test->drawFilledRoundedRectangle(self::$quality*7,self::$quality*7,self::$quality*793,self::$quality*(243+$addHeight),5,255,255,255);
//$Test->drawRoundedRectangle(5,5,795,245,5,128,128,128);
//self::$quality*5,self::$quality*5,self::$quality*795,self::$quality*(245+$addHeight),200,200,200);
$Test->drawGraphArea(255,255,255,TRUE);
// Pri checkboxu lahko naredimo fiksno skalo
if($spremenljivka['tip'] == 2 && self::$settings['noFixedScale'] == 1){
// Frekvence
if(self::$settings['value_type'] == 1){
// Dobimo sum frekvenc
$sum = 0;
foreach($Data as $vrednost){
$sum += $vrednost['Vrednosti'];
}
$Test->setFixedScale(0, $sum);
}
// Odstotki
else
$Test->setFixedScale(0, 100);
}
// Pri dvojnem multigridu prikazemo skalo od 1 do stevila variabel
if($spremenljivka['tip'] == 6 && $spremenljivka['enota'] == 3){
$VMax = count($spremenljivka['options']);
// Zacnemo skalo z 1
if($fixedScale == 0){
$Divisions = $VMax-1;
$VMin = 1;
}
// Zacnemo skalo z 0
else{
$VMax--;
$Divisions = $VMax;
$VMin = 0;
}
$Test->setFixedScale($VMin, $VMax, $Divisions);
}
$Test->drawScale($Data,$DataSet->GetDataDescription(),SCALE_START0,0,0,0,TRUE,$angle,0,TRUE,1,FALSE,$roundText);
$Test->drawGrid(4,TRUE,230,230,230,50);
// Draw the 0 line
$Test->setFontProperties(dirname(__FILE__).'/../../pChart/Fonts/verdana.ttf',self::$quality*6);
$Test->drawTreshold(0,143,55,72,TRUE,TRUE);
// Draw the bar graph
$Test->setFontProperties(dirname(__FILE__).'/../../pChart/Fonts/verdana.ttf',self::$quality*self::$fontSize);
$Test->drawBarGraph($Data,$DataSet->GetDataDescription(), false, 95, self::$settings['barLabel'], self::$settings['barLabelSmall']);
// Finish the graph
if($show_legend == 1)
//$Test->drawLegend(self::$quality*680,self::$quality*30,$DataSet->GetDataDescription(),255,255,255);
// pri vodoravnih strukturnih stolpcih izrisemo legendo na dnu
$Test->drawVerticalLegend(self::$quality*400,self::$quality*(190+$addHeight),$DataSet->GetDataDescription(),255,255,255);
//$Test->setFontProperties("Fonts/verdana.ttf",10);
//$Test->drawTitle(50,22,$spremenljivka['variable'].' - '.$spremenljivka['naslov'],50,50,50,585);
$Test->setFontProperties(dirname(__FILE__).'/../../pChart/Fonts/verdana.ttf',self::$quality*self::$fontSize);
// Prikaz numerusa na grafu
$char = (self::$settings['base'] == 1 && ($spremenljivka['tip'] == 2 || $spremenljivka['tip'] == 16)) ? 'r' : 'n';
if( self::$settings['show_numerus'] == 1 || (self::$settings['show_numerus'] == -1 && SurveyDataSettingProfiles :: getSetting('chartNumerusText') == 1) )
$numerus = $char.' = '.$DataSet->GetNumerus();
elseif( self::$settings['show_numerus'] == -1 && SurveyDataSettingProfiles :: getSetting('chartNumerusText') == 2 )
$numerus = $char.' = ' . $DataSet->GetNumerus() . self::$numerusText;
else
$numerus = '';
$Test->drawTextBox(self::$quality*680,self::$quality*210,self::$quality*795,self::$quality*220,$numerus,$Angle=0,$R=0,$G=0,$B=0,$Align=ALIGN_LEFT,$Shadow=FALSE,$BgR=-1,$BgG=-1,$BgB=-1,$Alpha=0);
$vars = isset($spremenljivka['options']) ? count($spremenljivka['options']) : 0;
// Prikaz povprecja na grafu (samo pri ordinalnem radiu)
if( ($spremenljivka['tip'] == 1 || $spremenljivka['tip'] == 3)
&& $spremenljivka['skala'] != 1
&& (self::$settings['show_avg'] == 1 || (self::$settings['show_avg'] == -1 && $vars == 5 && SurveyDataSettingProfiles :: getSetting('chartAvgText') == 1)) ){
$Test->drawTextBox(self::$quality*680,self::$quality*40,self::$quality*795,self::$quality*45,'x = '.$DataSet->GetAverage(),$Angle=0,$R=0,$G=0,$B=0,$Align=ALIGN_LEFT,$Shadow=FALSE,$BgR=-1,$BgG=-1,$BgB=-1,$Alpha=0);
$Test->drawTextBox(self::$quality*680,self::$quality*45,self::$quality*795,self::$quality*50,'‾',$Angle=0,$R=0,$G=0,$B=0,$Align=ALIGN_LEFT,$Shadow=FALSE,$BgR=-1,$BgG=-1,$BgB=-1,$Alpha=0);
}
// Prikaz povprecja za number
if( ($spremenljivka['tip'] == 7 || $spremenljivka['tip'] == 22)
&& (self::$settings['show_avg'] == 1 || (self::$settings['show_avg'] == -1 && SurveyDataSettingProfiles :: getSetting('chartAvgText') == 1)) ){
$Test->drawTextBox(self::$quality*680,self::$quality*90,self::$quality*795,self::$quality*95,'x = '.$DataSet->GetAverage(),$Angle=0,$R=0,$G=0,$B=0,$Align=ALIGN_LEFT,$Shadow=FALSE,$BgR=-1,$BgG=-1,$BgB=-1,$Alpha=0);
$Test->drawTextBox(self::$quality*680,self::$quality*95,self::$quality*795,self::$quality*100,'‾',$Angle=0,$R=0,$G=0,$B=0,$Align=ALIGN_LEFT,$Shadow=FALSE,$BgR=-1,$BgG=-1,$BgB=-1,$Alpha=0);
}
return $Test;
}
// Funkcije za izris posameznih tipov grafov - horizontalni stolpci
static function createHorBars($DataSet, $spremenljivka, $show_legend=0, $fixedScale=0){
global $lang;
// Nastavimo visino grafa (ce imamo vec kot 7 variabel/gridov)
$Data = $DataSet->GetData();
$countGrids = count($Data);
$addHeight = $countGrids > 5 ? ($countGrids-5)*30 : 0;
// Dodamo prostor na dnu za legendo pri multigrid povprecjih
$addLegendSpace = 0;
if($show_legend == 1 && $spremenljivka['tip'] == 6 && self::$settings['type'] == 0 && $spremenljivka['enota'] != 3)
$addLegendSpace = 70;
// Initialise the graph
$Test = new MyHorBar(self::$quality*800,self::$quality*(250+$addHeight+$addLegendSpace));
// Nastavimo barve grafu glede na skin
$Test = self::setChartColors($Test, self::$skin);
$Test->setLineStyle(self::$quality,$DotSize=0);
$Test->setFontProperties(dirname(__FILE__).'/../../pChart/Fonts/verdana.ttf',self::$quality*self::$fontSize);
// Sirina label
// Ce iamo povprecje ni labele
if(in_array($spremenljivka['tip'],array(1,3,7)) && self::$settings['type'] == 9){
$startX = 160;
$roundText = 35;
}
elseif(self::$settings['labelWidth'] == 20){
$startX = 225;
$roundText = 35;
}
elseif(self::$settings['labelWidth'] == 75){
$startX = 500;
$roundText = 80;
}
else{
$startX = 360;
$roundText = 60;
}
$Test->setGraphArea(self::$quality*$startX,self::$quality*50,self::$quality*650,self::$quality*(220+$addHeight));
$Test->drawFilledRoundedRectangle(self::$quality*7,self::$quality*7,self::$quality*793,self::$quality*(243+$addHeight+$addLegendSpace),5,255,255,255);
//$Test->drawRoundedRectangle(5,5,795,245,5,128,128,128);
//$Test->drawRectangle(self::$quality*5,self::$quality*5,self::$quality*795,self::$quality*(245+$addHeight+$addLegendSpace),200,200,200);
$Test->drawGraphArea(255,255,255,TRUE);
// Pri ordinalnih multigridih prikazemo skalo od 1 do stevila variabel (ce prikazujemo povprecja)
if( ($spremenljivka['tip'] == 6 && self::$settings['type'] == 0) || ($spremenljivka['tip'] == 17 && self::$settings['type'] == 0) ){
$VMax = count($spremenljivka['options']);
// Zacnemo skalo z 1
if($fixedScale == 0){
$Divisions = $VMax-1;
$VMin = 1;
}
// Zacnemo skalo z 0
else{
$VMax--;
$Divisions = $VMax;
$VMin = 0;
}
$Test->setFixedScale($VMin, $VMax, $Divisions);
}
// Pri checkboxu lahko naredimo fiksno skalo
if($spremenljivka['tip'] == 2 && self::$settings['noFixedScale'] == 1){
// Frekvence
if(self::$settings['value_type'] == 1){
// Dobimo sum frekvenc
$sum = 0;
foreach($DataSet->GetData() as $vrednost){
$sum += $vrednost['Vrednosti'];
}
$Test->setFixedScale(0, $sum);
}
// Odstotki
else
$Test->setFixedScale(0, 100);
}
// Pri povprecju (radio) poiscemo najvecjo vrednost
if(in_array($spremenljivka['tip'],array(1,3)) && self::$settings['type'] == 9){
$VMax = count($spremenljivka['options']);
foreach($DataSet->GetData() as $vrednost){
$VMax = ($VMax < $vrednost['Vrednosti']) ? $vrednost['Vrednosti'] : $VMax;
}
$VMin = 0;
$Test->setFixedScale($VMin, $VMax);
}
// Pri povprecju (numeric) poiscemo najvecjo vrednost
elseif(($spremenljivka['tip'] == 7 || $spremenljivka['tip'] == 22) && self::$settings['type'] == 9){
$VMax = 1;
$sequences = explode('_', $spremenljivka['sequences']);
foreach($sequences as $sequence){
if (count(SurveyAnalysis::$_FREQUENCYS[$sequence]['valid']) > 0 ) {
foreach(SurveyAnalysis::$_FREQUENCYS[$sequence]['valid'] AS $vkey => $vAnswer) {
$VMax = ($VMax < (int)$vAnswer['text']) ? (int)$vAnswer['text'] : $VMax;
}
}
}
$VMin = 0;
$Test->setFixedScale($VMin, $VMax);
}
$Test->drawHorScale($DataSet->GetData(),$DataSet->GetDataDescription(),SCALE_START0,0,0,0,TRUE,0,0,TRUE,1,FALSE,$roundText);
$Test->drawHorGrid(4,TRUE,230,230,230,50);
// Draw the 0 line
$Test->setFontProperties(dirname(__FILE__).'/../../pChart/Fonts/verdana.ttf',self::$quality*6);
$Test->drawTreshold(0,143,55,72,TRUE,TRUE);
$Test->setFontProperties(dirname(__FILE__).'/../../pChart/Fonts/verdana.ttf',self::$quality*self::$fontSize);
// Draw the bar graph
$Test->drawHorBarGraph($DataSet->GetData(),$DataSet->GetDataDescription(), self::$settings['barLabel'], self::$settings['barLabelSmall']);
// Finish the graph
if($show_legend == 1){
// posebna legenda pri povprecjih
if($spremenljivka['tip'] == 6 && self::$settings['type'] == 0 && $spremenljivka['enota'] != 3)
//$Test->drawAvgVerticalLegend(self::$quality*680,self::$quality*30,$spremenljivka['options'],255,255,255);
$Test->drawAvgVerticalLegend(self::$quality*400,self::$quality*(190+$addHeight+$addLegendSpace),$spremenljivka['options'],255,255,255);
else
$Test->drawLegend(self::$quality*680,self::$quality*30,$DataSet->GetDataDescription(),255,255,255);
}
if($spremenljivka['tip'] == 18 || $spremenljivka['tip'] == 20)
$Test->drawTitle(self::$quality*200,self::$quality*22,$lang['srv_analiza_sums_average'],0,0,0,self::$quality*680);
$Test->setFontProperties(dirname(__FILE__).'/../../pChart/Fonts/verdana.ttf',self::$quality*self::$fontSize);
// Prikaz numerusa na grafu
$char = (self::$settings['base'] == 1 && ($spremenljivka['tip'] == 2 || $spremenljivka['tip'] == 16)) ? 'r' : 'n';
if( self::$settings['show_numerus'] == 1 || (self::$settings['show_numerus'] == -1 && SurveyDataSettingProfiles :: getSetting('chartNumerusText') == 1) )
$numerus = $char.' = '.$DataSet->GetNumerus();
elseif( self::$settings['show_numerus'] == -1 && SurveyDataSettingProfiles :: getSetting('chartNumerusText') == 2 )
$numerus = $char.' = ' . $DataSet->GetNumerus() . self::$numerusText;
else
$numerus = '';
$Test->drawTextBox(self::$quality*680,self::$quality*(210+$addHeight),self::$quality*795,self::$quality*(220+$addHeight),$numerus,$Angle=0,$R=0,$G=0,$B=0,$Align=ALIGN_LEFT,$Shadow=FALSE,$BgR=-1,$BgG=-1,$BgB=-1,$Alpha=0);
$vars = isset($spremenljivka['options']) ? count($spremenljivka['options']) : 0;
// Prikaz povprecja na grafu (samo pri ordinalnem radiu)
if( ($spremenljivka['tip'] == 1 || $spremenljivka['tip'] == 3)
&& $spremenljivka['skala'] != 1
&& (self::$settings['show_avg'] == 1 || (self::$settings['show_avg'] == -1 && $vars == 5 && SurveyDataSettingProfiles :: getSetting('chartAvgText') == 1)) ){
$Test->drawTextBox(self::$quality*680,self::$quality*50,self::$quality*795,self::$quality*55,'x = '.$DataSet->GetAverage(),$Angle=0,$R=0,$G=0,$B=0,$Align=ALIGN_LEFT,$Shadow=FALSE,$BgR=-1,$BgG=-1,$BgB=-1,$Alpha=0);
$Test->drawTextBox(self::$quality*680,self::$quality*55,self::$quality*795,self::$quality*60,'‾',$Angle=0,$R=0,$G=0,$B=0,$Align=ALIGN_LEFT,$Shadow=FALSE,$BgR=-1,$BgG=-1,$BgB=-1,$Alpha=0);
}
// Prikaz povprecja za number
if( ($spremenljivka['tip'] == 7 || $spremenljivka['tip'] == 22)
&& (self::$settings['show_avg'] == 1 || (self::$settings['show_avg'] == -1 && SurveyDataSettingProfiles :: getSetting('chartAvgText') == 1)) ){
$Test->drawTextBox(self::$quality*680,self::$quality*90,self::$quality*795,self::$quality*95,'x = '.$DataSet->GetAverage(),$Angle=0,$R=0,$G=0,$B=0,$Align=ALIGN_LEFT,$Shadow=FALSE,$BgR=-1,$BgG=-1,$BgB=-1,$Alpha=0);
$Test->drawTextBox(self::$quality*680,self::$quality*95,self::$quality*795,self::$quality*100,'‾',$Angle=0,$R=0,$G=0,$B=0,$Align=ALIGN_LEFT,$Shadow=FALSE,$BgR=-1,$BgG=-1,$BgB=-1,$Alpha=0);
}
return $Test;
}
// Funkcije za izris posameznih tipov grafov - vertikalni sestavljeni stolpci
static function createVerStructBars($DataSet, $spremenljivka){
$Data = $DataSet->GetData();
$countGrids = count($Data);
$angle = 0;
$addHeight = 0;
$roundText = 15;
if($countGrids > 5){
$angle = 45;
$addHeight = 110;
$roundText = 30;
}
// Initialise the graph
$Test = new pChart(self::$quality*800,self::$quality*(250+$addHeight));
// Nastavimo barve grafu glede na skin
$Test = self::setChartColors($Test, self::$skin);
$Test->setLineStyle(self::$quality,$DotSize=0);
$Test->setFontProperties(dirname(__FILE__).'/../../pChart/Fonts/verdana.ttf',self::$quality*self::$fontSize);
// Pri navadnem radio in checkbox vprasanju imamo samo en stolpec - zato so dimenzije drugacne
if($spremenljivka['tip'] == 1 || $spremenljivka['tip'] == 2 || $spremenljivka['tip'] == 3)
$Test->setGraphArea(self::$quality*250,self::$quality*40,self::$quality*500,self::$quality*220);
else
$Test->setGraphArea(self::$quality*100,self::$quality*40,self::$quality*650,self::$quality*220);
$Test->drawFilledRoundedRectangle(self::$quality*7,self::$quality*7,self::$quality*793,self::$quality*(243+$addHeight),5,255,255,255);
//$Test->drawRoundedRectangle(5,5,795,245,5,128,128,128);
//$Test->drawRectangle(self::$quality*5,self::$quality*5,self::$quality*795,self::$quality*(245+$addHeight),200,200,200);
$Test->drawGraphArea(255,255,255,TRUE);
$Test->drawScale($DataSet->GetData(),$DataSet->GetDataDescription(),SCALE_ADDALLSTART0,0,0,0,TRUE,$angle,0,TRUE,1,FALSE,$roundText);
$Test->drawGrid(4,TRUE,230,230,230,50);
// Draw the 0 line
$Test->setFontProperties(dirname(__FILE__).'/../../pChart/Fonts/verdana.ttf',self::$quality*6);
$Test->drawTreshold(0,143,55,72,TRUE,TRUE);
// Draw the bar graph
$Test->setFontProperties(dirname(__FILE__).'/../../pChart/Fonts/verdana.ttf',self::$quality*self::$fontSize);
$Test->drawStackedBarGraph($DataSet->GetData(),$DataSet->GetDataDescription(), self::$settings['barLabel'], 95);
// Finish the graph
if($spremenljivka['tip'] == 1 || $spremenljivka['tip'] == 2 || $spremenljivka['tip'] == 3)
$Test->drawLegend(self::$quality*580,self::$quality*30,$DataSet->GetDataDescription(),255,255,255,$Rs=-1,$Gs=-1,$Bs=-1,$Rt=0,$Gt=0,$Bt=0,$Border=false,$reverse=true);
else
$Test->drawLegend(self::$quality*680,self::$quality*30,$DataSet->GetDataDescription(),255,255,255,$Rs=-1,$Gs=-1,$Bs=-1,$Rt=0,$Gt=0,$Bt=0,$Border=false,$reverse=true);
$Test->setFontProperties("Fonts/verdana.ttf",self::$quality*10);
//$Test->drawTitle(50,22,$spremenljivka['variable'].' - '.$spremenljivka['naslov'],50,50,50,585);
$Test->setFontProperties(dirname(__FILE__).'/../../pChart/Fonts/verdana.ttf',self::$quality*self::$fontSize);
// Prikaz numerusa na grafu
$char = (self::$settings['base'] == 1 && ($spremenljivka['tip'] == 2 || $spremenljivka['tip'] == 16)) ? 'r' : 'n';
if( self::$settings['show_numerus'] == 1 || (self::$settings['show_numerus'] == -1 && SurveyDataSettingProfiles :: getSetting('chartNumerusText') == 1) )
$numerus = $char.' = '.$DataSet->GetNumerus();
elseif( self::$settings['show_numerus'] == -1 && SurveyDataSettingProfiles :: getSetting('chartNumerusText') == 2 )
$numerus = $char.' = ' . $DataSet->GetNumerus() . self::$numerusText;
else
$numerus = '';
if($spremenljivka['tip'] == 1 || $spremenljivka['tip'] == 2 || $spremenljivka['tip'] == 3)
$Test->drawTextBox(self::$quality*540,self::$quality*210,self::$quality*645,self::$quality*220,$numerus,$Angle=0,$R=0,$G=0,$B=0,$Align=ALIGN_LEFT,$Shadow=FALSE,$BgR=-1,$BgG=-1,$BgB=-1,$Alpha=0);
else
$Test->drawTextBox(self::$quality*680,self::$quality*210,self::$quality*795,self::$quality*220,$numerus,$Angle=0,$R=0,$G=0,$B=0,$Align=ALIGN_LEFT,$Shadow=FALSE,$BgR=-1,$BgG=-1,$BgB=-1,$Alpha=0);
$vars = count($spremenljivka['options']);
// Prikaz povprecja na grafu (samo pri ordinalnem radiu)
if( ($spremenljivka['tip'] == 1 || $spremenljivka['tip'] == 3)
&& $spremenljivka['skala'] != 1
&& (self::$settings['show_avg'] == 1 || (self::$settings['show_avg'] == -1 && $vars == 5 && SurveyDataSettingProfiles :: getSetting('chartAvgText') == 1)) ){
$Test->drawTextBox(self::$quality*350,self::$quality*25,self::$quality*400,self::$quality*30,'x = '.$DataSet->GetAverage(),$Angle=0,$R=0,$G=0,$B=0,$Align=ALIGN_LEFT,$Shadow=FALSE,$BgR=-1,$BgG=-1,$BgB=-1,$Alpha=0);
$Test->drawTextBox(self::$quality*350,self::$quality*30,self::$quality*400,self::$quality*35,'‾',$Angle=0,$R=0,$G=0,$B=0,$Align=ALIGN_LEFT,$Shadow=FALSE,$BgR=-1,$BgG=-1,$BgB=-1,$Alpha=0);
}
return $Test;
}
// Funkcije za izris posameznih tipov grafov - horizontalni sestavljeni stolpci
static function createHorStructBars($DataSet, $spremenljivka){
// Nastavimo visino graffa (ce imamo vec kot 7 variabel/gridov)
$Data = $DataSet->GetData();
$countGrids = count($Data);
$addHeight = $countGrids > 5 ? ($countGrids-5)*30 : 0;
// Imamo semanticni dif. - izpisujemo labele na desni
$rightScale = ($spremenljivka['tip'] == 6 && isset($spremenljivka['enota']) && $spremenljivka['enota'] == 1 && self::$settings['scale_limit'] == 1) ? true : false;
// Initialise the graph
$Test = new MyHorBar(self::$quality*800,self::$quality*(250+$addHeight+50));
// Nastavimo barve grafu glede na skin
$Test = self::setChartColors($Test, self::$skin);
$Test->setLineStyle(self::$quality,$DotSize=0);
$Test->setFontProperties(dirname(__FILE__).'/../../pChart/Fonts/verdana.ttf',self::$quality*self::$fontSize);
// Sirina label
if(self::$settings['labelWidth'] == 20){
$startX = 225;
$roundText = 35;
}
elseif(self::$settings['labelWidth'] == 75){
$startX = 500;
$roundText = 80;
}
else{
$startX = 360;
$roundText = 60;
}
// Pri navadnem radio in checkbox vprasanju imamo samo en stolpec - zato so dimenzije drugacne
if($spremenljivka['tip'] == 1 || $spremenljivka['tip'] == 2 || $spremenljivka['tip'] == 3){
$Test->setGraphArea(self::$quality*200,self::$quality*50,self::$quality*630,self::$quality*220);
$Test->drawFilledRoundedRectangle(self::$quality*7,self::$quality*7,self::$quality*793,self::$quality*243,5,255,255,255);
//$Test->drawRectangle(self::$quality*5,self::$quality*5,self::$quality*795,self::$quality*295,200,200,200);
$Test->drawGraphArea(255,255,255,TRUE);
$Test->drawHorScale($DataSet->GetData(),$DataSet->GetDataDescription(),SCALE_ADDALLSTART0,0,0,0,TRUE,0,0,TRUE);
$Test->drawHorGrid(4,TRUE,230,230,230,50);
}
// Semanticni diferencial s skalo na desni
elseif($rightScale){
$Test->setGraphArea(self::$quality*270,self::$quality*50,self::$quality*530,self::$quality*(220+$addHeight));
$Test->drawFilledRoundedRectangle(7,7,793,243+$addHeight,5,255,255,255);
//$Test->drawRectangle(self::$quality*5,self::$quality*5,self::$quality*795,self::$quality*(295+$addHeight),200,200,200);
$Test->drawGraphArea(255,255,255,TRUE);
$Test->drawHorScale($DataSet->GetData(),$DataSet->GetDataDescription(),SCALE_ADDALLSTART0/*SCALE_START0*/,0,0,0,TRUE,0,0,TRUE,1,$rightScale,$roundText=40);
$Test->drawHorGrid(4,false,230,230,230,50);
}
else{
$Test->setGraphArea(self::$quality*$startX,self::$quality*50,self::$quality*650,self::$quality*(220+$addHeight));
$Test->drawFilledRoundedRectangle(7,7,793,243+$addHeight,5,255,255,255);
//$Test->drawRectangle(self::$quality*5,self::$quality*5,self::$quality*795,self::$quality*(295+$addHeight),200,200,200);
$Test->drawGraphArea(255,255,255,TRUE);
$Test->drawHorScale($DataSet->GetData(),$DataSet->GetDataDescription(),SCALE_ADDALLSTART0,0,0,0,TRUE,0,0,TRUE,1,FALSE,$roundText);
$Test->drawHorGrid(4,TRUE,230,230,230,50);
}
// Draw the 0 line
$Test->setFontProperties(dirname(__FILE__).'/../../pChart/Fonts/verdana.ttf',self::$quality*6);
$Test->drawTreshold(0,143,55,72,TRUE,TRUE);
$Test->setFontProperties(dirname(__FILE__).'/../../pChart/Fonts/verdana.ttf',self::$quality*self::$fontSize);
// Draw the bar graph
$Test->drawStackedHorBarGraph($DataSet->GetData(),$DataSet->GetDataDescription(),self::$settings['barLabel'],95);
// Finish the graph
/*if($spremenljivka['tip'] == 1 || $spremenljivka['tip'] == 2 || $spremenljivka['tip'] == 3)
$Test->drawLegend(560,30,$DataSet->GetDataDescription(),255,255,255);
else
$Test->drawLegend(680,30,$DataSet->GetDataDescription(),255,255,255);*/
// pri vodoravnih strukturnih stolpcih izrisemo legendo na dnu
$Test->drawVerticalLegend(self::$quality*400,self::$quality*(240+$addHeight),$DataSet->GetDataDescription(),255,255,255);
$Test->setFontProperties("Fonts/verdana.ttf",self::$quality*10);
//$Test->drawTitle(50,22,$spremenljivka['variable'].' - '.$spremenljivka['naslov'],50,50,50,585);
$Test->setFontProperties(dirname(__FILE__).'/../../pChart/Fonts/verdana.ttf',self::$quality*self::$fontSize);
// Prikaz numerusa na grafu
$char = (self::$settings['base'] == 1 && ($spremenljivka['tip'] == 2 || $spremenljivka['tip'] == 16)) ? 'r' : 'n';
if( self::$settings['show_numerus'] == 1 || (self::$settings['show_numerus'] == -1 && SurveyDataSettingProfiles :: getSetting('chartNumerusText') == 1) )
$numerus = $char.' = '.$DataSet->GetNumerus();
elseif( self::$settings['show_numerus'] == -1 && SurveyDataSettingProfiles :: getSetting('chartNumerusText') == 2 )
$numerus = $char.' = ' . $DataSet->GetNumerus() . self::$numerusText;
else
$numerus = '';
/*if($spremenljivka['tip'] == 1 || $spremenljivka['tip'] == 2 || $spremenljivka['tip'] == 3)
$Test->drawTextBox(570,210+$addHeight,795,220+$addHeight,'n = '.$DataSet->GetNumerus().self::$numerusText,$Angle=0,$R=0,$G=0,$B=0,$Align=ALIGN_LEFT,$Shadow=FALSE,$BgR=-1,$BgG=-1,$BgB=-1,$Alpha=0);
else*/
$Test->drawTextBox(self::$quality*680,self::$quality*(210+$addHeight),self::$quality*795,self::$quality*(220+$addHeight),$numerus,$Angle=0,$R=0,$G=0,$B=0,$Align=ALIGN_LEFT,$Shadow=FALSE,$BgR=-1,$BgG=-1,$BgB=-1,$Alpha=0);
$vars = count($spremenljivka['options']);
// Prikaz povprecja na grafu (samo pri ordinalnem radiu)
if( ($spremenljivka['tip'] == 1 || $spremenljivka['tip'] == 3)
&& $spremenljivka['skala'] != 1
&& (self::$settings['show_avg'] == 1 || (self::$settings['show_avg'] == -1 && $vars == 5 && SurveyDataSettingProfiles :: getSetting('chartAvgText') == 1)) ){
$Test->drawTextBox(self::$quality*680,self::$quality*50,self::$quality*795,self::$quality*55,'x = '.$DataSet->GetAverage(),$Angle=0,$R=0,$G=0,$B=0,$Align=ALIGN_LEFT,$Shadow=FALSE,$BgR=-1,$BgG=-1,$BgB=-1,$Alpha=0);
$Test->drawTextBox(self::$quality*680,self::$quality*55,self::$quality*795,self::$quality*60,'‾',$Angle=0,$R=0,$G=0,$B=0,$Align=ALIGN_LEFT,$Shadow=FALSE,$BgR=-1,$BgG=-1,$BgB=-1,$Alpha=0);
}
return $Test;
}
// Funkcije za izris posameznih tipov grafov - krozni graf
static function createPie($DataSet, $spremenljivka, $show_legend=1){
global $lang;
// Initialise the graph
$Test = new pChart(self::$quality*800,self::$quality*280);
// Pri pie grafu uporabimo antialiasing
$Test->setAntialias(true, 20);
// Nastavimo barve grafu glede na skin
$Test = self::setChartColors($Test, self::$skin);
$Test->setLineStyle(self::$quality,$DotSize=0);
$Test->setFontProperties(dirname(__FILE__).'/../../pChart/Fonts/verdana.ttf',self::$quality*self::$fontSize);
$Test->drawFilledRoundedRectangle(self::$quality*7,self::$quality*7,self::$quality*793,self::$quality*273,5,255,255,255);
//$Test->drawRectangle(self::$quality*5,self::$quality*5,self::$quality*795,self::$quality*275,200,200,200);
// Pri vsoti ne izpisujemo procentov
if($spremenljivka['tip'] == 18 || ($spremenljivka['tip'] == 1 && self::$settings['type'] == 2 && self::$settings['value_type'] == 1))
$labels = (self::$settings['sort'] == 1) ? 'custom_sort' : 'custom';
else
$labels = (self::$settings['sort'] == 1) ? 'custom_percent_sort' : 'custom_percent';
// Izrisemo navaden krozni graf
$Test->drawFlatPieGraph($DataSet->GetData(),$DataSet->GetDataDescription(),self::$quality*390,self::$quality*145,self::$quality*95,$labels);
// Finish the graph
$Test->setFontProperties(dirname(__FILE__).'/../../pChart/Fonts/verdana.ttf',self::$quality*self::$fontSize);
//$Test->drawLegend(700,30,$DataSet->GetDataDescription(),255,255,255);
if($show_legend == 1)
$Test->drawPieLegend(self::$quality*600,self::$quality*50,$DataSet->GetData(),$DataSet->GetDataDescription(),255,255,255);
$Test->setFontProperties(dirname(__FILE__).'/../../pChart/Fonts/verdana.ttf',self::$quality*10);
if($spremenljivka['tip'] == 18)
$Test->drawTitle(self::$quality*180,self::$quality*30,$lang['srv_analiza_sums_average'],0,0,0,self::$quality*610);
$Test->setFontProperties(dirname(__FILE__).'/../../pChart/Fonts/verdana.ttf',self::$quality*self::$fontSize);
$Test->setAntialias(false, 0);
// Prikaz numerusa na grafu
$char = (self::$settings['base'] == 1 && ($spremenljivka['tip'] == 2 || $spremenljivka['tip'] == 16)) ? 'r' : 'n';
if( self::$settings['show_numerus'] == 1 || (self::$settings['show_numerus'] == -1 && SurveyDataSettingProfiles :: getSetting('chartNumerusText') == 1) )
$numerus = $char.' = '.$DataSet->GetNumerus();
elseif( self::$settings['show_numerus'] == -1 && SurveyDataSettingProfiles :: getSetting('chartNumerusText') == 2 )
$numerus = $char.' = ' . $DataSet->GetNumerus() . self::$numerusText;
else
$numerus = '';
$Test->drawTextBox(self::$quality*600,self::$quality*220,self::$quality*715,self::$quality*230,$numerus,$Angle=0,$R=0,$G=0,$B=0,$Align=ALIGN_LEFT,$Shadow=FALSE,$BgR=-1,$BgG=-1,$BgB=-1,$Alpha=0);
$vars = count($spremenljivka['options']);
// Prikaz povprecja na grafu (samo pri ordinalnem radiu)
if( ($spremenljivka['tip'] == 1 || $spremenljivka['tip'] == 3)
&& $spremenljivka['skala'] != 1
&& (self::$settings['show_avg'] == 1 || (self::$settings['show_avg'] == -1 && $vars == 5 && SurveyDataSettingProfiles :: getSetting('chartAvgText') == 1)) ){
$Test->drawTextBox(self::$quality*600,self::$quality*240,self::$quality*715,self::$quality*245,'x = '.$DataSet->GetAverage(),$Angle=0,$R=0,$G=0,$B=0,$Align=ALIGN_LEFT,$Shadow=FALSE,$BgR=-1,$BgG=-1,$BgB=-1,$Alpha=0);
$Test->drawTextBox(self::$quality*600,self::$quality*245,self::$quality*715,self::$quality*250,'‾',$Angle=0,$R=0,$G=0,$B=0,$Align=ALIGN_LEFT,$Shadow=FALSE,$BgR=-1,$BgG=-1,$BgB=-1,$Alpha=0);
}
return $Test;
}
// Funkcije za izris posameznih tipov grafov - 3D krozni graf
static function create3DPie($DataSet, $spremenljivka, $show_legend=1){
global $lang;
// Initialise the graph
$Test = new pChart(self::$quality*800,self::$quality*280);
// Pri 3d pie grafu uporabimo antialiasing
$Test->setAntialias(true, 20);
// Nastavimo barve grafu glede na skin
$Test = self::setChartColors($Test, self::$skin);
$Test->setLineStyle(self::$quality,$DotSize=0);
$Test->setFontProperties(dirname(__FILE__).'/../../pChart/Fonts/verdana.ttf',self::$quality*self::$fontSize);
$Test->drawFilledRoundedRectangle(self::$quality*7,self::$quality*7,self::$quality*793,self::$quality*273,5,255,255,255);
//$Test->drawRectangle(self::$quality*5,self::$quality*5,self::$quality*795,self::$quality*275,200,200,200);
// Pri vsoti ne izpisujemo procentov
if($spremenljivka['tip'] == 18 || ($spremenljivka['tip'] == 1 && self::$settings['type'] == 2 && self::$settings['value_type'] == 1))
$labels = (self::$settings['sort'] == 1) ? 'custom_sort' : 'custom';
else
$labels = (self::$settings['sort'] == 1) ? 'custom_percent_sort' : 'custom_percent';
// Izrisemo 3d krozni graf
$Test->drawPieGraph($DataSet->GetData(),$DataSet->GetDataDescription(),self::$quality*390,self::$quality*130,self::$quality*95,$labels,$EnhanceColors=true,$Skew=50,$SpliceHeight=self::$quality*20,$SpliceDistance=0,$Decimals=0);
// Finish the graph
$Test->setFontProperties(dirname(__FILE__).'/../../pChart/Fonts/verdana.ttf',self::$quality*self::$fontSize);
//$Test->drawLegend(700,30,$DataSet->GetDataDescription(),255,255,255);
if($show_legend == 1)
$Test->drawPieLegend(self::$quality*600,self::$quality*50,$DataSet->GetData(),$DataSet->GetDataDescription(),255,255,255);
$Test->setFontProperties(dirname(__FILE__).'/../../pChart/Fonts/verdana.ttf',self::$quality*10);
if($spremenljivka['tip'] == 18)
$Test->drawTitle(self::$quality*180,self::$quality*30,$lang['srv_analiza_sums_average'],0,0,0,self::$quality*610);
$Test->setFontProperties(dirname(__FILE__).'/../../pChart/Fonts/verdana.ttf',self::$quality*self::$fontSize);
$Test->setAntialias(false, 0);
// Prikaz numerusa na grafu
$char = (self::$settings['base'] == 1 && ($spremenljivka['tip'] == 2 || $spremenljivka['tip'] == 16)) ? 'r' : 'n';
if( self::$settings['show_numerus'] == 1 || (self::$settings['show_numerus'] == -1 && SurveyDataSettingProfiles :: getSetting('chartNumerusText') == 1) )
$numerus = $char.' = '.$DataSet->GetNumerus();
elseif( self::$settings['show_numerus'] == -1 && SurveyDataSettingProfiles :: getSetting('chartNumerusText') == 2 )
$numerus = $char.' = ' . $DataSet->GetNumerus() . self::$numerusText;
else
$numerus = '';
$Test->drawTextBox(self::$quality*600,self::$quality*220,self::$quality*715,self::$quality*230,$numerus,$Angle=0,$R=0,$G=0,$B=0,$Align=ALIGN_LEFT,$Shadow=FALSE,$BgR=-1,$BgG=-1,$BgB=-1,$Alpha=0);
$vars = count($spremenljivka['options']);
// Prikaz povprecja na grafu (samo pri ordinalnem radiu)
if( ($spremenljivka['tip'] == 1 || $spremenljivka['tip'] == 3)
&& $spremenljivka['skala'] != 1
&& (self::$settings['show_avg'] == 1 || (self::$settings['show_avg'] == -1 && $vars == 5 && SurveyDataSettingProfiles :: getSetting('chartAvgText') == 1)) ){
$Test->drawTextBox(self::$quality*600,self::$quality*240,self::$quality*715,self::$quality*245,'x = '.$DataSet->GetAverage(),$Angle=0,$R=0,$G=0,$B=0,$Align=ALIGN_LEFT,$Shadow=FALSE,$BgR=-1,$BgG=-1,$BgB=-1,$Alpha=0);
$Test->drawTextBox(self::$quality*600,self::$quality*245,self::$quality*715,self::$quality*250,'‾',$Angle=0,$R=0,$G=0,$B=0,$Align=ALIGN_LEFT,$Shadow=FALSE,$BgR=-1,$BgG=-1,$BgB=-1,$Alpha=0);
}
return $Test;
}
// Funkcije za izris posameznih tipov grafov - linijski graf
//spremenljivka je lahko null za linijski graf analize editiranja (SurveyEditsAnalysis)
static function createLine($DataSet, $spremenljivka, $show_legend=0, $fixedScale=0){
// Initialise the graph
$Test = new pChart(self::$quality*800,self::$quality*280);
// Nastavimo barve grafu glede na skin
$Test = self::setChartColors($Test, self::$skin);
if($spremenljivka != null && ($spremenljivka['tip'] == 6 && $fixedScale == 1 && $spremenljivka['enota'] != 3) || ($spremenljivka['tip'] == 6 && $fixedScale == 0 && $spremenljivka['enota'] == 3)){
$VMax = count($spremenljivka['options']);
$Divisions = $VMax-1;
$Test->setFixedScale($VMin=1, $VMax, $Divisions);
}
$count = count($DataSet->GetData());
// Ce imamo numeric vse vrednosti in jih je vec kot 20 omejimo max 20 label na X osi
$SkipLabels = 1;
if($spremenljivka != null && ($spremenljivka['tip'] == 7 || $spremenljivka['tip'] == 22) && $count > 20)
$SkipLabels = $count / 20;
// Kot label na x osi
$angle = 0;
if($count > 6)
$angle = 45;
$Test->setLineStyle(self::$quality,$DotSize=0);
$Test->setFontProperties(dirname(__FILE__).'/../../pChart/Fonts/verdana.ttf',self::$quality*self::$fontSize);
$Test->setGraphArea(self::$quality*100,self::$quality*40,self::$quality*650,self::$quality*220);
$Test->drawFilledRoundedRectangle(self::$quality*7,self::$quality*7,self::$quality*793,self::$quality*273,5,255,255,255);
//$Test->drawRectangle(self::$quality*5,self::$quality*5,self::$quality*795,self::$quality*275,200,200,200);
$Test->drawGraphArea(255,255,255,TRUE);
// Pri checkboxu lahko naredimo fiksno skalo
if($spremenljivka != null && $spremenljivka['tip'] == 2 && self::$settings['noFixedScale'] == 1){
// Frekvence
if(self::$settings['value_type'] == 1){
// Dobimo sum frekvenc
$sum = 0;
foreach($DataSet->GetData() as $vrednost){
$sum += $vrednost['Vrednosti'];
}
$Test->setFixedScale(0, $sum);
}
// Odstotki
else
$Test->setFixedScale(0, 100);
}
$Test->drawScale($DataSet->GetData(),$DataSet->GetDataDescription(),SCALE_START0,0,0,0,TRUE,$angle,0,TRUE, $SkipLabels);
if($count <= 20)
$Test->drawGrid(4,TRUE,230,230,230,50);
// Draw the 0 line
$Test->setFontProperties(dirname(__FILE__).'/../../pChart/Fonts/verdana.ttf',self::$quality*self::$fontSize);
//$Test->drawTreshold(0,143,55,72,TRUE,TRUE);
// Draw the bar graph
$Test->drawLineGraph($DataSet->GetData(),$DataSet->GetDataDescription());
if($count <= 20)
$Test->drawPlotGraph($DataSet->GetData(),$DataSet->GetDataDescription(),self::$quality*3,self::$quality*2,255,255,255);
if($show_legend == 1)
$Test->drawLegend(self::$quality*680,self::$quality*30,$DataSet->GetDataDescription(),255,255,255);
$Test->setFontProperties(dirname(__FILE__).'/../../pChart/Fonts/verdana.ttf',self::$quality*self::$fontSize);
// Prikaz numerusa na grafu
$char = (self::$settings['base'] == 1 && ($spremenljivka != null && ($spremenljivka['tip'] == 2 || $spremenljivka['tip'] == 16))) ? 'r' : 'n';
if( self::$settings['show_numerus'] == 1 || (self::$settings['show_numerus'] == -1 && SurveyDataSettingProfiles :: getSetting('chartNumerusText') == 1) )
$numerus = $char.' = '.$DataSet->GetNumerus();
elseif( self::$settings['show_numerus'] == -1 && SurveyDataSettingProfiles :: getSetting('chartNumerusText') == 2 )
$numerus = $char.' = ' . $DataSet->GetNumerus() . self::$numerusText;
else
$numerus = '';
$Test->drawTextBox(self::$quality*690,self::$quality*(210+$addHeight),self::$quality*795,self::$quality*(220+$addHeight),$numerus,$Angle=0,$R=0,$G=0,$B=0,$Align=ALIGN_LEFT,$Shadow=FALSE,$BgR=-1,$BgG=-1,$BgB=-1,$Alpha=0);
// Prikaz povprecja za number
if($spremenljivka != null && ($spremenljivka['tip'] == 7 || $spremenljivka['tip'] == 22)
&& (self::$settings['show_avg'] == 1 || (self::$settings['show_avg'] == -1 && SurveyDataSettingProfiles :: getSetting('chartAvgText') == 1)) ){
$Test->drawTextBox(self::$quality*690,self::$quality*80,self::$quality*795,self::$quality*85,'x = '.$DataSet->GetAverage(),$Angle=0,$R=0,$G=0,$B=0,$Align=ALIGN_LEFT,$Shadow=FALSE,$BgR=-1,$BgG=-1,$BgB=-1,$Alpha=0);
$Test->drawTextBox(self::$quality*690,self::$quality*85,self::$quality*795,self::$quality*90,'‾',$Angle=0,$R=0,$G=0,$B=0,$Align=ALIGN_LEFT,$Shadow=FALSE,$BgR=-1,$BgG=-1,$BgB=-1,$Alpha=0);
}
return $Test;
}
// Funkcije za izris posameznih tipov grafov - linijski graf
static function createVerLine($DataSet, $spremenljivka, $show_legend=0, $fixedScale=0){
// Nastavimo visino grafa (ce imamo vec kot 7 variabel/gridov)
$Data = $DataSet->GetData();
$countGrids = count($Data);
$addHeight = $countGrids > 5 ? ($countGrids-5)*30 : 0;
// Imamo semanticni dif. - izpisujemo labele na desni
$rightScale = (isset($spremenljivka['enota']) && $spremenljivka['enota'] == 1 && self::$settings['scale_limit'] == 1) ? true : false;
// Initialise the graph
$Test = new MyHorBar(self::$quality*800,self::$quality*(250+$addHeight));
// Nastavimo barve grafu glede na skin
$Test = self::setChartColors($Test, self::$skin);
if($spremenljivka['tip'] == 6 && $fixedScale == 0){
$VMax = count($spremenljivka['options']);
$Divisions = $VMax-1;
$Test->setFixedScale($VMin=1, $VMax, $Divisions);
}
$Test->setLineStyle(self::$quality,$DotSize=0);
$Test->setFontProperties(dirname(__FILE__).'/../../pChart/Fonts/verdana.ttf',self::$quality*self::$fontSize);
$Test->setGraphArea(self::$quality*270,self::$quality*50,self::$quality*530,self::$quality*(220+$addHeight));
$Test->drawFilledRoundedRectangle(self::$quality*7,self::$quality*7,self::$quality*793,self::$quality*(243+$addHeight),5,255,255,255);
//$Test->drawRectangle(self::$quality*5,self::$quality*5,self::$quality*795,self::$quality*(245+$addHeight),200,200,200);
$Test->drawGraphArea(255,255,255,TRUE);
$Test->drawHorScale($DataSet->GetData(),$DataSet->GetDataDescription(),SCALE_START0,0,0,0,TRUE,0,0,TRUE,1,$rightScale,$roundText=40);
$Test->drawHorGrid(4,false,230,230,230,50);
// Draw the 0 line
$Test->setFontProperties(dirname(__FILE__).'/../../pChart/Fonts/verdana.ttf',self::$quality*6);
$Test->drawTreshold(0,143,55,72,TRUE,TRUE);
$Test->setFontProperties(dirname(__FILE__).'/../../pChart/Fonts/verdana.ttf',self::$quality*self::$fontSize);
// Draw the line graph
$Test->drawVerLineGraph($DataSet->GetData(),$DataSet->GetDataDescription(), $insideValues=false);
// Finish the graph
if($show_legend == 1){
// posebna legenda pri povprecjih
if($spremenljivka['tip'] == 6 && self::$settings['type'] == 6)
$Test->drawAvgLegend(self::$quality*680,self::$quality*30,$spremenljivka['options'],255,255,255);
else
$Test->drawLegend(self::$quality*680,self::$quality*30,$DataSet->GetDataDescription(),255,255,255);
}
$Test->setFontProperties(dirname(__FILE__).'/../../pChart/Fonts/verdana.ttf',self::$quality*self::$fontSize);
if($spremenljivka['tip'] == 18)
$Test->drawTitle(self::$quality*200,self::$quality*22,'Povprečje',150,150,150,self::$quality*585);
$Test->setFontProperties(dirname(__FILE__).'/../../pChart/Fonts/verdana.ttf',self::$quality*self::$fontSize);
// Prikaz numerusa na grafu
$char = (self::$settings['base'] == 1 && ($spremenljivka['tip'] == 2 || $spremenljivka['tip'] == 16)) ? 'r' : 'n';
if( self::$settings['show_numerus'] == 1 || (self::$settings['show_numerus'] == -1 && SurveyDataSettingProfiles :: getSetting('chartNumerusText') == 1) )
$numerus = $char.' = '.$DataSet->GetNumerus();
elseif( self::$settings['show_numerus'] == -1 && SurveyDataSettingProfiles :: getSetting('chartNumerusText') == 2 )
$numerus = $char.' = ' . $DataSet->GetNumerus() . self::$numerusText;
else
$numerus = '';
$Test->drawTextBox(self::$quality*680,self::$quality*(210+$addHeight),self::$quality*795,self::$quality*(220+$addHeight),$numerus,$Angle=0,$R=0,$G=0,$B=0,$Align=ALIGN_LEFT,$Shadow=FALSE,$BgR=-1,$BgG=-1,$BgB=-1,$Alpha=0);
return $Test;
}
// Funkcije za izris posameznih tipov grafov - vertikalni stolpci
static function createRadar($DataSet, $spremenljivka, $show_legend=0, $fixedScale=0){
$Data = $DataSet->GetData();
$countGrids = count($Data);
// Initialise the graph
$Test = new pChart(self::$quality*800,self::$quality*350);
// Pri radarju uporabimo antialiasing
$Test->setAntialias(true, 20);
// Nastavimo barve grafu glede na skin
$Test = self::setChartColors($Test, self::$skin);
$Test->setLineStyle(self::$quality,$DotSize=0);
$Test->setFontProperties(dirname(__FILE__).'/../../pChart/Fonts/verdana.ttf',self::$quality*self::$fontSize);
$Test->setGraphArea(self::$quality*100,self::$quality*40,self::$quality*650,self::$quality*320);
$Test->drawFilledRoundedRectangle(self::$quality*7,self::$quality*7,self::$quality*793,self::$quality*343,5,255,255,255);
//$Test->drawRectangle(self::$quality*5,self::$quality*5,self::$quality*795,self::$quality*345,200,200,200);
// Draw the 0 line
$Test->setFontProperties(dirname(__FILE__).'/../../pChart/Fonts/verdana.ttf',self::$quality*self::$fontSize);
$Test->drawTreshold(0,143,55,72,TRUE,TRUE);
// Pri ordinalnih multigridih prikazemo skalo od 1 do stevila variabel (ce prikazujemo povprecja)
if($spremenljivka['tip'] == 6 /*&& $spremenljivka['skala'] == 0*/ && $fixedScale == 0){
$VMax = count($spremenljivka['options']) - 1;
$Divisions = $VMax-1;
$Test->setFixedScale($VMin=1, $VMax, $Divisions);
}
else
$VMax = -1;
// Draw the radar
$Test->drawRadarAxis($DataSet->GetData(),$DataSet->GetDataDescription(),true,5,0,0,0,160,160,160,$VMax,self::$settings['radar_scale']);
// Tip radarja - navaden ali samo crte
if(self::$settings['radar_type'] == 1)
$Test->drawFilledRadar($DataSet->GetData(),$DataSet->GetDataDescription(),50,5,$VMax);
else{
$Test->setLineStyle($Width=(2*self::$quality),$DotSize=0);
$Test->drawRadar($DataSet->GetData(),$DataSet->GetDataDescription(),5,$VMax);
}
$Test->setAntialias(false, 0);
// Finish the graph
$Test->setFontProperties(dirname(__FILE__).'/../../pChart/Fonts/verdana.ttf',self::$quality*self::$fontSize);
if($show_legend == 1){
// posebna legenda pri povprecjih
if($spremenljivka['tip'] == 6 && self::$settings['type'] == 5)
$Test->drawAvgLegend(self::$quality*680,self::$quality*30,$spremenljivka['options'],255,255,255);
else
$Test->drawLegend(self::$quality*680,self::$quality*30,$DataSet->GetDataDescription(),255,255,255);
}
$Test->setFontProperties("Fonts/verdana.ttf",self::$quality*10);
//$Test->drawTitle(50,22,$spremenljivka['variable'].' - '.$spremenljivka['naslov'],50,50,50,585);
$Test->setFontProperties(dirname(__FILE__).'/../../pChart/Fonts/verdana.ttf',self::$quality*self::$fontSize);
// Prikaz numerusa na grafu
$char = (self::$settings['base'] == 1 && ($spremenljivka['tip'] == 2 || $spremenljivka['tip'] == 16)) ? 'r' : 'n';
if( self::$settings['show_numerus'] == 1 || (self::$settings['show_numerus'] == -1 && SurveyDataSettingProfiles :: getSetting('chartNumerusText') == 1) )
$numerus = $char.' = '.$DataSet->GetNumerus();
elseif( self::$settings['show_numerus'] == -1 && SurveyDataSettingProfiles :: getSetting('chartNumerusText') == 2 )
$numerus = $char.' = ' . $DataSet->GetNumerus() . self::$numerusText;
else
$numerus = '';
$Test->drawTextBox(self::$quality*600,self::$quality*220,self::$quality*715,self::$quality*230,$numerus,$Angle=0,$R=0,$G=0,$B=0,$Align=ALIGN_LEFT,$Shadow=FALSE,$BgR=-1,$BgG=-1,$BgB=-1,$Alpha=0);
return $Test;
}
// Nastavitve na vrhu
static function displayGlobalSettings(){
global $lang;
global $admin_type;
global $site_url;
self::$skin = SurveyUserSetting :: getInstance()->getSettings('default_chart_profile_skin');
//moznost osvezevanja grafov - ne uporabljamo zaenkrat
if($admin_type < 2 && false)
echo '';
// Izrisemo ostale filtre
SurveyAnalysis::DisplayFilters(self::$quality);
// prklop na vecjo resolucijo grafov (zaenkrat tukaj - kasneje v globalne nastavitve)
//self::displayHQSetting();
echo '
';
# če imamo filter zoom ga izpišemo
SurveyZoom::getConditionString();
# če imamo filter ifov ga izpišemo
SurveyConditionProfiles:: getConditionString();
# če imamo filter ifov za inspect ga izpišemo
$SI = new SurveyInspect(self::$anketa);
$SI->getConditionString();
# če ne uporabljamo privzetega časovnega profila izpišemo opozorilo
SurveyTimeProfiles :: printIsDefaultProfile();
# če imamo filter spremenljivk ga izpišemo
SurveyVariablesProfiles:: getProfileString(true);
# če imamo rekodiranje
$SR = new SurveyRecoding(self::$anketa);
$SR -> getProfileString();
SurveyDataSettingProfiles :: getVariableTypeNote();
echo '
';
}
public static function displayHQSetting(){
global $lang;
echo '
';
echo '
';
echo '
';
echo ' ';
echo ' ';
echo '
';
# nastavitev skina grafov
echo '
';
$SSH = new SurveyStaticHtml(self::$anketa);
$SSH -> displayLinkChart(false);
echo '
';
echo '
';
}
// Nastavitve na dnu
static function displayBottomSettings($noDataAlert = ""){
global $site_path;
global $lang;
echo '
';
}
// Pripis pod grafom (numerus, povprecje, spremenljivka...)
static function displayBottomChartInfo($DataSet, $spremenljivka){
global $site_path;
global $lang;
echo '
, r = '.$DataSet->GetNumerus().''.self::$numerusText.'
';
else
echo '
, n = '.$DataSet->GetNumerus().''.self::$numerusText.'
';
// povprecje (ce je radio ali droipdown ordinalna)
if(($spremenljivka['tip'] == 1 || $spremenljivka['tip'] == 3) && $spremenljivka['skala'] != 1)
echo '
, x = '.$DataSet->GetAverage().'
';
echo '
';
echo '
';
}
// Nastavitve posameznega grafa
static function displaySingleSettings($spid, $settings=0){
global $site_path;
global $lang;
if (self::$publicChart == true) {
return false;
}
$spremenljivka = SurveyAnalysis::$_HEADERS[$spid];
// Ikone izvoza na vrhu posameznih nastavitev
self::displayExportIcons($spid);
echo '
';
echo '
';
echo '
'.$lang['srv_chart_settings_basic'].'
';
echo '
'.$lang['srv_chart_settings_advanced'].'
';
echo '
';
// OSNOVNE NASTAVITVE
echo '
';
switch($spremenljivka['tip']){
case 1:
case 3:
self::displayRadioSettings($spid, $settings);
break;
case 2:
self::displayCheckboxSettings($spid, $settings);
break;
case 6:
if(isset($spremenljivka['enota'])&&$spremenljivka['enota'] == 3)
self::displayDoubleMultigridSettings($spid, $settings);
else
self::displayMultigridSettings($spid, $settings);
break;
case 7:
case 22:
self::displayNumberSettings($spid, $settings);
break;
case 8:
self::displayDateSettings($spid, $settings);
break;
case 16:
self::displayMulticheckboxSettings($spid, $settings);
break;
case 17:
self::displayRankingSettings($spid, $settings);
break;
case 18:
self::displayVsotaSettings($spid, $settings);
break;
case 20:
self::displayMultinumberSettings($spid, $settings);
break;
default:
break;
}
// Preview vprasanja
echo '
';
switch($spremenljivka['tip']){
case 1:
case 3:
self::displayAdvancedRadioSettings($spid, $settings);
break;
case 2:
self::displayAdvancedCheckboxSettings($spid, $settings);
break;
case 6:
if(isset($spremenljivka['enota']) && $spremenljivka['enota'] == 3)
self::displayAdvancedDoubleMultigridSettings($spid, $settings);
else
self::displayAdvancedMultigridSettings($spid, $settings);
break;
case 7:
case 22:
self::displayAdvancedNumberSettings($spid, $settings);
break;
case 8:
self::displayAdvancedDateSettings($spid, $settings);
break;
case 16:
self::displayAdvancedMulticheckboxSettings($spid, $settings);
break;
case 17:
self::displayAdvancedRankingSettings($spid, $settings);
break;
case 18:
self::displayAdvancedVsotaSettings($spid, $settings);
break;
case 20:
self::displayAdvancedMultinumberSettings($spid, $settings);
break;
default:
break;
}
echo '
';
echo '
';
}
// Nastavitve posamezne tabele (odprti odgovori)
static function displaySingleSettingsTable($spid, $settings=0){
global $site_path;
global $lang;
if (self::$publicChart == true) {
return false;
}
$spremenljivka = SurveyAnalysis::$_HEADERS[$spid];
// Ikone izvoza na vrhu posameznih nastavitev
self::displayExportIcons($spid, $hide_button=true);
echo '
';
echo '
'.$lang['srv_chart_open_answers_settings'].'
';
// OSNOVNE NASTAVITVE
echo '
';
switch($spremenljivka['tip']){
case 21:
case 4:
self::displayTableSettings($spid);
break;
case 19:
self::displayMultitextSettings($spid, $settings);
break;
default:
break;
}
// Preview vprasanja
echo '
';
}
// ikone na vrhu posameznih nastavitev (izvozi)
static function displayExportIcons($spid, $hide_button=false){
global $site_path;
global $lang;
$spremenljivka = isset(SurveyAnalysis::$_HEADERS[$spid])?SurveyAnalysis::$_HEADERS[$spid]:array();
$loop = (isset(SurveyAnalysis::$_CURRENT_LOOP)) ? SurveyAnalysis::$_CURRENT_LOOP['cnt'] : 'undefined';
// linki
echo '
';
// Izvoz posameznega grafa v PDF/RTF/PPT
echo '';
echo '';
// V PPT zaenkrat ne izvazamo tabel
if(isset($spremenljivka['tip'])&&$spremenljivka['tip'] != 4 && $spremenljivka['tip'] != 19 && $spremenljivka['tip'] != 21)
echo '';
// Gumb za nastavitve
if(!$hide_button)
echo '';
echo '
';
}
// Nastavitve za radio grafe (tip 1,3)
static function displayRadioSettings($spid, $settings){
global $site_path;
global $lang;
$spremenljivka = isset(SurveyAnalysis::$_HEADERS[$spid])?SurveyAnalysis::$_HEADERS[$spid]:array();
// Nastavitve numeric dropdowna - obravnavamo kot number
if(isset($spremenljivka['tip'])&&$spremenljivka['tip'] == 3 && self::checkDropdownNumeric($spid)){
// Tip grafa
echo '
';
}
}
}
// Nastavitve za radio grafe (tip 1,3) - NAPREDNO
static function displayAdvancedRadioSettings($spid, $settings){
global $site_path;
global $lang;
$spremenljivka = SurveyAnalysis::$_HEADERS[$spid];
// prikaz numerusa
echo '
';
}
}
// Nastavitve za checkbox grafe (tip 2)
static function displayAdvancedCheckboxSettings($spid, $settings){
global $site_path;
global $lang;
// prikaz numerusa
echo '
';
}
// prikaz label majhnih vrednosti zraven stolpcov
if($settings['barLabel'] == 1 && ($settings['type'] == 0 || $settings['type'] == 1)){
echo '
';
echo '';
echo '';
echo '
';
}
}
// Nastavitve za number grafe (tip 7)
static function displayNumberSettings($spid, $settings){
global $site_path;
global $lang;
// Tip grafa
echo '
';
echo $lang['srv_chart_type'].': ';
echo '
';
// tip izpisa vrednosti
if($settings['type'] != 9){
echo '
';
}
// Nastavitve za number grafe (tip 7)
static function displayAdvancedNumberSettings($spid, $settings){
global $site_path;
global $lang;
// prikaz numerusa
echo '
';
}
}
// Nastavitve za datum grafe (tip 8)
static function displayDateSettings($spid, $settings){
global $site_path;
global $lang;
// Tip grafa
echo '
';
echo $lang['srv_chart_type'].': ';
echo '
';
// tip izpisa vrednosti
if($settings['type'] < 3){
echo '
';
}
}
// Nastavitve za datum grafe (tip 8)
static function displayAdvancedDateSettings($spid, $settings){
global $site_path;
global $lang;
// prikaz numerusa
echo '
';
}
// Nastavitve za dvojne multigrid grafe (tip 6, enota 3)
static function displayDoubleMultigridSettings($spid, $settings){
global $site_path;
global $lang;
$spremenljivka = SurveyAnalysis::$_HEADERS[$spid];
// Tip grafa
echo '
';
echo $lang['srv_chart_type'].': ';
echo '
';
// Tip radarja
if($settings['type'] == '4'){
echo '
';
}
// prikaz label v stolpcih
if($settings['type'] == 0 || $settings['type'] == 1){
echo '
';
echo '';
echo '';
echo '
';
}
}
// Nastavitve za dvojne multigrid grafe (tip 6, enota 3)
static function displayAdvancedDoubleMultigridSettings($spid, $settings){
global $site_path;
global $lang;
$spremenljivka = SurveyAnalysis::$_HEADERS[$spid];
// prikaz numerusa
echo '
';
// prikaz label v stolpcih
if($settings['type'] == 2 || $settings['type'] == 3){
echo '
';
echo '';
echo '';
echo '
';
}
}
// Nastavitve za multicheckbox grafe (tip 16)
static function displayAdvancedMulticheckboxSettings($spid, $settings){
global $site_path;
global $lang;
// prikaz numerusa
echo '
';
}
// prikaz label v stolpcih
if($settings['type'] == 2 || $settings['type'] == 3){
echo '
';
echo '';
echo '';
echo '
';
}
}
// Nastavitve za vsoto (tip 18)
static function displayAdvancedVsotaSettings($spid, $settings){
global $site_path;
global $lang;
// prikaz numerusa
echo '
';
}
// prikaz label majhnih vrednosti zraven stolpcov
if($settings['barLabel'] == 1 && ($settings['type'] == 2 || $settings['type'] == 3)){
echo '
';
echo '';
echo '';
echo '
';
}
}
// Nastavitve za ranking grafe (tip 17)
static function displayRankingSettings($spid, $settings){
global $site_path;
global $lang;
// Tip grafa
echo '
';
echo $lang['srv_chart_type'].': ';
echo '
';
// sortiranje
echo '
';
echo $lang['srv_chart_sort'].': ';
echo '
';
// tip izpisa vrednosti
echo '
';
echo $lang['srv_chart_valtype'].': ';
echo '
';
// prikaz label v stolpcih
echo '
';
echo '';
echo '';
echo '
';
}
// Nastavitve za ranking grafe (tip 17)
static function displayAdvancedRankingSettings($spid, $settings){
global $site_path;
global $lang;
// prikaz numerusa
echo '
';
}
// prikaz label majhnih vrednosti zraven stolpcov
if($settings['barLabel'] == 1 && $settings['type'] == 0){
echo '
';
echo '';
echo '';
echo '
';
}
// zacni skalo z 0 (samo pri povprecju)
if($settings['type'] == 0){
echo '
';
echo '';
echo '';
echo '
';
}
}
// Nastavitve za multinumber (tip 20)
static function displayMultinumberSettings($spid, $settings){
global $site_path;
global $lang;
// Tip grafa
echo '
';
}
}
// Nastavitve za multinumber (tip 20)
static function displayAdvancedMultinumberSettings($spid, $settings){
global $site_path;
global $lang;
// prikaz numerusa
echo '