diff options
Diffstat (limited to 'scrapersources/oep-exemptions_1')
-rw-r--r-- | scrapersources/oep-exemptions_1 | 101 |
1 files changed, 101 insertions, 0 deletions
diff --git a/scrapersources/oep-exemptions_1 b/scrapersources/oep-exemptions_1 new file mode 100644 index 0000000..29c3a98 --- /dev/null +++ b/scrapersources/oep-exemptions_1 @@ -0,0 +1,101 @@ +<!doctype html> +<html lang="nb"> +<head> +<meta charset="utf-8" /> +<title>Hvor mange dokumenter er journalført i hver etat og hvor mange er unntatt innsyn?</title> +<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script> +<script src="https://cdnjs.cloudflare.com/ajax/libs/highcharts/2.2.2/highcharts.js"></script> +<!-- <script src="https://code.highcharts.com/modules/exporting.js"></script>--> +<script src="https://cdnjs.cloudflare.com/ajax/libs/underscore.js/1.3.3/underscore-min.js"></script> +<script> +$(function() + { + var chart; + var query_url = "https://api.scraperwiki.com/api/1.0/datastore/sqlite?format=jsondict&name=postliste-oep&query=select%20Agency%2C%22Grounds%20for%20exemption%20document%22%20as%20ex%2C%20count(*)%20as%20num%20from%20%60swdata%60%20group%20by%20Agency%2Cex%20"; + + function get_chart_opts(agencies, series) { + return { + chart: { renderTo: 'container', type: 'bar' }, + title: { text: 'Hvor mange dokumenter er journalført i hver etat og hvor mange er unntatt innsyn?' }, + xAxis: { categories: agencies }, + yAxis: { + min: 0, + title: { text: "Antall journalførte dokumenter" }, + }, + legend: { + backgroundColor: '#FFFFFF', + reversed: true + }, + tooltip: { + formatter: function() { + return ''+ this.series.name + ': '+ this.y + ' ('+parseInt(this.percentage) + '%)'; + + } + }, + plotOptions: { + series: { + stacking: 'percent' + } + }, + series: series + }; + + } + + function populate_chart(data) { + // TODO: Very naive iteration today. Should be optimized + var agencies = _.uniq( _.pluck(data, 'Agency') ); + var totals = {}; + var not_exemption = {}; + var series = []; + + // traverse and find data + _.each(data, function(entry) { + var agency_name = entry['Agency']; + + if (agency_name) { + if (! totals[agency_name]) { + totals[agency_name] = 0; + } + totals[agency_name] += entry['num']; + + if ("" == entry['ex']) { + not_exemption[agency_name] = entry['num']; + } + } + }); + + + // make series + series.push({ name: 'Ingen merknader', + data: _.map(agencies, function(agency) { + return not_exemption[agency]; + }) + }); + + + series.push({ name: 'Unntatt innsyn', + data: _.map(agencies, function(agency) { + return totals[agency] - not_exemption[agency]; + }) + }); + + + + chart = new Highcharts.Chart(get_chart_opts(agencies, series)); + }; + + + $(document).ready(function() { + $.ajax({ url: query_url, dataType: 'json', success: function(data){ populate_chart(data); } }); + }); +} +); + +</script> +</head> +<body> + <div id="container" style="height: 2000px;width: 100%;margin: 0 auto"></div> + <p>Alle dokumenter som har oppgitt en grunn for å unnlate offentligjøring vil telles som "Unnatt innsyn".</p> +</body> +</html> |