Merge branch 'master' of ssh://apples.lambdacomplex.org/git/disclosr
[disclosr.git] / employees-fail.php
blob:a/employees-fail.php -> blob:b/employees-fail.php
<?php <?php
include_once('include/common.inc.php'); include_once('include/common.inc.php');
include_header('Charts'); include_header('Charts');
$db = $server->get_db('disclosr-agencies'); $db = $server->get_db('disclosr-agencies');
?> ?>
<div class="foundation-header"> <div class="foundation-header">
<h1><a href="about.php">Charts</a></h1> <h1><a href="about.php">Charts</a></h1>
<h4 class="subheader">Lorem ipsum.</h4> <h4 class="subheader">Lorem ipsum.</h4>
</div> </div>
<div id="scores" style="width:900px;height:500px;"></div> <div id="scores" style="width:900px;height:500px;"></div>
<div id="employees" style="width:1000px;height:900px;"></div>  
<script id="source"> <script id="source">
window.onload = function() { window.onload = function() {
$(document).ready(function() { $(document).ready(function() {
var d1 = []; var d1 = [];
var scorelabels = []; var scorelabels = [];
<?php <?php
try { try {
$rows = $db->get_view("app", "scoreHas?group=true", null, true)->rows; $rows = $db->get_view("app", "scoreHas?group=true", null, true)->rows;
   
   
$dataValues = Array(); $dataValues = Array();
foreach ($rows as $row) { foreach ($rows as $row) {
$dataValues[$row->value] = $row->key; $dataValues[$row->value] = $row->key;
} }
$i = 0; $i = 0;
ksort($dataValues); ksort($dataValues);
foreach ($dataValues as $value => $key) { foreach ($dataValues as $value => $key) {
   
echo " d1.push([$i, $value]);" . PHP_EOL; echo " d1.push([$i, $value]);" . PHP_EOL;
echo " scorelabels.push('$key');" . PHP_EOL; echo " scorelabels.push('$key');" . PHP_EOL;
$i++; $i++;
} }
} catch (SetteeRestClientException $e) { } catch (SetteeRestClientException $e) {
setteErrorHandler($e); setteErrorHandler($e);
} }
?> ?>
function scoretrackformatter(obj) { function scoretrackformatter(obj) {
if (scorelabels[Math.floor(obj.x)]) { if (scorelabels[Math.floor(obj.x)]) {
return (scorelabels[Math.floor(obj.x)])+"="+obj.y; return (scorelabels[Math.floor(obj.x)])+"="+obj.y;
} else { } else {
return ""; return "";
} }
} }
function scoretickformatter(val, axis) { function scoretickformatter(val, axis) {
if (scorelabels[Math.floor(val)]) { if (scorelabels[Math.floor(val)]) {
return '<p style="margin-top:8em;-webkit-transform:rotate(-90deg);">'+(scorelabels[Math.floor(val)])+"</b>"; return '<p style="margin-top:8em;-webkit-transform:rotate(-90deg);">'+(scorelabels[Math.floor(val)])+"</b>";
} else { } else {
return ""; return "";
} }
} }
Flotr.draw(document.getElementById("scores"), [ {data: d1}], { Flotr.draw(document.getElementById("scores"), [ {data: d1}], {
HtmlText: true, HtmlText: true,
bars : { bars : {
show : true show : true
}, },
mouse : { mouse : {
track : true, track : true,
relative : true, relative : true,
trackFormatter: scoretrackformatter trackFormatter: scoretrackformatter
},yaxis: { },yaxis: {
autoscaling: true autoscaling: true
}, },
xaxis: { xaxis: {
autoscaling: true, autoscaling: true,
minorTickFreq: 0.6, minorTickFreq: 0.6,
noTicks : scorelabels.length, noTicks : scorelabels.length,
tickFormatter: scoretickformatter tickFormatter: scoretickformatter
} }
}); });
  <div id="employees" style="width:1000px;height:900px;"></div>
var emplabels = []; var emplabels = [];
function emptrackformatter(obj) { function emptrackformatter(obj) {
return (obj.series.label)+" = "+obj.y+" in "+emplabels[Math.floor(obj.x)]; return (obj.series.label)+" = "+obj.y+" in "+emplabels[Math.floor(obj.x)];
} }
function emptickformatter(val, axis) { function emptickformatter(val, axis) {
if (emplabels[Math.floor(val)]) { if (emplabels[Math.floor(val)]) {
return '<p style="margin-top:8em;-webkit-transform:rotate(-90deg);">'+(emplabels[Math.floor(val)])+"</b>"; return '<p style="margin-top:8em;-webkit-transform:rotate(-90deg);">'+(emplabels[Math.floor(val)])+"</b>";
} else { } else {
return ""; return "";
} }
} }
function onDataReceived(series) { function onDataReceived(series) {
emplabels = series.labels; emplabels = series.labels;
Flotr.draw(document.getElementById("employees"), series.data, { Flotr.draw(document.getElementById("employees"), series.data, {
mouse : { mouse : {
track : true, track : true,
relative : true, relative : true,
trackFormatter: emptrackformatter trackFormatter: emptrackformatter
},yaxis: { },yaxis: {
max: 10000, max: 10000,
scaling: 'logarithmic' scaling: 'logarithmic'
}, },
xaxis: { xaxis: {
minorTickFreq: 1, minorTickFreq: 1,
noTicks: emplabels.length, noTicks: emplabels.length,
showMinorLabels: true, showMinorLabels: true,
tickFormatter: emptickformatter tickFormatter: emptickformatter
}, },
legend: { legend: {
show: false show: false
} }
}); });
} }
$.ajax({ $.ajax({
url: "admin/exportEmployees.csv.php?format=json", url: "admin/exportEmployees.csv.php?format=json",
method: 'GET', method: 'GET',
dataType: 'json', dataType: 'json',
success: onDataReceived success: onDataReceived
}); });
   
}); });
}; };
</script> </script>
   
<?php <?php
include_footer(); include_footer();
?> ?>