|
|
@@ -309,6 +309,39 @@ class ChartGenerator {
|
|
|
return $chart;
|
|
|
}
|
|
|
|
|
|
+ public function getPassFailCountChartByKey(string $title, string $object_key): Chart {
|
|
|
+ $data = $this->totalData;
|
|
|
+
|
|
|
+ $counts = $data->$object_key;
|
|
|
+
|
|
|
+ $pass_count = $counts["pass"] ?? 0;
|
|
|
+ $fail_count = $counts["fail"] ?? 0;
|
|
|
+
|
|
|
+ $dataset = [$pass_count, $fail_count];
|
|
|
+ $labels = ["Pass", "Fail"];
|
|
|
+ $colours = [self::COLOUR_GREEN, self::COLOUR_RED];
|
|
|
+
|
|
|
+ /*
|
|
|
+ if($data->voidCount > 0) {
|
|
|
+ $dataset[] = $data->voidCount;
|
|
|
+ $labels[] = "Void";
|
|
|
+ $colours[] = self::COLOUR_GREY;
|
|
|
+ }
|
|
|
+ */
|
|
|
+
|
|
|
+ $title = sprintf("%s (%s)", $title, $this->dateRangeLabel);
|
|
|
+
|
|
|
+ $chart = new Chart();
|
|
|
+ $chart->setType("pie");
|
|
|
+ $chart->setTitle($title);
|
|
|
+ $chart->setLabels($labels);
|
|
|
+ $chart->addDataset("Counts", $dataset, [
|
|
|
+ "background_colours" => $colours,
|
|
|
+ "datalabels" => Chart::DATALABELS_BOX,
|
|
|
+ ]);
|
|
|
+ return $chart;
|
|
|
+ }
|
|
|
+
|
|
|
public function getPeriodicPassFailRateChart(): Chart {
|
|
|
|
|
|
$chart = new Chart;
|
|
|
@@ -403,13 +436,15 @@ class ChartGenerator {
|
|
|
|
|
|
}
|
|
|
|
|
|
- public function getPeriodicAlcoholPassRateChart(): Chart {
|
|
|
+ public function getPeriodicPassRateChartByKey(string $title, string $object_key): Chart {
|
|
|
$pass_rates = [];
|
|
|
$fail_rates = [];
|
|
|
|
|
|
foreach($this->periodicData as $index => $data) {
|
|
|
- $pass_count = $data->alcoholCounts["pass"];
|
|
|
- $fail_count = $data->alcoholCounts["fail"];
|
|
|
+ $counts = $data->$object_key;
|
|
|
+
|
|
|
+ $pass_count = $counts["pass"];
|
|
|
+ $fail_count = $counts["fail"];
|
|
|
$test_count = $pass_count + $fail_count;
|
|
|
|
|
|
if($test_count === 0) {
|
|
|
@@ -436,7 +471,7 @@ class ChartGenerator {
|
|
|
"stacked" => true,
|
|
|
]);
|
|
|
$chart->setType("horizontalBar");
|
|
|
- $chart->setTitle(__("Alcohol Pass Rate"));
|
|
|
+ $chart->setTitle($title);
|
|
|
$chart->setLabels($this->xDataLabels);
|
|
|
$chart->addDataset("Pass (%)", $pass_rates, ["background_colours" => self::COLOUR_GREEN]);
|
|
|
$chart->addDataset("Fail (%)", $fail_rates, ["background_colours" => self::COLOUR_RED]);
|