|
|
@@ -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");
|