1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 | <?php include('template.inc.php'); include_header_documents("Charts"); include_once('../include/common.inc.php'); $agenciesdb = $server->get_db('disclosr-agencies'); $idtoname = Array(); $idtofoirequestssuccessful = Array(); foreach ($agenciesdb->get_view("app", "byCanonicalName")->rows as $row) { $idtoname[$row->id] = trim($row->value->name); $foirequestssuccessful = 0; if(isset($row->value->statistics->foiRequests)) { foreach ($row->value->statistics->foiRequests as $statperiod) { $statperiod=object_to_array($statperiod); if (isset($statperiod["Requests for other information granted in full"])) $foirequestssuccessful += $statperiod["Requests for other information granted in full"]; if (isset($statperiod["Requests for other information granted in part"])) $foirequestssuccessful += $statperiod["Requests for other information granted in part"]; } } $idtofoirequestssuccessful[$row->id] =$foirequestssuccessful; } $foidocsdb = $server->get_db('disclosr-foidocuments'); ?> <div class="foundation-header"> <h1><a href="about.php">Charts</a></h1> <h4 class="subheader"></h4> </div> <div id="bydate" style="width:1000px;height:300px;"></div> <div id="byagency" style="width:1000px;height:1400px;"></div> <script id="source"> window.onload = function () { $(document).ready(function () { var d1 = [], options1, o1; <?php try { $rows = $foidocsdb->get_view("app", "byDateMonthYear?group=true",null, false,false,true)->rows; $dataValues = Array(); foreach ($rows as $row) { $dataValues[$row->key] = $row->value; } $i = 0; ksort($dataValues); foreach ($dataValues as $key => $value) { $date = date_create_from_format('Y-m-d', $key); if (date_format($date, 'U') != "") { echo " d1.push([".date_format($date, 'U')."000, $value]);" . PHP_EOL; // echo " emplabels.push('$key');" . PHP_EOL; $i++; } } } catch (SetteeRestClientException $e) { setteErrorHandler($e); } ?> options1 = { xaxis: { mode: 'time', labelsAngle: 45 }, selection: { mode: 'x' }, HtmlText: false, title: 'Disclosure Log entries added by Date' }; // Draw graph with default options, overwriting with passed options function drawGraph(opts) { // Clone the options, so the 'options' variable always keeps intact. o1 = Flotr._.extend(Flotr._.clone(options1), opts || {}); // Return a new graph. return Flotr.draw( document.getElementById("bydate"), [ d1 ], o1 ); } graph = drawGraph(); Flotr.EventAdapter.observe(document.getElementById("bydate"), 'flotr:select', function (area) { // Draw selected area graph = drawGraph({ xaxis: { min: area.x1, max: area.x2, mode: 'time', labelsAngle: 45 }, yaxis: { min: area.y1, max: area.y2 } }); }); // When graph is clicked, draw the graph with default area. Flotr.EventAdapter.observe(document.getElementById("bydate"), 'flotr:click', function () { graph = drawGraph(); }); }); }; var d2 = []; var d3 = []; var agencylabels = []; function agencytrackformatter(obj) { return agencylabels[Math.floor(obj.y)] + " = " + obj.x; } function agencytickformatter(val, axis) { if (agencylabels[Math.floor(val)]) { return (agencylabels[Math.floor(val)]) ; } else { return ""; } } <?php try { $rows = $foidocsdb->get_view("app", "byAgencyID?group=true",null, false,false,true)->rows; function cmp($a, $b) { return $a->value > $b->value; } usort($rows, "cmp"); $dataValues = Array(); $i = 0; foreach ($rows as $row) { echo " d2.push([ $row->value,$i]);" . PHP_EOL; echo " d3.push([ ".$idtofoirequestssuccessful[$row->key].",$i]);" . PHP_EOL; echo " agencylabels.push(['".str_replace("'","",$idtoname[$row->key])."']);" . PHP_EOL; $i++; } } catch (SetteeRestClientException $e) { setteErrorHandler($e); } ?> // Draw the graph Flotr.draw( document.getElementById("byagency"), [d2], { title: "Disclosure Log entries by Agency", bars: { show: true, horizontal: true, shadowSize: 0, barWidth: 0.5 }, mouse: { track: true, relative: true, trackFormatter: agencytrackformatter }, yaxis: { minorTickFreq: 1, noTicks: agencylabels.length, showMinorLabels: true, tickFormatter: agencytickformatter }, xaxis: { min: 0, autoscaleMargin: 1 }, legend: { show: true } } ); </script> <?php include_footer_documents(); ?> |