|
@@ -46,6 +46,9 @@ class ChartGenerator {
|
|
|
/** @var array $areaManagerData */
|
|
/** @var array $areaManagerData */
|
|
|
private $areaManagerData;
|
|
private $areaManagerData;
|
|
|
|
|
|
|
|
|
|
+ /** @var array */
|
|
|
|
|
+ private $brandData;
|
|
|
|
|
+
|
|
|
/** @var Template $template */
|
|
/** @var Template $template */
|
|
|
private $template;
|
|
private $template;
|
|
|
|
|
|
|
@@ -200,6 +203,10 @@ class ChartGenerator {
|
|
|
$this->areaManagerData = $data;
|
|
$this->areaManagerData = $data;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ public function setBrandData(array $data): void {
|
|
|
|
|
+ $this->brandData = $data;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
// Charts
|
|
// Charts
|
|
|
public function getTestsByStageChart(): Chart {
|
|
public function getTestsByStageChart(): Chart {
|
|
|
$chart = new Chart;
|
|
$chart = new Chart;
|
|
@@ -716,96 +723,22 @@ class ChartGenerator {
|
|
|
return $charts;
|
|
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 $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)
|
|
|
|
|
|
|
+ private function getDataPassRateChart(array $data, string $entity_name): Chart {
|
|
|
$data_values = [];
|
|
$data_values = [];
|
|
|
|
|
|
|
|
$test_counts = [];
|
|
$test_counts = [];
|
|
|
$pass_counts = [];
|
|
$pass_counts = [];
|
|
|
$fail_counts = [];
|
|
$fail_counts = [];
|
|
|
|
|
|
|
|
- foreach($this->areaManagerData as $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"));
|
|
|
|
|
|
|
+ foreach($data as $datum) {
|
|
|
|
|
+ $total_test_count = array_sum(array_column($datum, "testCount"));
|
|
|
|
|
+ $total_pass_count = array_sum(array_column($datum, "passCount"));
|
|
|
|
|
|
|
|
- $test_counts[] = $total_area_manager_test_count;
|
|
|
|
|
- $pass_counts[] = $total_area_manager_pass_count;
|
|
|
|
|
- $fail_counts[] = $total_area_manager_fail_count;
|
|
|
|
|
|
|
+ $test_counts[] = $total_test_count;
|
|
|
|
|
+ $pass_counts[] = $total_pass_count;
|
|
|
|
|
+ $fail_counts[] = $total_test_count - $total_pass_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_test_count === 0) ? 0 : round(($total_pass_count * 100) / $total_test_count);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
$chart = new Chart;
|
|
$chart = new Chart;
|
|
@@ -813,7 +746,7 @@ class ChartGenerator {
|
|
|
"type" => "category",
|
|
"type" => "category",
|
|
|
"scale_label_config" => [
|
|
"scale_label_config" => [
|
|
|
"display" => true,
|
|
"display" => true,
|
|
|
- "labelString" => "Area Manager",
|
|
|
|
|
|
|
+ "labelString" => $entity_name,
|
|
|
]
|
|
]
|
|
|
]);
|
|
]);
|
|
|
$chart->addYAxis([
|
|
$chart->addYAxis([
|
|
@@ -821,8 +754,8 @@ class ChartGenerator {
|
|
|
"tick_config" => ["min" => 0, "max" => 100]
|
|
"tick_config" => ["min" => 0, "max" => 100]
|
|
|
]);
|
|
]);
|
|
|
$chart->setType("bar");
|
|
$chart->setType("bar");
|
|
|
- $chart->setTitle("Area Manager Pass Rate ({$this->dateRangeLabel})");
|
|
|
|
|
- $chart->setLabels($this->getAreaManagerXDataLabels());
|
|
|
|
|
|
|
+ $chart->setTitle("{$entity_name} Pass Rate ({$this->dateRangeLabel})");
|
|
|
|
|
+ $chart->setLabels(array_keys($data));
|
|
|
$chart->addDataset("Pass %", $data_values , [
|
|
$chart->addDataset("Pass %", $data_values , [
|
|
|
"background_colours" => self::COLOUR_BLUE
|
|
"background_colours" => self::COLOUR_BLUE
|
|
|
]);
|
|
]);
|
|
@@ -835,14 +768,37 @@ class ChartGenerator {
|
|
|
return $chart;
|
|
return $chart;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- public function getPeriodicAreaManagerPassRateChart(): Chart {
|
|
|
|
|
|
|
+ public function getPeriodicDataPassRateChart(string $entity): Chart {
|
|
|
|
|
+
|
|
|
|
|
+ switch($entity) {
|
|
|
|
|
+ case "region":
|
|
|
|
|
+ $data = $this->regionData;
|
|
|
|
|
+ $entity_name = "Region";
|
|
|
|
|
+ $entity_keys = $this->getRegionKeys();
|
|
|
|
|
+ $x_labels = $this->getRegionXDataLabels();
|
|
|
|
|
+ break;
|
|
|
|
|
+ case "areaManager":
|
|
|
|
|
+ $data = $this->areaManagerData;
|
|
|
|
|
+ $entity_name = "Area Manager";
|
|
|
|
|
+ $entity_keys = $this->getAreaManagerKeys();
|
|
|
|
|
+ $x_labels = $this->getAreaManagerKeys();
|
|
|
|
|
+ break;
|
|
|
|
|
+ case "brand":
|
|
|
|
|
+ $data = $this->brandData;
|
|
|
|
|
+ $entity_name = "Brand";
|
|
|
|
|
+ $entity_keys = $this->getBrandKeys();
|
|
|
|
|
+ $x_labels = $this->getBrandKeys();
|
|
|
|
|
+ break;
|
|
|
|
|
+ default:
|
|
|
|
|
+ throw new RuntimeException("Invalid entity passed to getPeriodicDataPassRateChart: $entity");
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
- $chart = new Chart;
|
|
|
|
|
|
|
+ $chart = new Chart();
|
|
|
$chart->addXAxis([
|
|
$chart->addXAxis([
|
|
|
"type" => "category",
|
|
"type" => "category",
|
|
|
"scale_label_config" => [
|
|
"scale_label_config" => [
|
|
|
"display" => true,
|
|
"display" => true,
|
|
|
- "labelString" => "Area Manager",
|
|
|
|
|
|
|
+ "labelString" => $entity_name,
|
|
|
]
|
|
]
|
|
|
]);
|
|
]);
|
|
|
$chart->addYAxis([
|
|
$chart->addYAxis([
|
|
@@ -850,26 +806,62 @@ class ChartGenerator {
|
|
|
"tick_config" => ["min" => 0, "max" => 100]
|
|
"tick_config" => ["min" => 0, "max" => 100]
|
|
|
]);
|
|
]);
|
|
|
$chart->setType("bar");
|
|
$chart->setType("bar");
|
|
|
- $chart->setTitle("Area Manager Pass Rate by {$this->resolutionName}");
|
|
|
|
|
- $chart->setLabels($this->getAreaManagerXDataLabels());
|
|
|
|
|
|
|
+ $chart->setTitle("{$entity_name} Pass Rate by {$this->resolutionName}");
|
|
|
|
|
+ $chart->setLabels($x_labels);
|
|
|
|
|
|
|
|
foreach($this->periodKeys as $index => $key) {
|
|
foreach($this->periodKeys as $index => $key) {
|
|
|
$data_values = [];
|
|
$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);
|
|
|
|
|
|
|
+ foreach($entity_keys as $entity_key) {
|
|
|
|
|
+ $datum = $data[$entity_key][$key];
|
|
|
|
|
+ $data_values[] = ($datum->testCount === 0) ? 0 : round(($datum->passCount * 100) / $datum->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],
|
|
|
- "datalabels" => [
|
|
|
|
|
- "display" => false,
|
|
|
|
|
- ],
|
|
|
|
|
|
|
+ "dataLabels" => [
|
|
|
|
|
+ "display" => false
|
|
|
|
|
+ ]
|
|
|
]);
|
|
]);
|
|
|
}
|
|
}
|
|
|
$chart->setDatalabelSuffixes(...array_fill(0, count($this->periodKeys), "%"));
|
|
$chart->setDatalabelSuffixes(...array_fill(0, count($this->periodKeys), "%"));
|
|
|
return $chart;
|
|
return $chart;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ public function hasRegionData(): bool {
|
|
|
|
|
+ return $this->regionData !== null;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ public function getRegionPassRateChart(): Chart {
|
|
|
|
|
+ return $this->getDataPassRateChart($this->regionData, "Region");
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ public function getPeriodicRegionPassRateChart(): Chart {
|
|
|
|
|
+ return $this->getPeriodicDataPassRateChart("region");
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ public function hasAreaManagerData(): bool {
|
|
|
|
|
+ return $this->areaManagerData !== null;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ public function getAreaManagerPassRateChart(): Chart {
|
|
|
|
|
+ return $this->getDataPassRateChart($this->areaManagerData, "Area Manager");
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ public function getPeriodicAreaManagerPassRateChart(): Chart {
|
|
|
|
|
+ return $this->getPeriodicDataPassRateChart("areaManager");
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ public function hasBrandData(): bool {
|
|
|
|
|
+ return $this->brandData !== null;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ public function getBrandPassRateChart(): Chart {
|
|
|
|
|
+ return $this->getDataPassRateChart($this->brandData, "Brand");
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ public function getPeriodicBrandPassRateChart(): Chart {
|
|
|
|
|
+ return $this->getPeriodicDataPassRateChart("brand");
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
public function getCleanlinessChart(): Chart {
|
|
public function getCleanlinessChart(): Chart {
|
|
|
|
|
|
|
|
$chart = new Chart;
|
|
$chart = new Chart;
|
|
@@ -1146,6 +1138,11 @@ class ChartGenerator {
|
|
|
return array_keys($this->areaManagerData);
|
|
return array_keys($this->areaManagerData);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ private function getBrandKeys(): array {
|
|
|
|
|
+ if(!$this->brandData) return [];
|
|
|
|
|
+ return array_keys($this->brandData);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
private function getAreaManagerXDataLabels(): array {
|
|
private function getAreaManagerXDataLabels(): array {
|
|
|
return $this->getAreaManagerKeys();
|
|
return $this->getAreaManagerKeys();
|
|
|
}
|
|
}
|