Просмотр исходного кода

Add "Eye Contact by Period" chart

Alan Lam 7 лет назад
Родитель
Сommit
4028a1bad7

+ 36 - 0
template_processing/age_verification/reports_build_charts.php

@@ -119,6 +119,42 @@ $chart->addDataset("Fail Rate (%)", $fail_rates, [
 $chart->setDatalabelSuffixes("%", "%");
 $charts[] = $chart;
 
+// Eye Contact Period
+$eye_contact_rates = array_values(array_map(function($period) {
+	if($period->testCount == 0) return [0, 0, 0];
+
+	$yes = round(($period->eyeContactCounts[0] / $period->testCount) * 100);
+	$no = round(($period->eyeContactCounts[1] / $period->testCount) * 100);
+	$na = 100 - $yes - $no;
+
+	return [$yes, $no, $na];
+}, $data));
+
+$chart = new Chart;
+$chart->addXAxis([
+	"type" => "category",
+	"stacked" => true,
+]);
+$chart->addYAxis([
+	"id" => "y-axis-1",
+	"tick_config" => ["min" => 0, "max" => 100],
+	"stacked" => true,
+]);
+$chart->setType("bar");
+$chart->setTitle("Eye Contact by {$resolution_name}");
+$chart->setLabels($x_data_labels);
+$chart->addDataset("Yes (%)", array_column($eye_contact_rates, 0), [
+	"background_colours" => "#4CAF50"
+]);
+$chart->addDataset("No (%)", array_column($eye_contact_rates, 1), [
+	"background_colours" => "#F44336"
+]);
+$chart->addDataset("N/A (%)", array_column($eye_contact_rates, 2), [
+	"background_colours" => "#bdbdbd"
+]);
+$chart->setDatalabelSuffixes("%", "%", "%");
+$charts[] = $chart;
+
 // Totals by Period
 
 $test_counts = array_column($data, "testCount");

+ 4 - 0
template_processing/age_verification/reports_create_empty_objects.php

@@ -6,6 +6,8 @@ $empty_data = (object) [
 	"passCount" => 0,
 	"failCount" => 0,
 
+	"eyeContactCounts" => [0, 0, 0],
+
 	"maleTesterCount" => 0,
 	"femaleTesterCount" => 0,
 
@@ -48,6 +50,8 @@ $total_data = (object) [
 	"femaleChallengerCount" => 0,
 	"unspecifiedChallengerCount" => 0,
 
+	"eyeContactCounts" => [0, 0, 0],
+
 	"testCount" => 0,
 	"passCount" => 0,
 	"failCount" => 0,

+ 36 - 0
template_processing/age_verification_mitchells_butlers/reports_build_charts.php

@@ -119,6 +119,42 @@ $chart->addDataset("Fail Rate (%)", $fail_rates, [
 $chart->setDatalabelSuffixes("%", "%");
 $charts[] = $chart;
 
+// Eye Contact Period
+$eye_contact_rates = array_values(array_map(function($period) {
+	if($period->testCount == 0) return [0, 0, 0];
+
+	$yes = round(($period->eyeContactCounts[0] / $period->testCount) * 100);
+	$no = round(($period->eyeContactCounts[1] / $period->testCount) * 100);
+	$na = 100 - $yes - $no;
+
+	return [$yes, $no, $na];
+}, $data));
+
+$chart = new Chart;
+$chart->addXAxis([
+	"type" => "category",
+	"stacked" => true,
+]);
+$chart->addYAxis([
+	"id" => "y-axis-1",
+	"tick_config" => ["min" => 0, "max" => 100],
+	"stacked" => true,
+]);
+$chart->setType("bar");
+$chart->setTitle("Eye Contact by {$resolution_name}");
+$chart->setLabels($x_data_labels);
+$chart->addDataset("Yes (%)", array_column($eye_contact_rates, 0), [
+	"background_colours" => "#4CAF50"
+]);
+$chart->addDataset("No (%)", array_column($eye_contact_rates, 1), [
+	"background_colours" => "#F44336"
+]);
+$chart->addDataset("N/A (%)", array_column($eye_contact_rates, 2), [
+	"background_colours" => "#bdbdbd"
+]);
+$chart->setDatalabelSuffixes("%", "%", "%");
+$charts[] = $chart;
+
 // Totals by Period
 
 $test_counts = array_column($data, "testCount");

+ 4 - 0
template_processing/age_verification_mitchells_butlers/reports_create_empty_objects.php

@@ -6,6 +6,8 @@ $empty_data = (object) [
 	"passCount" => 0,
 	"failCount" => 0,
 
+	"eyeContactCounts" => [0, 0, 0],
+
 	"maleTesterCount" => 0,
 	"femaleTesterCount" => 0,
 
@@ -48,6 +50,8 @@ $total_data = (object) [
 	"femaleChallengerCount" => 0,
 	"unspecifiedChallengerCount" => 0,
 
+	"eyeContactCounts" => [0, 0, 0],
+
 	"testCount" => 0,
 	"passCount" => 0,
 	"failCount" => 0,