Skip to content

Commit

Permalink
Cleaned up reporting, data refresh.
Browse files Browse the repository at this point in the history
  • Loading branch information
tobinbradley committed Dec 7, 2012
1 parent e4b4f90 commit a2f5c59
Show file tree
Hide file tree
Showing 9 changed files with 764 additions and 159 deletions.
15 changes: 0 additions & 15 deletions .htaccess

This file was deleted.

2 changes: 2 additions & 0 deletions css/main.css
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
content: '';
display: block;
position: absolute;
pointer-events: none;
top: 0;
right: 0;
bottom: 0;
Expand Down Expand Up @@ -105,6 +106,7 @@
#selectedNeighborhood { line-height: 20px; }
.measureText { font-size: 1.2em; font-weight: bold; }
.measure-details h5 { margin: 0; padding: 0; }
.chart { margin-bottom: 20px; }

/* report dialog */
#report_metrics { height: 200px; }
Expand Down
469 changes: 456 additions & 13 deletions img/src/report-title-page.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
41 changes: 13 additions & 28 deletions index.html

Large diffs are not rendered by default.

25 changes: 19 additions & 6 deletions js/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ $(document).ready(function() {

// Load JSON metric configuration
$.ajax({
url: "js/metrics.json?V=7",
url: "js/metrics.json?V=8",
dataType: "json",
async: false,
success: function(data){
Expand All @@ -26,7 +26,7 @@ $(document).ready(function() {

// Grab NPA JSON
$.ajax({
url: "js/npa.json",
url: "js/npa.json?V=8",
dataType: "json",
type: "GET",
async: false,
Expand All @@ -42,17 +42,24 @@ $(document).ready(function() {
$.each(FTmeta, function(index) {
if (this.style.breaks.length > 0) {
$('p[data-group=' + this.category + ']').append('<li><a href="javascript:void(0)" class="measure-link" data-measure="' + this.field + '">' + this.title + ' <i></i></a></li>');
//$('optgroup[label=' + this.category.toProperCase() + ']').append('<option value="' + this.field + '">' + this.title + '</option>');
$('optgroup[label=' + this.category.toProperCase() + ']').append('<option value="' + this.field + '">' + this.title + '</option>');
}
});

// sort metrics
$(".sidenav p").each(function() {
$("li", this).sort(asc_sort).appendTo(this);
});
/*$("#modalReport optgroup").each(function() {
$("#modalReport optgroup").each(function() {
$("option", this).sort(asc_sort).appendTo(this);
});*/
});

// report optgroup click
$("#report_metrics optgroup").click(function(e) { $(this).children().prop('selected','selected'); });
$("#report_metrics optgroup option").click(function(e) { e.stopPropagation(); });
$("#all_metrics").change(function () {
$(this).is(":checked") ? $("#report_metrics optgroup option").prop('selected','selected') : $("#report_metrics optgroup option").prop('selected', false);
});

// Set default metric
updateData(FTmeta[defaultMeasure]);
Expand Down Expand Up @@ -118,7 +125,7 @@ $(document).ready(function() {
});

// Opacity slider
$( "#opacity_slider" ).slider({ range: "min", value: 70, min: 25, max: 100, stop: function (event, ui) {
$( "#opacity_slider" ).slider({ range: "min", value: 80, min: 25, max: 100, stop: function (event, ui) {
geojson.setStyle(style);
if (activeRecord.id) highlightSelected( getNPALayer(activeRecord.id) );
}
Expand All @@ -127,6 +134,12 @@ $(document).ready(function() {
// Feedback from submit
$("#talkback").submit(function(e){
e.preventDefault();
$('#modalTalkback').modal('hide');
$.ajax({
type: "POST",
url: "php/feedback.php",
data: { inputName: $("#inputName").val(), inputEmail: $("#inputEmail").val(), inputURL: window.location.href, inputFeedback: $("#inputFeedback").val() }
});
});

// jQuery UI Autocomplete
Expand Down
265 changes: 210 additions & 55 deletions js/metrics.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion js/npa.json

Large diffs are not rendered by default.

104 changes: 63 additions & 41 deletions php/report.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

ob_start();

/**
* Set content header
*/
Expand Down Expand Up @@ -68,13 +70,25 @@ function Footer()
}
}

// Prety up the number
function prettyData($data, $themeasure) {
global $pdf, $json, $npadata, $chartColors;
if (is_null($data) || !is_numeric($data)) {
return "N/A";
}
else {
if ($data >= 10000) $data = number_format($data);
return $json[$themeasure]["style"]["prefix"] . $data . $json[$themeasure]["style"]["units"];
}
}

/**
* Create PDF
*/
$pdf = new PDF('P','in','Letter');



/************************************************************/
/* Cover Page */
/************************************************************/
Expand All @@ -89,24 +103,24 @@ function Footer()

// Title page header
$pdf->SetFont('Arial','B',40);
$pdf->Ln(0.8);
$pdf->Ln(0.7);
$pdf->Cell(0.3);
$pdf->Cell(0,0, "Neighborhood Profile Area");

// Title page neighborhood
$pdf->SetFont('Arial','B',180);
$pdf->Ln(1.8);
$pdf->Ln(1.75);
$pdf->Cell(0.3);
//$pdf->Cell(1.7);
$pdf->Cell(0, 0, $neighborhood);

// Title page main content
$pdf->Ln(3.8);
$pdf->Cell(1);
$pdf->SetTextColor(0,0,0);
$pdf->SetFont('Arial','', 14);
$text = "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Fusce elementum tortor vitae tortor dapibus quis porta est fringilla. Etiam vulputate erat id purus elementum scelerisque. Sed id risus nisi, at dapibus nisi. Aliquam in enim eu odio gravida interdum sed sed odio. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos. Cras ullamcorper ornare augue. Nulla mollis orci quis quam pulvinar semper. Pellentesque interdum libero vitae enim ultrices faucibus. Duis vel enim eget ipsum aliquet sollicitudin in ut massa. In diam lacus, sodales id ornare eu, dictum et sem. Fusce iaculis viverra tortor, et volutpat nulla posuere quis.";
$pdf->MultiCell(5.8, 0.2, $text);
$pdf->Ln(3.15);
$pdf->Cell(0.43);
$pdf->SetTextColor(0,0,45);
$pdf->SetFont('Arial','B', 50);
$text = "Quality of Life Study";
$pdf->MultiCell(0, 0.2, $text);


/************************************************************/
Expand Down Expand Up @@ -156,26 +170,29 @@ function createMeasure($x, $y, $themeasure) {
$pdf->SetTextColor(0,0,0);
$pdf->SetY($y);
$pdf->SetX($x);
//$pdf->SetLeftMargin($x);
//$pdf->SetRightMargin($x + 4);
$pdf->SetFont('Arial','B',12);
$pdf->Write(0, $json[$themeasure][title] );
$pdf->Ln(0.2);
$pdf->SetX($x);
$pdf->Write(0, $npadata[$json[$themeasure]["field"]] . $json[$themeasure]["style"]["units"]);
$pdf->Ln(0.2);
$pdf->SetX($x);
$chartMax = ($npadata[$json[$themeasure]["field"]] >= round($json[$themeasure]["style"]["avg"]) ? $npadata[$json[$themeasure]["field"]] : round($json[$themeasure]["style"]["avg"]));
$chartMax = ($chartMax > 100 ? $chartMax + 100 : 100 );
$pdf->Image( "http://chart.apis.google.com/chart?chxr=0,0," . $chartMax . "&chxl=1:|2010&chxt=x,y&chbh=a,4,9&chs=250x75&cht=bhg&chco=FF9900,FFCA7A&chds=0," . $chartMax . ",0," . $chartMax . "&chd=t:" . $npadata[$json[$themeasure]["field"]] . "|" . round($json[$themeasure]["style"]["avg"]) . "&chdl=Neightborhood|NPA+Average&chdlp=t&chg=-1,0", null , null, 0, 0, "PNG");
$pdf->Ln(0.2);
// $pdf->Write(0, $json[$themeasure][title] );
$pdf->MultiCell(3.5, 0.15, prettyData($npadata[$json[$themeasure]["field"]], $themeasure) . " " . utf8_decode($json[$themeasure][title]), 0, "L");
//$pdf->Ln(0.15);
//$pdf->SetX($x);
//$pdf->Write(0, $json[$themeasure]["style"]["prefix"] . (is_null($npadata[$json[$themeasure]["field"]]) ? "N/A" : $npadata[$json[$themeasure]["field"]]) . $json[$themeasure]["style"]["units"]);
$pdf->Ln(0.15);
//$pdf->SetX($x);
//$chartMax = ($npadata[$json[$themeasure]["field"]] >= round($json[$themeasure]["style"]["avg"]) ? $npadata[$json[$themeasure]["field"]] : round($json[$themeasure]["style"]["avg"]));
//$chartMax = ($chartMax > 100 ? $chartMax + 100 : 100 );
// $pdf->Image( "http://chart.apis.google.com/chart?chxr=0,0," . $chartMax . "&chxl=1:|2010&chxt=x,y&chbh=a,4,9&chs=250x75&cht=bhg&chco=FF9900,FFCA7A&chds=0," . $chartMax . ",0," . $chartMax . "&chd=t:" . $npadata[$json[$themeasure]["field"]] . "|" . round($json[$themeasure]["style"]["avg"]) . "&chdl=Neightborhood|NPA+Average&chdlp=t&chg=-1,0", null , null, 0, 0, "PNG");
// $pdf->Ln(0.2);
$pdf->SetX($x);
$pdf->SetFont('Arial','B',10);
$pdf->Write(0, "What is this Indicator?");
$pdf->Ln(0.1);
$pdf->SetX($x);
$pdf->SetFont('Arial','',10);
$pdf->MultiCell(3.5, 0.15, strip_tags($json[$themeasure][description]), 0, "L");
if ($json[$themeasure][auxchart]) {
$pdf->Ln(0.2);
$pdf->MultiCell(3.5, 0.15, utf8_decode(strip_tags($json[$themeasure][description])), 0, "L");
/*if ($json[$themeasure][auxchart]) {
$pdf->Ln(0.15);
$pdf->SetX($x);
$measureTitles = array();
$measureValues = array();
Expand All @@ -189,39 +206,42 @@ function createMeasure($x, $y, $themeasure) {
$auxContent = "http://chart.apis.google.com/chart?chf=bg,s,00000000&chs=320x165&cht=p&chp=0.1";
$auxContent .= "&chd=t:" . implode(",", $measureValues) . "&chdl=" . str_replace(" ", "+", implode("|", $measureTitles)) . "&chco=";
$pdf->Image( $auxContent, null , null, 0, 0, "PNG");
}
$pdf->Ln(0.2);
}*/
$pdf->Ln(0.15);
$pdf->SetX($x);
$pdf->SetFont('Arial','B',10);
$pdf->Write(0, "Why is this Important?");
$pdf->Ln(0.1);
$pdf->SetX($x);
$pdf->SetFont('Arial','',10);
$pdf->MultiCell(3.5, 0.15, strip_tags($json[$themeasure][importance]), 0, "L");
$pdf->Ln(0.2);
$pdf->SetX($x);
$pdf->SetFont('Arial','B',10);
$pdf->Write(0, "Technical Notes");
$pdf->Ln(0.1);
$pdf->SetX($x);
$pdf->SetFont('Arial','',10);
$pdf->MultiCell(3.5, 0.15, strip_tags($json[$themeasure][tech_notes]), 0, "L");
$pdf->Ln(0.2);
$pdf->MultiCell(3.5, 0.15, utf8_decode(strip_tags($json[$themeasure][importance])), 0, "L");
$pdf->Ln(0.15);
$pdf->SetX($x);
$pdf->SetFont('Arial','B',10);
$pdf->Write(0, "Data Source");
$pdf->Write(0, "About the Data");
$pdf->Ln(0.1);
$pdf->SetX($x);
$pdf->SetFont('Arial','',10);
$pdf->MultiCell(3.5, 0.15, strip_tags($json[$themeasure][source]), 0, "L");
$pdf->Ln(0.2);
$pdf->SetX($x);
$pdf->SetFont('Arial','B',10);
$pdf->MultiCell(3.5, 0.15, utf8_decode(strip_tags($json[$themeasure][tech_notes])) . "\n\n". utf8_decode(strip_tags($json[$themeasure][source])), 0, "L");
//$pdf->Ln(0.15);
//$pdf->SetX($x);
//$pdf->SetFont('Arial','B',10);
//$pdf->Write(0, "Data Something");
//$pdf->Ln(0.1);
//$pdf->SetX($x);
//$pdf->SetFont('Arial','',10);
//$pdf->MultiCell(3.5, 0.15, utf8_decode(strip_tags($json[$themeasure][source])), 0, "L");

//$pdf->Ln(0.2);
//$pdf->SetX($x);
//$pdf->SetFont('Arial','B',10);
//$pdf->Write(0, "Additional Resources");
//$pdf->Ln(0.1);
//$pdf->SetX($x);
//$pdf->SetFont('Arial','',9);
//$pdf->SetTextColor(0,0,255);
//$pdf->SetLeftMargin($x);
//$pdf->WriteHTML($json[$themeasure][links]);
//$pdf->SetFont('','U');

}
Expand All @@ -234,14 +254,16 @@ function createMeasure($x, $y, $themeasure) {
// loop for each page - 4 measures per page
if (strlen($measures[0]) > 0) {
$measureCount = 0;
for ($i=0; $i < ceil(count($measures) / 2); $i++) {
for ($i=0; $i < ceil(count($measures) / 4); $i++) {
// add page
$pdf->AddPage();

if ($measures[ $measureCount]) createMeasure(0.5, 0.5, $measures[$measureCount]);
if ($measures[$measureCount + 1]) createMeasure(4.3, 0.5, $measures[$measureCount + 1]);
if ($measures[$measureCount + 2]) createMeasure(0.5, 5.5, $measures[$measureCount + 2]);
if ($measures[$measureCount + 3]) createMeasure(4.3, 5.5, $measures[$measureCount + 3]);

$measureCount = $measureCount + 2;
$measureCount = $measureCount + 4;
}
}

Expand All @@ -252,6 +274,6 @@ function createMeasure($x, $y, $themeasure) {
/************************************************************/
$pdf->Output();


ob_end_flush();

?>
Binary file modified php/report_cover_page.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit a2f5c59

Please sign in to comment.