|
|
@@ -0,0 +1,1024 @@
|
|
|
+<?php
|
|
|
+
|
|
|
+/**
|
|
|
+ * 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";
|
|
|
+
|
|
|
+ /** @var object $totalData */
|
|
|
+ private $totalData;
|
|
|
+
|
|
|
+ /** @var array $periodicData */
|
|
|
+ private $periodicData;
|
|
|
+
|
|
|
+ /** @var string $dateRangeLabel */
|
|
|
+ private $dateRangeLabel;
|
|
|
+
|
|
|
+ /** @var string $resolutionName */
|
|
|
+ private $resolutionName;
|
|
|
+
|
|
|
+ /** @var string[] $xDataLabels */
|
|
|
+ private $xDataLabels;
|
|
|
+
|
|
|
+ /** @var string[] $periodKeys */
|
|
|
+ private $periodKeys;
|
|
|
+
|
|
|
+ /** @var string[] $periodLabels */
|
|
|
+ private $periodLabels;
|
|
|
+
|
|
|
+ /** @var array $regionData */
|
|
|
+ private $regionData;
|
|
|
+
|
|
|
+ /** @var array $areaManagerData */
|
|
|
+ private $areaManagerData;
|
|
|
+
|
|
|
+ public function __construct(object $total_data, array $periodic_data) {
|
|
|
+ $this->totalData = $total_data;
|
|
|
+ $this->periodicData = $periodic_data;
|
|
|
+
|
|
|
+ $this->xDataLabels = array_values(array_map(function($d) {
|
|
|
+ return $d->label;
|
|
|
+ }, $this->periodicData));
|
|
|
+ }
|
|
|
+
|
|
|
+ public function setDateRangeLabel(string $label) {
|
|
|
+ $this->dateRangeLabel = $label;
|
|
|
+ }
|
|
|
+
|
|
|
+ public function setResolutionName(string $name) {
|
|
|
+ $this->resolutionName = $name;
|
|
|
+ }
|
|
|
+
|
|
|
+ public function setPeriodKeysAndLabels(array $keys, array $labels) {
|
|
|
+ $this->periodKeys = $keys;
|
|
|
+ $this->periodLabels = $labels;
|
|
|
+ }
|
|
|
+
|
|
|
+ public function setRegionData(array $data) {
|
|
|
+ ksort($data, SORT_NATURAL);
|
|
|
+ $this->regionData = $data;
|
|
|
+ }
|
|
|
+
|
|
|
+ public function setAreaManagerData(array $data) {
|
|
|
+ ksort($data, SORT_NATURAL);
|
|
|
+ $this->areaManagerData = $data;
|
|
|
+ }
|
|
|
+
|
|
|
+ // Charts
|
|
|
+ public function getTestsByStageChart(): Chart {
|
|
|
+ $chart = new Chart;
|
|
|
+ $chart->setType("doughnut");
|
|
|
+ $chart->setTitle("Tests by Stage {$this->dateRangeLabel}");
|
|
|
+ $chart->setLabels(["1 - On Entry", "2 - While Browsing", "3 - During Play", "4 - On Exit", "5 - No Challenge"]);
|
|
|
+ $chart->addDataset("Tests", [
|
|
|
+ $this->totalData->stage1Count,
|
|
|
+ $this->totalData->stage2Count,
|
|
|
+ $this->totalData->stage3Count,
|
|
|
+ $this->totalData->stage4Count,
|
|
|
+ $this->totalData->stage5Count,
|
|
|
+ ], [
|
|
|
+ "background_colours" => [
|
|
|
+ self::COLOUR_GREEN,
|
|
|
+ self::COLOUR_YELLOW,
|
|
|
+ self::COLOUR_ORANGE,
|
|
|
+ self::COLOUR_LIGHT_RED,
|
|
|
+ self::COLOUR_RED,
|
|
|
+ ],
|
|
|
+ "datalabels" => Chart::DATALABELS_BOX,
|
|
|
+ ]);
|
|
|
+ $chart->setPrintSuffixes("");
|
|
|
+ $chart->print = true;
|
|
|
+ $chart->printPercentages = true;
|
|
|
+ $chart->printTotalColumn = true;
|
|
|
+ $chart->setPrintLabels(["Stage 1", "Stage 2", "Stage 3", "Stage 4", "Stage 5"]);
|
|
|
+ return $chart;
|
|
|
+ }
|
|
|
+
|
|
|
+ public function getChallengerGenderChart(): Chart {
|
|
|
+ $chart = new Chart;
|
|
|
+ $chart->setType("pie");
|
|
|
+ $chart->setTitle("Staff Gender {$this->dateRangeLabel}");
|
|
|
+ $chart->setLabels(["Male", "Female", "Unspecified"]);
|
|
|
+ $chart->addDataset("Counts", [
|
|
|
+ $this->totalData->maleChallengerCount,
|
|
|
+ $this->totalData->femaleChallengerCount,
|
|
|
+ $this->totalData->unspecifiedChallengerCount,
|
|
|
+ ], [
|
|
|
+ "background_colours" => [
|
|
|
+ self::COLOUR_BLUE,
|
|
|
+ self::COLOUR_MAGENTA,
|
|
|
+ self::COLOUR_GREY,
|
|
|
+ ],
|
|
|
+ "datalabels" => Chart::DATALABELS_BOX,
|
|
|
+ ]);
|
|
|
+ return $chart;
|
|
|
+ }
|
|
|
+
|
|
|
+ public function getTesterGenderChart(): Chart {
|
|
|
+ $chart = new Chart;
|
|
|
+ $chart->setType("pie");
|
|
|
+ $chart->setTitle("Tester Gender {$this->dateRangeLabel}");
|
|
|
+ $chart->setLabels(["Male", "Female"]);
|
|
|
+ $chart->addDataset("Counts", [
|
|
|
+ $this->totalData->maleTesterCount,
|
|
|
+ $this->totalData->femaleTesterCount,
|
|
|
+ ], [
|
|
|
+ "background_colours" => [
|
|
|
+ self::COLOUR_BLUE,
|
|
|
+ self::COLOUR_MAGENTA,
|
|
|
+ ],
|
|
|
+ "datalabels" => Chart::DATALABELS_BOX,
|
|
|
+ ]);
|
|
|
+ return $chart;
|
|
|
+ }
|
|
|
+
|
|
|
+ public function getPassFailCountChart(): Chart {
|
|
|
+ $chart = new Chart;
|
|
|
+ $chart->setType("pie");
|
|
|
+ $chart->setTitle("Pass / Fail {$this->dateRangeLabel}");
|
|
|
+ $chart->setLabels(["Pass", "Fail"]);
|
|
|
+ $chart->addDataset("Counts", [
|
|
|
+ $this->totalData->passCount,
|
|
|
+ $this->totalData->failCount,
|
|
|
+ ], [
|
|
|
+ "background_colours" => [
|
|
|
+ self::COLOUR_GREEN,
|
|
|
+ self::COLOUR_RED,
|
|
|
+ ],
|
|
|
+ "datalabels" => Chart::DATALABELS_BOX,
|
|
|
+ ]);
|
|
|
+ return $chart;
|
|
|
+ }
|
|
|
+
|
|
|
+ public function getPeriodicPassFailRateChart(): Chart {
|
|
|
+
|
|
|
+ $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("Pass / Fail by {$this->resolutionName}");
|
|
|
+ $chart->setLabels($this->xDataLabels);
|
|
|
+ $chart->addDataset("Pass Rate (%)", $this->getPeriodicPassRates(), [
|
|
|
+ "background_colours" => self::COLOUR_GREEN
|
|
|
+ ]);
|
|
|
+ $chart->addDataset("Fail Rate (%)", $this->getPeriodicFailRates(), [
|
|
|
+ "background_colours" => self::COLOUR_RED
|
|
|
+ ]);
|
|
|
+ $chart->setDatalabelSuffixes("%", "%");
|
|
|
+ return $chart;
|
|
|
+ }
|
|
|
+
|
|
|
+ public function getPeriodicDoorSensorAlertPassRateChart(): Chart {
|
|
|
+ return $this->getPeriodicPassRateChart(
|
|
|
+ "Pass Rate by Door Sensor Alert",
|
|
|
+ $this->getPeriodicPassRateByDoorSensorAlert(1),
|
|
|
+ $this->getPeriodicPassRateByDoorSensorAlert(0),
|
|
|
+ $this->getPeriodicPassRateByDoorSensorAlert(2)
|
|
|
+ );
|
|
|
+ }
|
|
|
+
|
|
|
+ public function getPeriodicEyeContactPassRateChart(): Chart {
|
|
|
+ return $this->getPeriodicPassRateChart(
|
|
|
+ "Pass Rate by Eye Contact",
|
|
|
+ $this->getPeriodicPassRateByEyeContact(1),
|
|
|
+ $this->getPeriodicPassRateByEyeContact(0),
|
|
|
+ $this->getPeriodicPassRateByEyeContact(2)
|
|
|
+ );
|
|
|
+ }
|
|
|
+
|
|
|
+ public function getPeriodicLineOfSightPassRateChart(): Chart {
|
|
|
+
|
|
|
+ return $this->getPeriodicPassRateChart(
|
|
|
+ "Pass Rate by Line of Sight",
|
|
|
+ $this->getPeriodicPassRateByLineOfSight(1),
|
|
|
+ $this->getPeriodicPassRateByLineOfSight(0),
|
|
|
+ $this->getPeriodicPassRateByLineOfSight(2)
|
|
|
+ );
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ public function getPeriodicBarPurchasePassRateChart(): Chart {
|
|
|
+
|
|
|
+ return $this->getPeriodicPassRateChart(
|
|
|
+ "Pass Rate by Bar Purchase",
|
|
|
+ $this->getPeriodicPassRateByBarPurchase(1),
|
|
|
+ $this->getPeriodicPassRateByBarPurchase(0),
|
|
|
+ $this->getPeriodicPassRateByBarPurchase(2)
|
|
|
+ );
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ public function getPeriodicEyeContactChart(): Chart {
|
|
|
+
|
|
|
+ $rates = $this->getEyeContactRates();
|
|
|
+
|
|
|
+ $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 {$this->resolutionName}");
|
|
|
+ $chart->setLabels($this->xDataLabels);
|
|
|
+ $chart->addDataset("Yes (%)", array_column($rates, 0), [
|
|
|
+ "background_colours" => self::COLOUR_GREEN
|
|
|
+ ]);
|
|
|
+ $chart->addDataset("No (%)", array_column($rates, 1), [
|
|
|
+ "background_colours" => self::COLOUR_RED
|
|
|
+ ]);
|
|
|
+ $chart->setDatalabelSuffixes("%", "%");
|
|
|
+ return $chart;
|
|
|
+ }
|
|
|
+
|
|
|
+ public function getPeriodicTotalsChart(): Chart {
|
|
|
+
|
|
|
+ $test_counts = $this->getPeriodicTestCounts();
|
|
|
+ $pass_rates = $this->getPeriodicPassRates();
|
|
|
+ $pass_counts = $this->getPeriodicPassCounts();
|
|
|
+ $fail_counts = $this->getPeriodicFailCounts();
|
|
|
+
|
|
|
+ $chart = new Chart;
|
|
|
+ $chart->setType("bar");
|
|
|
+ $chart->setTitle("Totals by {$this->resolutionName}");
|
|
|
+ $chart->setLabels($this->xDataLabels);
|
|
|
+ $chart->addYAxis([
|
|
|
+ "id" => "y-axis-1",
|
|
|
+ "tick_config" => ["min" => 0, "max" => ceil(max($test_counts) / 10) * 10]
|
|
|
+ ]);
|
|
|
+ $chart->addYAxis([
|
|
|
+ "position" => "right",
|
|
|
+ "id" => "y-axis-2",
|
|
|
+ "grid_lines" => false,
|
|
|
+ "tick_config" => ["min" => 0, "max" => 100]
|
|
|
+ ]);
|
|
|
+
|
|
|
+ $chart->addDataset("Pass Rate (%)", $pass_rates, [
|
|
|
+ "border_colours" => self::COLOUR_YELLOW,
|
|
|
+ "background_colours" => "transparent",
|
|
|
+ "type" => "line",
|
|
|
+ "y_axis_id" => "y-axis-2",
|
|
|
+ "datalabels" => [
|
|
|
+ "display" => false
|
|
|
+ ],
|
|
|
+ "line_tension" => 0,
|
|
|
+ ]);
|
|
|
+ $chart->addDataset("Test Count", $test_counts, [
|
|
|
+ "background_colours" => self::COLOUR_BLUE,
|
|
|
+ "type" => "bar",
|
|
|
+ "y_axis_id" => "y-axis-1",
|
|
|
+ "datalabels" => [
|
|
|
+ "display" => false
|
|
|
+ ],
|
|
|
+ ]);
|
|
|
+ $chart->addDataset("Pass", $pass_counts, [
|
|
|
+ "background_colours" => self::COLOUR_GREEN,
|
|
|
+ "type" => "bar",
|
|
|
+ "y_axis_id" => "y-axis-1",
|
|
|
+ "datalabels" => [
|
|
|
+ "display" => false
|
|
|
+ ],
|
|
|
+ ]);
|
|
|
+ $chart->addDataset("Fail", $fail_counts, [
|
|
|
+ "background_colours" => self::COLOUR_RED,
|
|
|
+ "type" => "bar",
|
|
|
+ "y_axis_id" => "y-axis-1",
|
|
|
+ "datalabels" => [
|
|
|
+ "display" => false
|
|
|
+ ],
|
|
|
+ ]);
|
|
|
+ $chart->setDatalabelSuffixes("%", "", "", "");
|
|
|
+ $chart->print = true;
|
|
|
+ return $chart;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * @return Chart[]
|
|
|
+ * @throws Exception
|
|
|
+ */
|
|
|
+ public function getPointOfChallengeCharts(): array {
|
|
|
+ $charts = [];
|
|
|
+
|
|
|
+ foreach($this->periodKeys as $index => $key) {
|
|
|
+ $key_label = $this->periodLabels[$index];
|
|
|
+
|
|
|
+ $period_data = $this->periodicData[$key];
|
|
|
+
|
|
|
+ if($period_data->testCount == 0) continue;
|
|
|
+
|
|
|
+ $chart = new Chart;
|
|
|
+ $chart->setType("pie");
|
|
|
+ $chart->setTitle("$key_label Point of Challenge");
|
|
|
+ $chart->setLabels(["On Entry", "While Browsing", "During Play", "On Exit", "No Challenge"]);
|
|
|
+ $chart->addDataset("Counts", [
|
|
|
+ $period_data->stage1Count,
|
|
|
+ $period_data->stage2Count,
|
|
|
+ $period_data->stage3Count,
|
|
|
+ $period_data->stage4Count,
|
|
|
+ $period_data->stage5Count,
|
|
|
+ ], [
|
|
|
+ "background_colours" => [
|
|
|
+ self::COLOUR_GREEN,
|
|
|
+ self::COLOUR_YELLOW,
|
|
|
+ self::COLOUR_ORANGE,
|
|
|
+ self::COLOUR_LIGHT_RED,
|
|
|
+ self::COLOUR_RED,
|
|
|
+ ],
|
|
|
+ "datalabels" => Chart::DATALABELS_BOX,
|
|
|
+ ]);
|
|
|
+ $charts[] = $chart;
|
|
|
+ }
|
|
|
+
|
|
|
+ return $charts;
|
|
|
+ }
|
|
|
+
|
|
|
+ public function getPeriodicTesterGenderChart(): Chart {
|
|
|
+
|
|
|
+ $male_counts = $this->getPeriodicMaleTesterCount();
|
|
|
+ $female_counts = $this->getPeriodicFemaleTesterCount();
|
|
|
+
|
|
|
+ $chart = new Chart;
|
|
|
+ $chart->addYAxis([
|
|
|
+ "id" => "y-axis-1",
|
|
|
+ "tick_config" => ["min" => 0, "max" => ceil(max(max($male_counts), max($female_counts)) / 10) * 10]
|
|
|
+ ]);
|
|
|
+
|
|
|
+ $chart->setType("bar");
|
|
|
+ $chart->setTitle("Tester Gender by {$this->resolutionName}");
|
|
|
+ $chart->setLabels($this->xDataLabels);
|
|
|
+ $chart->addDataset("Male", $male_counts, [
|
|
|
+ "background_colours" => self::COLOUR_BLUE
|
|
|
+ ]);
|
|
|
+ $chart->addDataset("Female", $female_counts, [
|
|
|
+ "background_colours" => self::COLOUR_MAGENTA
|
|
|
+ ]);
|
|
|
+ return $chart;
|
|
|
+ }
|
|
|
+
|
|
|
+ public function getPeriodicTestCountChart(): Chart {
|
|
|
+ $test_counts = $this->getPeriodicTestCounts();
|
|
|
+
|
|
|
+ $chart = new Chart;
|
|
|
+ $chart->addYAxis([
|
|
|
+ "id" => "y-axis-1",
|
|
|
+ "tick_config" => ["min" => 0, "max" => ceil(max($test_counts) / 10) * 10]
|
|
|
+ ]);
|
|
|
+ $chart->setType("bar");
|
|
|
+ $chart->setTitle("Tests by {$this->resolutionName}");
|
|
|
+ $chart->setLabels($this->xDataLabels);
|
|
|
+ $chart->addDataset("Tests", $test_counts, [
|
|
|
+ "background_colours" => self::COLOUR_BLUE
|
|
|
+ ]);
|
|
|
+ $charts[] = $chart;
|
|
|
+ return $chart;
|
|
|
+ }
|
|
|
+
|
|
|
+ public function getGenderComparisonCharts(): array {
|
|
|
+
|
|
|
+ $charts = [];
|
|
|
+
|
|
|
+ $gender_keys = [
|
|
|
+ "maleChallengeMale" => [
|
|
|
+ "title" => "Male Challenge Male",
|
|
|
+ "label" => "M Cha. M",
|
|
|
+ ],
|
|
|
+ "maleChallengeFemale" => [
|
|
|
+ "title" => "Male Challenge Female",
|
|
|
+ "label" => "M Cha. F",
|
|
|
+ ],
|
|
|
+ "femaleChallengeMale" => [
|
|
|
+ "title" => "Female Challenge Male",
|
|
|
+ "label" => "F Cha. M",
|
|
|
+ ],
|
|
|
+ "femaleChallengeFemale" => [
|
|
|
+ "title" => "Female Challenge Female",
|
|
|
+ "label" => "F Cha. F",
|
|
|
+ ],
|
|
|
+ "unknownChallenge" => [
|
|
|
+ "title" => "Gender Not Specified",
|
|
|
+ "label" => "Gender Not Specified",
|
|
|
+ ],
|
|
|
+ ];
|
|
|
+
|
|
|
+ $gender_test_counts = [];
|
|
|
+ foreach($gender_keys as $gk => $gv) {
|
|
|
+ $gender_test_counts[] = array_sum(array_column($this->periodicData, "{$gk}Count"));
|
|
|
+ }
|
|
|
+
|
|
|
+ // Gender Comparison by Date Range
|
|
|
+ $chart = new Chart;
|
|
|
+ $chart->addYAxis([
|
|
|
+ "id" => "y-axis-1",
|
|
|
+ "tick_config" => ["min" => 0, "max" => ceil(max($gender_test_counts) / 10) * 10]
|
|
|
+ ]);
|
|
|
+ $chart->setType("bar");
|
|
|
+ $chart->setTitle("Gender Comparison {$this->dateRangeLabel}");
|
|
|
+ $chart->setLabels(array_column($gender_keys, "label"));
|
|
|
+ $chart->addDataset("Tests", $gender_test_counts, [
|
|
|
+ "background_colours" => self::COLOUR_BLUE
|
|
|
+ ]);
|
|
|
+ $charts[] = $chart;
|
|
|
+
|
|
|
+ // Gender Comparison by Resolution
|
|
|
+ $mcm_counts = array_column($this->periodicData, "maleChallengeMaleCount");
|
|
|
+ $mcf_counts = array_column($this->periodicData, "maleChallengeFemaleCount");
|
|
|
+ $fcm_counts = array_column($this->periodicData, "femaleChallengeMaleCount");
|
|
|
+ $fcf_counts = array_column($this->periodicData, "femaleChallengeFemaleCount");
|
|
|
+ $ns_counts = array_column($this->periodicData, "unknownChallengeCount");
|
|
|
+
|
|
|
+ $chart = new Chart;
|
|
|
+ $chart->addYAxis([
|
|
|
+ "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]
|
|
|
+ ]);
|
|
|
+ $chart->setType("bar");
|
|
|
+ $chart->setTitle("Gender Comparison by {$this->resolutionName}");
|
|
|
+ $chart->setLabels($this->xDataLabels);
|
|
|
+ $chart->addDataset("M Cha. M", $mcm_counts, ["background_colours" => self::COLOUR_BLUE]);
|
|
|
+ $chart->addDataset("M Cha. F", $mcf_counts, ["background_colours" => self::COLOUR_DARK_BLUE]);
|
|
|
+ $chart->addDataset("F Cha. M", $fcm_counts, ["background_colours" => self::COLOUR_PURPLE]);
|
|
|
+ $chart->addDataset("F Cha. F", $fcf_counts, ["background_colours" => self::COLOUR_MAGENTA]);
|
|
|
+ $chart->addDataset("Not Specified", $ns_counts, ["background_colours" => self::COLOUR_GREY]);
|
|
|
+ $chart->print = true;
|
|
|
+ $charts[] = $chart;
|
|
|
+
|
|
|
+ // Gender Comparison Pass Rate by Resolution
|
|
|
+ /** @noinspection PhpUnusedLocalVariableInspection */
|
|
|
+ {
|
|
|
+ $mcm_pass_counts = array_column($this->periodicData, "maleChallengeMalePassCount");
|
|
|
+ $mcf_pass_counts = array_column($this->periodicData, "maleChallengeFemalePassCount");
|
|
|
+ $fcm_pass_counts = array_column($this->periodicData, "femaleChallengeMalePassCount");
|
|
|
+ $fcf_pass_counts = array_column($this->periodicData, "femaleChallengeFemalePassCount");
|
|
|
+ $ns_pass_counts = array_column($this->periodicData, "unknownChallengePassCount");
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * @var float $mcm_pass_rates
|
|
|
+ * @var float $mcf_pass_rates
|
|
|
+ * @var float $fcm_pass_rates
|
|
|
+ * @var float $fcf_pass_rates
|
|
|
+ * @var float $ns_pass_rates
|
|
|
+ */
|
|
|
+
|
|
|
+ foreach(["mcm", "mcf", "fcm", "fcf", "ns"] as $prefix) {
|
|
|
+ $pass_rates = [];
|
|
|
+ $pass_counts = ${$prefix . "_pass_counts"};
|
|
|
+ $test_counts = ${$prefix . "_counts"};
|
|
|
+
|
|
|
+ foreach($test_counts as $index => $test_count) {
|
|
|
+ if($test_count == 0) {
|
|
|
+ $pass_rates[] = 0;
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ $pass_rates[] = number_format(($pass_counts[$index] * 100) / $test_count, 2);
|
|
|
+ }
|
|
|
+
|
|
|
+ ${$prefix . "_pass_rates"} = $pass_rates;
|
|
|
+ }
|
|
|
+
|
|
|
+ $chart = new Chart;
|
|
|
+ $chart->addYAxis([
|
|
|
+ "id" => "y-axis-1",
|
|
|
+ "tick_config" => ["min" => 0, "max" => 100],
|
|
|
+ ]);
|
|
|
+ $chart->setType("bar");
|
|
|
+ $chart->setTitle("Gender Comparison Pass Rate by {$this->resolutionName}");
|
|
|
+ $chart->setLabels($this->xDataLabels);
|
|
|
+ $chart->addDataset("M Cha. M", $mcm_pass_rates, ["background_colours" => self::COLOUR_BLUE, "datalabels" => ["display" => false], "line_tension" => 0]);
|
|
|
+ $chart->addDataset("M Cha. F", $mcf_pass_rates, ["background_colours" => self::COLOUR_DARK_BLUE, "datalabels" => ["display" => false], "line_tension" => 0]);
|
|
|
+ $chart->addDataset("F Cha. M", $fcm_pass_rates, ["background_colours" => self::COLOUR_PURPLE, "datalabels" => ["display" => false], "line_tension" => 0]);
|
|
|
+ $chart->addDataset("F Cha. F", $fcf_pass_rates, ["background_colours" => self::COLOUR_MAGENTA, "datalabels" => ["display" => false], "line_tension" => 0]);
|
|
|
+ $chart->addDataset("Not Specified", $ns_pass_rates, ["background_colours" => self::COLOUR_GREY, "datalabels" => ["display" => false], "line_tension" => 0]);
|
|
|
+ $chart->print = true;
|
|
|
+ $chart->setDatalabelSuffixes("%", "%", "%", "%", "%");
|
|
|
+ $charts[] = $chart;
|
|
|
+
|
|
|
+ // Gender Comparison Point of Challenge
|
|
|
+ foreach($this->periodKeys as $index => $key) {
|
|
|
+ $key_label = $this->periodLabels[$index];
|
|
|
+ $period_data = $this->periodicData[$key];
|
|
|
+
|
|
|
+ foreach($gender_keys as $prefix => $gv) {
|
|
|
+
|
|
|
+ $title = $gv["label"];
|
|
|
+ $test_count = $period_data->{$prefix . "Count"};
|
|
|
+ $stage_data = $period_data->{$prefix . "Stages"};
|
|
|
+
|
|
|
+ if($test_count == 0) continue;
|
|
|
+
|
|
|
+ $chart = new Chart;
|
|
|
+ $chart->setType("pie");
|
|
|
+ $chart->setTitle("$key_label $title Point of Challenge");
|
|
|
+ $chart->setLabels(["On Entry", "While Browsing", "During Play", "On Exit", "No Challenge"]);
|
|
|
+ $chart->addDataset("Counts", $stage_data, [
|
|
|
+ "background_colours" => [
|
|
|
+ self::COLOUR_GREEN,
|
|
|
+ self::COLOUR_YELLOW,
|
|
|
+ self::COLOUR_ORANGE,
|
|
|
+ self::COLOUR_LIGHT_RED,
|
|
|
+ self::COLOUR_RED,
|
|
|
+ ],
|
|
|
+ "datalabels" => Chart::DATALABELS_BOX,
|
|
|
+ ]);
|
|
|
+ $charts[] = $chart;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ return $charts;
|
|
|
+ }
|
|
|
+
|
|
|
+ public function hasRegionData(): bool {
|
|
|
+ return $this->regionData !== null;
|
|
|
+ }
|
|
|
+
|
|
|
+ public function getRegionPassRateChart(): Chart {
|
|
|
+
|
|
|
+ $data_values = [];
|
|
|
+
|
|
|
+ $test_counts = [];
|
|
|
+ $pass_counts = [];
|
|
|
+ $fail_counts = [];
|
|
|
+
|
|
|
+ foreach($this->regionData as $region => $r_data) {
|
|
|
+ $total_region_test_count = array_sum(array_column($r_data, "testCount"));
|
|
|
+ $total_region_pass_count = array_sum(array_column($r_data, "passCount"));
|
|
|
+
|
|
|
+ $test_counts[] = $total_region_test_count;
|
|
|
+ $pass_counts[] = $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);
|
|
|
+ }
|
|
|
+
|
|
|
+ $chart = new Chart;
|
|
|
+ $chart->addYAxis([
|
|
|
+ "id" => "y-axis-1",
|
|
|
+ "tick_config" => ["min" => 0, "max" => 100]
|
|
|
+ ]);
|
|
|
+ $chart->setType("bar");
|
|
|
+ $chart->setTitle("Region Pass Rate {$this->dateRangeLabel}");
|
|
|
+ $chart->setLabels($this->getRegionXDataLabels());
|
|
|
+ $chart->addDataset("Pass %", $data_values , [
|
|
|
+ "background_colours" => self::COLOUR_BLUE
|
|
|
+ ]);
|
|
|
+ $chart->addPrintDataset("Tests", $test_counts);
|
|
|
+ $chart->addPrintDataset("Pass", $pass_counts);
|
|
|
+ $chart->addPrintDataset("Fail", $fail_counts);
|
|
|
+
|
|
|
+ $chart->setDatalabelSuffixes("%");
|
|
|
+ $chart->print = true;
|
|
|
+ $chart->printTotalColumn = true;
|
|
|
+
|
|
|
+ return $chart;
|
|
|
+ }
|
|
|
+
|
|
|
+ public function getPeriodicRegionPassRateChart(): Chart {
|
|
|
+ $chart = new Chart;
|
|
|
+ $chart->addYAxis([
|
|
|
+ "id" => "y-axis-1",
|
|
|
+ "tick_config" => ["min" => 0, "max" => 100]
|
|
|
+ ]);
|
|
|
+ $chart->setType("bar");
|
|
|
+ $chart->setTitle("Region Pass Rate by {$this->resolutionName}");
|
|
|
+ $chart->setLabels($this->getRegionXDataLabels());
|
|
|
+
|
|
|
+ foreach($this->periodKeys as $index => $key) {
|
|
|
+ $data_values = [];
|
|
|
+ foreach($this->getRegionKeys() as $region) {
|
|
|
+ $r_data = $this->regionData[$region][$key];
|
|
|
+ $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->setDatalabelSuffixes(...array_fill(0, count($this->periodKeys), "%"));
|
|
|
+ return $chart;
|
|
|
+ }
|
|
|
+
|
|
|
+ public function hasAreaManagerData(): bool {
|
|
|
+ return $this->areaManagerData !== null;
|
|
|
+ }
|
|
|
+
|
|
|
+ public function getAreaManagerPassRateChart(): Chart {
|
|
|
+
|
|
|
+ // Area Pass Rate (Selected Date Range)
|
|
|
+ $data_values = [];
|
|
|
+
|
|
|
+ $test_counts = [];
|
|
|
+ $pass_counts = [];
|
|
|
+ $fail_counts = [];
|
|
|
+
|
|
|
+ foreach($this->areaManagerData as $area_manager => $a_data) {
|
|
|
+ $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_fail_count = array_sum(array_column($a_data, "failCount"));
|
|
|
+
|
|
|
+ $test_counts[] = $total_area_manager_test_count;
|
|
|
+ $pass_counts[] = $total_area_manager_pass_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);
|
|
|
+ }
|
|
|
+
|
|
|
+ $chart = new Chart;
|
|
|
+ $chart->addXAxis([
|
|
|
+ "type" => "category",
|
|
|
+ "scale_label_config" => [
|
|
|
+ "display" => true,
|
|
|
+ "labelString" => "Area Manager",
|
|
|
+ ]
|
|
|
+ ]);
|
|
|
+ $chart->addYAxis([
|
|
|
+ "id" => "y-axis-1",
|
|
|
+ "tick_config" => ["min" => 0, "max" => 100]
|
|
|
+ ]);
|
|
|
+ $chart->setType("bar");
|
|
|
+ $chart->setTitle("Area Manager Pass Rate {$this->dateRangeLabel}");
|
|
|
+ $chart->setLabels($this->getAreaManagerXDataLabels());
|
|
|
+ $chart->addDataset("Pass %", $data_values , [
|
|
|
+ "background_colours" => self::COLOUR_BLUE
|
|
|
+ ]);
|
|
|
+ $chart->addPrintDataset("Tests", $test_counts);
|
|
|
+ $chart->addPrintDataset("Pass", $pass_counts);
|
|
|
+ $chart->addPrintDataset("Fail", $fail_counts);
|
|
|
+ $chart->setDatalabelSuffixes("%");
|
|
|
+ $chart->print = true;
|
|
|
+ $chart->printTotalColumn = true;
|
|
|
+ return $chart;
|
|
|
+ }
|
|
|
+
|
|
|
+ public function getPeriodicAreaManagerPassRateChart(): Chart {
|
|
|
+
|
|
|
+ $chart = new Chart;
|
|
|
+ $chart->addXAxis([
|
|
|
+ "type" => "category",
|
|
|
+ "scale_label_config" => [
|
|
|
+ "display" => true,
|
|
|
+ "labelString" => "Area Manager",
|
|
|
+ ]
|
|
|
+ ]);
|
|
|
+ $chart->addYAxis([
|
|
|
+ "id" => "y-axis-1",
|
|
|
+ "tick_config" => ["min" => 0, "max" => 100]
|
|
|
+ ]);
|
|
|
+ $chart->setType("bar");
|
|
|
+ $chart->setTitle("Area Manager Pass Rate by {$this->resolutionName}");
|
|
|
+ $chart->setLabels($this->getAreaManagerXDataLabels());
|
|
|
+
|
|
|
+ foreach($this->periodKeys as $index => $key) {
|
|
|
+ $data_values = [];
|
|
|
+ foreach($this->getAreaManagerKeys() as $area_manager) {
|
|
|
+ $a_data = $this->areaManagerData[$area_manager][$key];
|
|
|
+ $data_values[] = ($a_data->testCount == 0) ? 0 : round(($a_data->passCount * 100) / $a_data->testCount);
|
|
|
+ }
|
|
|
+ $chart->addDataset($this->periodLabels[$index], $data_values, [
|
|
|
+ "background_colours" => Chart::COLOURS[$index],
|
|
|
+ "datalabels" => [
|
|
|
+ "display" => false,
|
|
|
+ ],
|
|
|
+ ]);
|
|
|
+ }
|
|
|
+ $chart->setDatalabelSuffixes(...array_fill(0, count($this->periodKeys), "%"));
|
|
|
+ return $chart;
|
|
|
+ }
|
|
|
+
|
|
|
+ public function getCleanlinessChart(): Chart {
|
|
|
+
|
|
|
+ $chart = new Chart;
|
|
|
+ $chart->setType("doughnut");
|
|
|
+ $chart->setTitle("Tests by Cleanliness {$this->dateRangeLabel}");
|
|
|
+ $chart->setLabels(["Very dirty", "Dirty", "Adequate", "Clean", "Very Clean"]);
|
|
|
+ $chart->addDataset("Tests", [
|
|
|
+ $this->totalData->cleanlinessCounts[0],
|
|
|
+ $this->totalData->cleanlinessCounts[1],
|
|
|
+ $this->totalData->cleanlinessCounts[2],
|
|
|
+ $this->totalData->cleanlinessCounts[3],
|
|
|
+ $this->totalData->cleanlinessCounts[4],
|
|
|
+ ], [
|
|
|
+ "background_colours" => [
|
|
|
+ self::COLOUR_RED,
|
|
|
+ self::COLOUR_LIGHT_RED,
|
|
|
+ self::COLOUR_ORANGE,
|
|
|
+ self::COLOUR_YELLOW,
|
|
|
+ self::COLOUR_GREEN,
|
|
|
+ ],
|
|
|
+ "datalabels" => Chart::DATALABELS_BOX,
|
|
|
+ ]);
|
|
|
+ $chart->setPrintSuffixes("");
|
|
|
+ $chart->print = true;
|
|
|
+ $chart->printTotalColumn = true;
|
|
|
+ $chart->printPercentages = true;
|
|
|
+ return $chart;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * @return Chart[]
|
|
|
+ * @throws Exception
|
|
|
+ */
|
|
|
+ public function getPeriodicCleanlinessCharts(): array {
|
|
|
+ $charts = [];
|
|
|
+
|
|
|
+ foreach($this->periodKeys as $index => $key) {
|
|
|
+ $key_label = $this->periodLabels[$index];
|
|
|
+
|
|
|
+ $period_data = $this->periodicData[$key];
|
|
|
+
|
|
|
+ if($period_data->testCount == 0) continue;
|
|
|
+
|
|
|
+ $chart = new Chart;
|
|
|
+ $chart->setType("pie");
|
|
|
+ $chart->setTitle("$key_label Cleanliness");
|
|
|
+ $chart->setLabels(["Very dirty", "Dirty", "Adequate", "Clean", "Very Clean"]);
|
|
|
+ $chart->addDataset("Counts", [
|
|
|
+ $period_data->cleanlinessCounts[0],
|
|
|
+ $period_data->cleanlinessCounts[1],
|
|
|
+ $period_data->cleanlinessCounts[2],
|
|
|
+ $period_data->cleanlinessCounts[3],
|
|
|
+ $period_data->cleanlinessCounts[4],
|
|
|
+ ], [
|
|
|
+ "background_colours" => [
|
|
|
+ self::COLOUR_RED,
|
|
|
+ self::COLOUR_LIGHT_RED,
|
|
|
+ self::COLOUR_ORANGE,
|
|
|
+ self::COLOUR_YELLOW,
|
|
|
+ self::COLOUR_GREEN,
|
|
|
+ ],
|
|
|
+ "datalabels" => Chart::DATALABELS_BOX,
|
|
|
+ ]);
|
|
|
+ $charts[] = $chart;
|
|
|
+ }
|
|
|
+
|
|
|
+ return $charts;
|
|
|
+ }
|
|
|
+
|
|
|
+ public function getPeriodicStaffBadgeWornChart(): Chart {
|
|
|
+ $staff_badge_worn_counts = array_column($this->periodicData, "staffBadgeWornCounts");
|
|
|
+
|
|
|
+ $unknown_counts = array_column($staff_badge_worn_counts, 0);
|
|
|
+ $no_counts = array_column($staff_badge_worn_counts, 1);
|
|
|
+ $yes_counts = array_column($staff_badge_worn_counts, 2);
|
|
|
+
|
|
|
+ $chart = new Chart;
|
|
|
+ $chart->setType("bar");
|
|
|
+ $chart->setTitle("Staff Badge Worn by {$this->resolutionName}");
|
|
|
+ $chart->setLabels($this->xDataLabels);
|
|
|
+ $chart->addDataset("Don't know", $unknown_counts, [
|
|
|
+ "background_colours" => self::COLOUR_LIGHT_GREY
|
|
|
+ ]);
|
|
|
+ $chart->addDataset("No", $no_counts, [
|
|
|
+ "background_colours" => self::COLOUR_RED
|
|
|
+ ]);
|
|
|
+ $chart->addDataset("Yes", $yes_counts, [
|
|
|
+ "background_colours" => self::COLOUR_GREEN
|
|
|
+ ]);
|
|
|
+ return $chart;
|
|
|
+ }
|
|
|
+
|
|
|
+ public function getPeriodicStaffOfferedDrinkChart(): Chart {
|
|
|
+ $counts = array_column($this->periodicData, "staffOfferedDrinkCounts");
|
|
|
+ return $this->getPeriodicBooleanChart("Staff Offered Drink", $counts);
|
|
|
+ }
|
|
|
+
|
|
|
+ public function getPeriodicStaffOfferedPromotionChart(): Chart {
|
|
|
+ $counts = array_column($this->periodicData, "staffOfferedPromotionCounts");
|
|
|
+ return $this->getPeriodicBooleanChart("Staff Offered Promotion", $counts);
|
|
|
+ }
|
|
|
+
|
|
|
+ public function getPeriodicStaffOfferedHelpChart(): Chart {
|
|
|
+ $counts = array_column($this->periodicData, "staffOfferedHelpCounts");
|
|
|
+ return $this->getPeriodicBooleanChart("Staff Offered Help", $counts);
|
|
|
+ }
|
|
|
+
|
|
|
+ public function getPeriodicStaffBehaviourCharts(): array {
|
|
|
+
|
|
|
+ $charts = [];
|
|
|
+
|
|
|
+ foreach($this->periodKeys as $index => $key) {
|
|
|
+ $key_label = $this->periodLabels[$index];
|
|
|
+
|
|
|
+ $period_data = $this->periodicData[$key];
|
|
|
+
|
|
|
+ if($period_data->testCount == 0) continue;
|
|
|
+
|
|
|
+ $chart = new Chart;
|
|
|
+ $chart->setType("pie");
|
|
|
+ $chart->setTitle("$key_label Staff Behaviour");
|
|
|
+ $chart->setLabels(["N/A", "Rude", "Slightly rude", "Neither rude or polite", "Polite", "Very polite"]);
|
|
|
+ $chart->addDataset("Counts", [
|
|
|
+ $period_data->staffBehaviourCounts[0],
|
|
|
+ $period_data->staffBehaviourCounts[1],
|
|
|
+ $period_data->staffBehaviourCounts[2],
|
|
|
+ $period_data->staffBehaviourCounts[3],
|
|
|
+ $period_data->staffBehaviourCounts[4],
|
|
|
+ $period_data->staffBehaviourCounts[5],
|
|
|
+ ], [
|
|
|
+ "background_colours" => [
|
|
|
+ self::COLOUR_LIGHT_GREY,
|
|
|
+ self::COLOUR_RED,
|
|
|
+ self::COLOUR_LIGHT_RED,
|
|
|
+ self::COLOUR_ORANGE,
|
|
|
+ self::COLOUR_YELLOW,
|
|
|
+ self::COLOUR_GREEN,
|
|
|
+ ],
|
|
|
+ "datalabels" => Chart::DATALABELS_BOX,
|
|
|
+ ]);
|
|
|
+ $charts[] = $chart;
|
|
|
+ }
|
|
|
+
|
|
|
+ return $charts;
|
|
|
+ }
|
|
|
+
|
|
|
+ public function getPeriodicStaffUniformChart(): Chart {
|
|
|
+ $counts = array_column($this->periodicData, "staffUniformCounts");
|
|
|
+ return $this->getPeriodicBooleanChart("Staff Uniform", $counts);
|
|
|
+ }
|
|
|
+
|
|
|
+ // Private methods
|
|
|
+
|
|
|
+ private function getPeriodicPassRates() {
|
|
|
+ return array_values(array_map(function($d) {
|
|
|
+ if($d->testCount == 0) return 0;
|
|
|
+ return round(($d->passCount / $d->testCount) * 100);
|
|
|
+ }, $this->periodicData));
|
|
|
+ }
|
|
|
+
|
|
|
+ private function getPeriodicFailRates() {
|
|
|
+ return array_values(array_map(function($d) {
|
|
|
+ if($d->testCount == 0) return 0;
|
|
|
+ $pass_rate = round(($d->passCount / $d->testCount) * 100);
|
|
|
+ return 100 - $pass_rate;
|
|
|
+ }, $this->periodicData));
|
|
|
+ }
|
|
|
+
|
|
|
+ private function getPeriodicPassRateByDoorSensorAlert(int $index) {
|
|
|
+ return array_values(array_map(function($data) use ($index) {
|
|
|
+ if($data->testCount == 0) return null;
|
|
|
+ if($data->doorSensorAlertFailCounts[$index] == 0) return 100;
|
|
|
+ return round(($data->doorSensorAlertPassCounts[$index] / $data->testCount) * 100);
|
|
|
+ }, $this->periodicData));
|
|
|
+ }
|
|
|
+
|
|
|
+ private function getPeriodicPassRateByEyeContact(int $index) {
|
|
|
+ return array_values(array_map(function($data) use ($index) {
|
|
|
+ if($data->testCount == 0) return null;
|
|
|
+ if($data->eyeContactFailCounts[$index] == 0) return 100;
|
|
|
+ return round(($data->eyeContactPassCounts[$index] / $data->testCount) * 100);
|
|
|
+ }, $this->periodicData));
|
|
|
+ }
|
|
|
+
|
|
|
+ private function getPeriodicPassRateByLineOfSight(int $index) {
|
|
|
+ return array_values(array_map(function($data) use ($index) {
|
|
|
+ if($data->testCount == 0) return null;
|
|
|
+ if($data->lineOfSightFailCounts[$index] == 0) return 100;
|
|
|
+ return round(($data->lineOfSightPassCounts[$index] / $data->testCount) * 100);
|
|
|
+ }, $this->periodicData));
|
|
|
+ }
|
|
|
+
|
|
|
+ private function getPeriodicPassRateByBarPurchase(int $index) {
|
|
|
+ return array_values(array_map(function($data) use ($index) {
|
|
|
+ if($data->testCount == 0) return null;
|
|
|
+ if($data->barPurchaseFailCounts[$index] == 0) return 100;
|
|
|
+ return round(($data->barPurchasePassCounts[$index] / $data->testCount) * 100);
|
|
|
+ }, $this->periodicData));
|
|
|
+ }
|
|
|
+
|
|
|
+ private function getEyeContactRates(): array {
|
|
|
+ return array_values(array_map(function($period) {
|
|
|
+ if($period->testCount == 0) return [0, 0, 0];
|
|
|
+
|
|
|
+ $yes = round(($period->eyeContactCounts[0] / $period->testCount) * 100);
|
|
|
+ $no = 100 - $yes;
|
|
|
+ $na = 0;
|
|
|
+
|
|
|
+ return [$yes, $no, $na];
|
|
|
+ }, $this->periodicData));
|
|
|
+ }
|
|
|
+
|
|
|
+ private function getPeriodicTestCounts(): array {
|
|
|
+ return array_column($this->periodicData, "testCount");
|
|
|
+ }
|
|
|
+
|
|
|
+ private function getPeriodicPassCounts(): array {
|
|
|
+ return array_column($this->periodicData, "passCount");
|
|
|
+ }
|
|
|
+
|
|
|
+ private function getPeriodicFailCounts(): array {
|
|
|
+ return array_column($this->periodicData, "failCount");
|
|
|
+ }
|
|
|
+
|
|
|
+ private function getPeriodicMaleTesterCount(): array {
|
|
|
+ return array_values(array_map(function($d) {
|
|
|
+ return $d->maleTesterCount;
|
|
|
+ }, $this->periodicData));
|
|
|
+ }
|
|
|
+
|
|
|
+ private function getPeriodicFemaleTesterCount(): array {
|
|
|
+ return array_values(array_map(function($d) {
|
|
|
+ return $d->femaleTesterCount;
|
|
|
+ }, $this->periodicData));
|
|
|
+ }
|
|
|
+
|
|
|
+ private function getRegionKeys(): array {
|
|
|
+ if(!$this->regionData) return [];
|
|
|
+ return array_keys($this->regionData);
|
|
|
+ }
|
|
|
+
|
|
|
+ private function getRegionXDataLabels(): array {
|
|
|
+ return array_map(function($key) {
|
|
|
+ return "Region $key";
|
|
|
+ }, $this->getRegionKeys());
|
|
|
+ }
|
|
|
+
|
|
|
+ private function getAreaManagerKeys(): array {
|
|
|
+ if(!$this->areaManagerData) return [];
|
|
|
+ return array_keys($this->areaManagerData);
|
|
|
+ }
|
|
|
+
|
|
|
+ private function getAreaManagerXDataLabels(): array {
|
|
|
+ return $this->getAreaManagerKeys();
|
|
|
+ }
|
|
|
+
|
|
|
+ private function getPeriodicBooleanChart(string $title, array $values): Chart {
|
|
|
+
|
|
|
+ $no_counts = array_column($values, 0);
|
|
|
+ $yes_counts = array_column($values, 1);
|
|
|
+
|
|
|
+ $chart = new Chart;
|
|
|
+ $chart->setType("bar");
|
|
|
+ $chart->setTitle("{$title} by {$this->resolutionName}");
|
|
|
+ $chart->setLabels($this->xDataLabels);
|
|
|
+ $chart->addDataset("No", $no_counts, [
|
|
|
+ "background_colours" => self::COLOUR_RED
|
|
|
+ ]);
|
|
|
+ $chart->addDataset("Yes", $yes_counts, [
|
|
|
+ "background_colours" => self::COLOUR_GREEN
|
|
|
+ ]);
|
|
|
+ return $chart;
|
|
|
+ }
|
|
|
+
|
|
|
+ private function getPeriodicPassRateChart(string $title, array $yes_rates, array $no_rates, ?array $null_rates = null) {
|
|
|
+
|
|
|
+ $chart = new Chart;
|
|
|
+ $chart->addYAxis([
|
|
|
+ "tick_config" => ["min" => 0, "max" => 100],
|
|
|
+ ]);
|
|
|
+
|
|
|
+ $chart->setType("line");
|
|
|
+ $chart->setTitle($title);
|
|
|
+ $chart->setLabels($this->xDataLabels);
|
|
|
+
|
|
|
+ $chart->setDatalabelSuffixes("%", "%");
|
|
|
+
|
|
|
+ if($null_rates !== null) {
|
|
|
+ $chart->addDataset("Don't Know", $null_rates, [
|
|
|
+ "background_colours" => self::COLOUR_GREY . "3F",
|
|
|
+ "border_colours" => self::COLOUR_GREY,
|
|
|
+ "line_tension" => 0,
|
|
|
+ "datalabels" => ["display" => false],
|
|
|
+ ]);
|
|
|
+ $chart->setDatalabelSuffixes("%", "%", "%");
|
|
|
+ }
|
|
|
+
|
|
|
+ $chart->addDataset("No", $no_rates, [
|
|
|
+ "background_colours" => self::COLOUR_RED . "3F",
|
|
|
+ "border_colours" => self::COLOUR_RED,
|
|
|
+ "line_tension" => 0,
|
|
|
+ "datalabels" => ["display" => false],
|
|
|
+ ]);
|
|
|
+
|
|
|
+ $chart->addDataset("Yes", $yes_rates, [
|
|
|
+ "background_colours" => self::COLOUR_GREEN . "3F",
|
|
|
+ "border_colours" => self::COLOUR_GREEN,
|
|
|
+ "line_tension" => 0,
|
|
|
+ "datalabels" => ["display" => false],
|
|
|
+ ]);
|
|
|
+
|
|
|
+ $chart->print = true;
|
|
|
+ return $chart;
|
|
|
+ }
|
|
|
+
|
|
|
+}
|