|
@@ -6,18 +6,18 @@
|
|
|
|
|
|
|
|
class ChartGenerator {
|
|
class ChartGenerator {
|
|
|
|
|
|
|
|
- const COLOUR_GREEN = "#4CAF50";
|
|
|
|
|
- const COLOUR_RED = "#F44336";
|
|
|
|
|
- const COLOUR_YELLOW = "#FFEB3B";
|
|
|
|
|
- const COLOUR_LIGHT_GREY = "#CCCCCC";
|
|
|
|
|
- const COLOUR_LIGHT_RED = "#FFAB91";
|
|
|
|
|
- const COLOUR_ORANGE = "#FBC02D";
|
|
|
|
|
- const COLOUR_BLUE = "#2196F3";
|
|
|
|
|
- const COLOUR_MAGENTA = "#E91E63";
|
|
|
|
|
- const COLOUR_DARK_BLUE = "#3F51B5";
|
|
|
|
|
- const COLOUR_PURPLE = "#9C27B0";
|
|
|
|
|
- const COLOUR_GREY = "#9E9E9E";
|
|
|
|
|
- const COLOUR_CYAN = "#00BCD4";
|
|
|
|
|
|
|
+ public const COLOUR_GREEN = "#4CAF50";
|
|
|
|
|
+ public const COLOUR_RED = "#F44336";
|
|
|
|
|
+ public const COLOUR_YELLOW = "#FFEB3B";
|
|
|
|
|
+ public const COLOUR_LIGHT_GREY = "#CCCCCC";
|
|
|
|
|
+ public const COLOUR_LIGHT_RED = "#FFAB91";
|
|
|
|
|
+ public const COLOUR_ORANGE = "#FBC02D";
|
|
|
|
|
+ public const COLOUR_BLUE = "#2196F3";
|
|
|
|
|
+ public const COLOUR_MAGENTA = "#E91E63";
|
|
|
|
|
+ public const COLOUR_DARK_BLUE = "#3F51B5";
|
|
|
|
|
+ public const COLOUR_PURPLE = "#9C27B0";
|
|
|
|
|
+ public const COLOUR_GREY = "#9E9E9E";
|
|
|
|
|
+ public const COLOUR_CYAN = "#00BCD4";
|
|
|
|
|
|
|
|
/** @var object $totalData */
|
|
/** @var object $totalData */
|
|
|
private $totalData;
|
|
private $totalData;
|
|
@@ -50,30 +50,30 @@ class ChartGenerator {
|
|
|
$this->totalData = $total_data;
|
|
$this->totalData = $total_data;
|
|
|
$this->periodicData = $periodic_data;
|
|
$this->periodicData = $periodic_data;
|
|
|
|
|
|
|
|
- $this->xDataLabels = array_values(array_map(function($d) {
|
|
|
|
|
|
|
+ $this->xDataLabels = array_values(array_map(static function($d) {
|
|
|
return $d->label;
|
|
return $d->label;
|
|
|
}, $this->periodicData));
|
|
}, $this->periodicData));
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- public function setDateRangeLabel(string $label) {
|
|
|
|
|
|
|
+ public function setDateRangeLabel(string $label): void {
|
|
|
$this->dateRangeLabel = $label;
|
|
$this->dateRangeLabel = $label;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- public function setResolutionName(string $name) {
|
|
|
|
|
|
|
+ public function setResolutionName(string $name): void {
|
|
|
$this->resolutionName = $name;
|
|
$this->resolutionName = $name;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- public function setPeriodKeysAndLabels(array $keys, array $labels) {
|
|
|
|
|
|
|
+ public function setPeriodKeysAndLabels(array $keys, array $labels): void {
|
|
|
$this->periodKeys = $keys;
|
|
$this->periodKeys = $keys;
|
|
|
$this->periodLabels = $labels;
|
|
$this->periodLabels = $labels;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- public function setRegionData(array $data) {
|
|
|
|
|
|
|
+ public function setRegionData(array $data): void {
|
|
|
ksort($data, SORT_NATURAL);
|
|
ksort($data, SORT_NATURAL);
|
|
|
$this->regionData = $data;
|
|
$this->regionData = $data;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- public function setAreaManagerData(array $data) {
|
|
|
|
|
|
|
+ public function setAreaManagerData(array $data): void {
|
|
|
ksort($data, SORT_NATURAL);
|
|
ksort($data, SORT_NATURAL);
|
|
|
$this->areaManagerData = $data;
|
|
$this->areaManagerData = $data;
|
|
|
}
|
|
}
|
|
@@ -205,6 +205,34 @@ class ChartGenerator {
|
|
|
);
|
|
);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ public function getPeriodicMachinePowerChart(): Chart {
|
|
|
|
|
+ return $this->getPeriodicBooleanChart(
|
|
|
|
|
+ "Machines Powered",
|
|
|
|
|
+ $this->getMachinePowerRates()
|
|
|
|
|
+ );
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ public function getPeriodicMachineSeatChart(): Chart {
|
|
|
|
|
+ return $this->getPeriodicBooleanChart(
|
|
|
|
|
+ "Machine Seating",
|
|
|
|
|
+ $this->getMachineSeatRates()
|
|
|
|
|
+ );
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ public function getPeriodicMachineTableChart(): Chart {
|
|
|
|
|
+ return $this->getPeriodicBooleanChart(
|
|
|
|
|
+ "Machine Table/Shelf",
|
|
|
|
|
+ $this->getMachineTableRates()
|
|
|
|
|
+ );
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ public function getPeriodicMachineAccessibleChart(): Chart {
|
|
|
|
|
+ return $this->getPeriodicBooleanChart(
|
|
|
|
|
+ "Machines Accessible",
|
|
|
|
|
+ $this->getMachineAccessibleRates()
|
|
|
|
|
+ );
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
public function getPeriodicEyeContactPassRateChart(): Chart {
|
|
public function getPeriodicEyeContactPassRateChart(): Chart {
|
|
|
return $this->getPeriodicPassRateChart(
|
|
return $this->getPeriodicPassRateChart(
|
|
|
"Pass Rate by Eye Contact",
|
|
"Pass Rate by Eye Contact",
|
|
@@ -236,10 +264,7 @@ class ChartGenerator {
|
|
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- public function getPeriodicEyeContactChart(): Chart {
|
|
|
|
|
-
|
|
|
|
|
- $rates = $this->getEyeContactRates();
|
|
|
|
|
-
|
|
|
|
|
|
|
+ public function getPeriodicBooleanPassRateChart(array $rates, string $title): Chart {
|
|
|
$chart = new Chart;
|
|
$chart = new Chart;
|
|
|
$chart->addXAxis([
|
|
$chart->addXAxis([
|
|
|
"type" => "category",
|
|
"type" => "category",
|
|
@@ -251,7 +276,7 @@ class ChartGenerator {
|
|
|
"stacked" => true,
|
|
"stacked" => true,
|
|
|
]);
|
|
]);
|
|
|
$chart->setType("bar");
|
|
$chart->setType("bar");
|
|
|
- $chart->setTitle("Eye Contact by {$this->resolutionName}");
|
|
|
|
|
|
|
+ $chart->setTitle($title);
|
|
|
$chart->setLabels($this->xDataLabels);
|
|
$chart->setLabels($this->xDataLabels);
|
|
|
$chart->addDataset("Yes (%)", array_column($rates, 0), [
|
|
$chart->addDataset("Yes (%)", array_column($rates, 0), [
|
|
|
"background_colours" => self::COLOUR_GREEN
|
|
"background_colours" => self::COLOUR_GREEN
|
|
@@ -263,6 +288,13 @@ class ChartGenerator {
|
|
|
return $chart;
|
|
return $chart;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ public function getPeriodicEyeContactChart(): Chart {
|
|
|
|
|
+ return $this->getPeriodicBooleanChart(
|
|
|
|
|
+ "Eye Contact by {$this->resolutionName}",
|
|
|
|
|
+ $this->getEyeContactRates()
|
|
|
|
|
+ );
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
public function getPeriodicTotalsChart(): Chart {
|
|
public function getPeriodicTotalsChart(): Chart {
|
|
|
|
|
|
|
|
$test_counts = $this->getPeriodicTestCounts();
|
|
$test_counts = $this->getPeriodicTestCounts();
|
|
@@ -336,7 +368,7 @@ class ChartGenerator {
|
|
|
|
|
|
|
|
$period_data = $this->periodicData[$key];
|
|
$period_data = $this->periodicData[$key];
|
|
|
|
|
|
|
|
- if($period_data->testCount == 0) continue;
|
|
|
|
|
|
|
+ if($period_data->testCount === 0) continue;
|
|
|
|
|
|
|
|
$chart = new Chart;
|
|
$chart = new Chart;
|
|
|
$chart->setType("pie");
|
|
$chart->setType("pie");
|
|
@@ -369,10 +401,12 @@ class ChartGenerator {
|
|
|
$male_counts = $this->getPeriodicMaleTesterCount();
|
|
$male_counts = $this->getPeriodicMaleTesterCount();
|
|
|
$female_counts = $this->getPeriodicFemaleTesterCount();
|
|
$female_counts = $this->getPeriodicFemaleTesterCount();
|
|
|
|
|
|
|
|
|
|
+ $counts = array_merge($male_counts, $female_counts);
|
|
|
|
|
+
|
|
|
$chart = new Chart;
|
|
$chart = new Chart;
|
|
|
$chart->addYAxis([
|
|
$chart->addYAxis([
|
|
|
"id" => "y-axis-1",
|
|
"id" => "y-axis-1",
|
|
|
- "tick_config" => ["min" => 0, "max" => ceil(max(max($male_counts), max($female_counts)) / 10) * 10]
|
|
|
|
|
|
|
+ "tick_config" => ["min" => 0, "max" => ceil(max($counts) / 10) * 10]
|
|
|
]);
|
|
]);
|
|
|
|
|
|
|
|
$chart->setType("bar");
|
|
$chart->setType("bar");
|
|
@@ -401,7 +435,6 @@ class ChartGenerator {
|
|
|
$chart->addDataset("Tests", $test_counts, [
|
|
$chart->addDataset("Tests", $test_counts, [
|
|
|
"background_colours" => self::COLOUR_BLUE
|
|
"background_colours" => self::COLOUR_BLUE
|
|
|
]);
|
|
]);
|
|
|
- $charts[] = $chart;
|
|
|
|
|
return $chart;
|
|
return $chart;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -458,10 +491,12 @@ class ChartGenerator {
|
|
|
$fcf_counts = array_column($this->periodicData, "femaleChallengeFemaleCount");
|
|
$fcf_counts = array_column($this->periodicData, "femaleChallengeFemaleCount");
|
|
|
$ns_counts = array_column($this->periodicData, "unknownChallengeCount");
|
|
$ns_counts = array_column($this->periodicData, "unknownChallengeCount");
|
|
|
|
|
|
|
|
|
|
+ $counts = array_merge($mcm_counts, $mcf_counts, $fcm_counts, $fcf_counts);
|
|
|
|
|
+
|
|
|
$chart = new Chart;
|
|
$chart = new Chart;
|
|
|
$chart->addYAxis([
|
|
$chart->addYAxis([
|
|
|
"id" => "y-axis-1",
|
|
"id" => "y-axis-1",
|
|
|
- "tick_config" => ["min" => 0, "max" => ceil(max(max($mcm_counts), max($mcf_counts), max($fcm_counts), max($fcf_counts)) / 10) * 10]
|
|
|
|
|
|
|
+ "tick_config" => ["min" => 0, "max" => ceil(max($counts) / 10) * 10]
|
|
|
]);
|
|
]);
|
|
|
$chart->setType("bar");
|
|
$chart->setType("bar");
|
|
|
$chart->setTitle("Gender Comparison by {$this->resolutionName}");
|
|
$chart->setTitle("Gender Comparison by {$this->resolutionName}");
|
|
@@ -498,7 +533,7 @@ class ChartGenerator {
|
|
|
$test_counts = ${$prefix . "_counts"};
|
|
$test_counts = ${$prefix . "_counts"};
|
|
|
|
|
|
|
|
foreach($test_counts as $index => $test_count) {
|
|
foreach($test_counts as $index => $test_count) {
|
|
|
- if($test_count == 0) {
|
|
|
|
|
|
|
+ if($test_count === 0) {
|
|
|
$pass_rates[] = 0;
|
|
$pass_rates[] = 0;
|
|
|
continue;
|
|
continue;
|
|
|
}
|
|
}
|
|
@@ -536,7 +571,7 @@ class ChartGenerator {
|
|
|
$test_count = $period_data->{$prefix . "Count"};
|
|
$test_count = $period_data->{$prefix . "Count"};
|
|
|
$stage_data = $period_data->{$prefix . "Stages"};
|
|
$stage_data = $period_data->{$prefix . "Stages"};
|
|
|
|
|
|
|
|
- if($test_count == 0) continue;
|
|
|
|
|
|
|
+ if($test_count === 0) continue;
|
|
|
|
|
|
|
|
$chart = new Chart;
|
|
$chart = new Chart;
|
|
|
$chart->setType("pie");
|
|
$chart->setType("pie");
|
|
@@ -571,7 +606,7 @@ class ChartGenerator {
|
|
|
$pass_counts = [];
|
|
$pass_counts = [];
|
|
|
$fail_counts = [];
|
|
$fail_counts = [];
|
|
|
|
|
|
|
|
- foreach($this->regionData as $region => $r_data) {
|
|
|
|
|
|
|
+ foreach($this->regionData as $r_data) {
|
|
|
$total_region_test_count = array_sum(array_column($r_data, "testCount"));
|
|
$total_region_test_count = array_sum(array_column($r_data, "testCount"));
|
|
|
$total_region_pass_count = array_sum(array_column($r_data, "passCount"));
|
|
$total_region_pass_count = array_sum(array_column($r_data, "passCount"));
|
|
|
|
|
|
|
@@ -579,7 +614,7 @@ class ChartGenerator {
|
|
|
$pass_counts[] = $total_region_pass_count;
|
|
$pass_counts[] = $total_region_pass_count;
|
|
|
$fail_counts[] = $total_region_test_count - $total_region_pass_count;
|
|
$fail_counts[] = $total_region_test_count - $total_region_pass_count;
|
|
|
|
|
|
|
|
- $data_values[] = ($total_region_test_count == 0) ? 0 : round(($total_region_pass_count * 100) / $total_region_test_count);
|
|
|
|
|
|
|
+ $data_values[] = ($total_region_test_count === 0) ? 0 : round(($total_region_pass_count * 100) / $total_region_test_count);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
$chart = new Chart;
|
|
$chart = new Chart;
|
|
@@ -618,7 +653,7 @@ class ChartGenerator {
|
|
|
$data_values = [];
|
|
$data_values = [];
|
|
|
foreach($this->getRegionKeys() as $region) {
|
|
foreach($this->getRegionKeys() as $region) {
|
|
|
$r_data = $this->regionData[$region][$key];
|
|
$r_data = $this->regionData[$region][$key];
|
|
|
- $data_values[] = ($r_data->testCount == 0) ? 0 : round(($r_data->passCount * 100) / $r_data->testCount);
|
|
|
|
|
|
|
+ $data_values[] = ($r_data->testCount === 0) ? 0 : round(($r_data->passCount * 100) / $r_data->testCount);
|
|
|
}
|
|
}
|
|
|
$chart->addDataset($this->periodLabels[$index], $data_values, ["background_colours" => Chart::COLOURS[$index]]);
|
|
$chart->addDataset($this->periodLabels[$index], $data_values, ["background_colours" => Chart::COLOURS[$index]]);
|
|
|
}
|
|
}
|
|
@@ -639,7 +674,7 @@ class ChartGenerator {
|
|
|
$pass_counts = [];
|
|
$pass_counts = [];
|
|
|
$fail_counts = [];
|
|
$fail_counts = [];
|
|
|
|
|
|
|
|
- foreach($this->areaManagerData as $area_manager => $a_data) {
|
|
|
|
|
|
|
+ foreach($this->areaManagerData as $a_data) {
|
|
|
$total_area_manager_test_count = array_sum(array_column($a_data, "testCount"));
|
|
$total_area_manager_test_count = array_sum(array_column($a_data, "testCount"));
|
|
|
$total_area_manager_pass_count = array_sum(array_column($a_data, "passCount"));
|
|
$total_area_manager_pass_count = array_sum(array_column($a_data, "passCount"));
|
|
|
$total_area_manager_fail_count = array_sum(array_column($a_data, "failCount"));
|
|
$total_area_manager_fail_count = array_sum(array_column($a_data, "failCount"));
|
|
@@ -648,7 +683,7 @@ class ChartGenerator {
|
|
|
$pass_counts[] = $total_area_manager_pass_count;
|
|
$pass_counts[] = $total_area_manager_pass_count;
|
|
|
$fail_counts[] = $total_area_manager_fail_count;
|
|
$fail_counts[] = $total_area_manager_fail_count;
|
|
|
|
|
|
|
|
- $data_values[] = ($total_area_manager_test_count == 0) ? 0 : round(($total_area_manager_pass_count * 100) / $total_area_manager_test_count);
|
|
|
|
|
|
|
+ $data_values[] = ($total_area_manager_test_count === 0) ? 0 : round(($total_area_manager_pass_count * 100) / $total_area_manager_test_count);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
$chart = new Chart;
|
|
$chart = new Chart;
|
|
@@ -700,7 +735,7 @@ class ChartGenerator {
|
|
|
$data_values = [];
|
|
$data_values = [];
|
|
|
foreach($this->getAreaManagerKeys() as $area_manager) {
|
|
foreach($this->getAreaManagerKeys() as $area_manager) {
|
|
|
$a_data = $this->areaManagerData[$area_manager][$key];
|
|
$a_data = $this->areaManagerData[$area_manager][$key];
|
|
|
- $data_values[] = ($a_data->testCount == 0) ? 0 : round(($a_data->passCount * 100) / $a_data->testCount);
|
|
|
|
|
|
|
+ $data_values[] = ($a_data->testCount === 0) ? 0 : round(($a_data->passCount * 100) / $a_data->testCount);
|
|
|
}
|
|
}
|
|
|
$chart->addDataset($this->periodLabels[$index], $data_values, [
|
|
$chart->addDataset($this->periodLabels[$index], $data_values, [
|
|
|
"background_colours" => Chart::COLOURS[$index],
|
|
"background_colours" => Chart::COLOURS[$index],
|
|
@@ -754,7 +789,7 @@ class ChartGenerator {
|
|
|
|
|
|
|
|
$period_data = $this->periodicData[$key];
|
|
$period_data = $this->periodicData[$key];
|
|
|
|
|
|
|
|
- if($period_data->testCount == 0) continue;
|
|
|
|
|
|
|
+ if($period_data->testCount === 0) continue;
|
|
|
|
|
|
|
|
$chart = new Chart;
|
|
$chart = new Chart;
|
|
|
$chart->setType("pie");
|
|
$chart->setType("pie");
|
|
@@ -829,7 +864,7 @@ class ChartGenerator {
|
|
|
|
|
|
|
|
$period_data = $this->periodicData[$key];
|
|
$period_data = $this->periodicData[$key];
|
|
|
|
|
|
|
|
- if($period_data->testCount == 0) continue;
|
|
|
|
|
|
|
+ if($period_data->testCount === 0) continue;
|
|
|
|
|
|
|
|
$chart = new Chart;
|
|
$chart = new Chart;
|
|
|
$chart->setType("pie");
|
|
$chart->setType("pie");
|
|
@@ -866,59 +901,74 @@ class ChartGenerator {
|
|
|
|
|
|
|
|
// Private methods
|
|
// Private methods
|
|
|
|
|
|
|
|
- private function getPeriodicPassRates() {
|
|
|
|
|
- return array_values(array_map(function($d) {
|
|
|
|
|
- if($d->testCount == 0) return 0;
|
|
|
|
|
|
|
+ private function getPeriodicPassRates(): array {
|
|
|
|
|
+ return array_values(array_map(static function($d) {
|
|
|
|
|
+ if($d->testCount === 0) return 0;
|
|
|
return round(($d->passCount / $d->testCount) * 100);
|
|
return round(($d->passCount / $d->testCount) * 100);
|
|
|
}, $this->periodicData));
|
|
}, $this->periodicData));
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- private function getPeriodicFailRates() {
|
|
|
|
|
- return array_values(array_map(function($d) {
|
|
|
|
|
- if($d->testCount == 0) return 0;
|
|
|
|
|
|
|
+ private function getPeriodicFailRates(): array {
|
|
|
|
|
+ return array_values(array_map(static function($d) {
|
|
|
|
|
+ if($d->testCount === 0) return 0;
|
|
|
$pass_rate = round(($d->passCount / $d->testCount) * 100);
|
|
$pass_rate = round(($d->passCount / $d->testCount) * 100);
|
|
|
return 100 - $pass_rate;
|
|
return 100 - $pass_rate;
|
|
|
}, $this->periodicData));
|
|
}, $this->periodicData));
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- private function getPeriodicPassRateByDoorSensorAlert(int $index) {
|
|
|
|
|
- return array_values(array_map(function($data) use ($index) {
|
|
|
|
|
- $test_count = $data->doorSensorAlertPassCounts[$index] + $data->doorSensorAlertFailCounts[$index];
|
|
|
|
|
- if($test_count == 0) return null;
|
|
|
|
|
|
|
+ private function getPeriodicPassRate(string $prefix, int $index): array {
|
|
|
|
|
+ $pass_field = $prefix . "PassCounts";
|
|
|
|
|
+ $fail_field = $prefix . "FailCounts";
|
|
|
|
|
+
|
|
|
|
|
+ return array_values(array_map(static function($data) use ($pass_field, $fail_field, $index) {
|
|
|
|
|
+ $test_count = $data->$pass_field[$index] + $data->$fail_field[$index];
|
|
|
|
|
+ if($test_count === 0) {
|
|
|
|
|
+ return null;
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
- return round(($data->doorSensorAlertPassCounts[$index] / $test_count) * 100);
|
|
|
|
|
|
|
+ return round(($data->$pass_field[$index] / $test_count) * 100);
|
|
|
}, $this->periodicData));
|
|
}, $this->periodicData));
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- private function getPeriodicPassRateByEyeContact(int $index) {
|
|
|
|
|
- return array_values(array_map(function($data) use ($index) {
|
|
|
|
|
- $test_count = $data->eyeContactPassCounts[$index] + $data->eyeContactFailCounts[$index];
|
|
|
|
|
- if($test_count == 0) return null;
|
|
|
|
|
- return round(($data->eyeContactPassCounts[$index] / $test_count) * 100);
|
|
|
|
|
- }, $this->periodicData));
|
|
|
|
|
|
|
+ private function getPeriodicPassRateByDoorSensorAlert(int $index): array {
|
|
|
|
|
+ return $this->getPeriodicPassRate("doorSensor", $index);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- private function getPeriodicPassRateByLineOfSight(int $index) {
|
|
|
|
|
- return array_values(array_map(function($data) use ($index) {
|
|
|
|
|
- $test_count = $data->lineOfSightPassCounts[$index] + $data->lineOfSightFailCounts[$index];
|
|
|
|
|
- if($test_count == 0) return null;
|
|
|
|
|
- return round(($data->lineOfSightPassCounts[$index] / $test_count) * 100);
|
|
|
|
|
- }, $this->periodicData));
|
|
|
|
|
|
|
+ private function getPeriodicPassRateByEyeContact(int $index): array {
|
|
|
|
|
+ return $this->getPeriodicPassRate("eyeContact", $index);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- private function getPeriodicPassRateByBarPurchase(int $index) {
|
|
|
|
|
- return array_values(array_map(function($data) use ($index) {
|
|
|
|
|
- $test_count = $data->barPurchasePassCounts[$index] + $data->barPurchaseFailCounts[$index];
|
|
|
|
|
- if($test_count == 0) return null;
|
|
|
|
|
- return round(($data->barPurchasePassCounts[$index] / $test_count) * 100);
|
|
|
|
|
- }, $this->periodicData));
|
|
|
|
|
|
|
+ private function getPeriodicPassRateByLineOfSight(int $index): array {
|
|
|
|
|
+ return $this->getPeriodicPassRate("lineOfSight", $index);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- private function getEyeContactRates(): array {
|
|
|
|
|
- return array_values(array_map(function($period) {
|
|
|
|
|
- if($period->testCount == 0) return [0, 0, 0];
|
|
|
|
|
|
|
+ private function getPeriodicPassRateByBarPurchase(int $index): array {
|
|
|
|
|
+ return $this->getPeriodicPassRate("barPurchase", $index);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ private function getMachinePowerRates(): array {
|
|
|
|
|
+ return $this->getBooleanRates("machinePowerCounts");
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ private function getMachineSeatRates(): array {
|
|
|
|
|
+ return $this->getBooleanRates("machineSeatCounts");
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ private function getMachineTableRates(): array {
|
|
|
|
|
+ return $this->getBooleanRates("machineTableCounts");
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ private function getMachineAccessibleRates(): array {
|
|
|
|
|
+ return $this->getBooleanRates("machineAccessibleCounts");
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
- $yes = round(($period->eyeContactCounts[0] / $period->testCount) * 100);
|
|
|
|
|
|
|
+ private function getBooleanRates(string $field): array {
|
|
|
|
|
+ return array_values(array_map(static function($period) use ($field) {
|
|
|
|
|
+ if($period->testCount === 0) {
|
|
|
|
|
+ return [0, 0, 0];
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ $yes = round(($period->$field[0] / $period->testCount) * 100);
|
|
|
$no = 100 - $yes;
|
|
$no = 100 - $yes;
|
|
|
$na = 0;
|
|
$na = 0;
|
|
|
|
|
|
|
@@ -926,6 +976,10 @@ class ChartGenerator {
|
|
|
}, $this->periodicData));
|
|
}, $this->periodicData));
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ private function getEyeContactRates(): array {
|
|
|
|
|
+ return $this->getBooleanRates("eyeContactCounts");
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
private function getPeriodicTestCounts(): array {
|
|
private function getPeriodicTestCounts(): array {
|
|
|
return array_column($this->periodicData, "testCount");
|
|
return array_column($this->periodicData, "testCount");
|
|
|
}
|
|
}
|
|
@@ -939,13 +993,13 @@ class ChartGenerator {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
private function getPeriodicMaleTesterCount(): array {
|
|
private function getPeriodicMaleTesterCount(): array {
|
|
|
- return array_values(array_map(function($d) {
|
|
|
|
|
|
|
+ return array_values(array_map(static function($d) {
|
|
|
return $d->maleTesterCount;
|
|
return $d->maleTesterCount;
|
|
|
}, $this->periodicData));
|
|
}, $this->periodicData));
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
private function getPeriodicFemaleTesterCount(): array {
|
|
private function getPeriodicFemaleTesterCount(): array {
|
|
|
- return array_values(array_map(function($d) {
|
|
|
|
|
|
|
+ return array_values(array_map(static function($d) {
|
|
|
return $d->femaleTesterCount;
|
|
return $d->femaleTesterCount;
|
|
|
}, $this->periodicData));
|
|
}, $this->periodicData));
|
|
|
}
|
|
}
|
|
@@ -956,7 +1010,7 @@ class ChartGenerator {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
private function getRegionXDataLabels(): array {
|
|
private function getRegionXDataLabels(): array {
|
|
|
- return array_map(function($key) {
|
|
|
|
|
|
|
+ return array_map(static function($key) {
|
|
|
return "Region $key";
|
|
return "Region $key";
|
|
|
}, $this->getRegionKeys());
|
|
}, $this->getRegionKeys());
|
|
|
}
|
|
}
|
|
@@ -979,16 +1033,17 @@ class ChartGenerator {
|
|
|
$chart->setType("bar");
|
|
$chart->setType("bar");
|
|
|
$chart->setTitle("{$title} by {$this->resolutionName}");
|
|
$chart->setTitle("{$title} by {$this->resolutionName}");
|
|
|
$chart->setLabels($this->xDataLabels);
|
|
$chart->setLabels($this->xDataLabels);
|
|
|
- $chart->addDataset("No", $no_counts, [
|
|
|
|
|
- "background_colours" => self::COLOUR_RED
|
|
|
|
|
- ]);
|
|
|
|
|
$chart->addDataset("Yes", $yes_counts, [
|
|
$chart->addDataset("Yes", $yes_counts, [
|
|
|
"background_colours" => self::COLOUR_GREEN
|
|
"background_colours" => self::COLOUR_GREEN
|
|
|
]);
|
|
]);
|
|
|
|
|
+ $chart->addDataset("No", $no_counts, [
|
|
|
|
|
+ "background_colours" => self::COLOUR_RED
|
|
|
|
|
+ ]);
|
|
|
|
|
+ $chart->setDatalabelSuffixes("%", "%");
|
|
|
return $chart;
|
|
return $chart;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- private function getPeriodicPassRateChart(string $title, array $yes_rates, array $no_rates, ?array $null_rates = null) {
|
|
|
|
|
|
|
+ private function getPeriodicPassRateChart(string $title, array $yes_rates, array $no_rates, ?array $null_rates = null): Chart {
|
|
|
|
|
|
|
|
$chart = new Chart;
|
|
$chart = new Chart;
|
|
|
$chart->addYAxis([
|
|
$chart->addYAxis([
|