|
@@ -346,7 +346,36 @@ class ChartGenerator {
|
|
|
return $chart;
|
|
return $chart;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- public function getPeriodicPassFailRateChart(string $title = "Pass / Fail"): Chart {
|
|
|
|
|
|
|
+ public function getPeriodicPassFailRateChart(array $options = []): Chart {
|
|
|
|
|
+
|
|
|
|
|
+ $title = $options["title"] ?? "Pass / Fail";
|
|
|
|
|
+ $array_key = $options["array_key"] ?? null;
|
|
|
|
|
+
|
|
|
|
|
+ $pass_rates = [];
|
|
|
|
|
+ $fail_rates = [];
|
|
|
|
|
+
|
|
|
|
|
+ foreach($this->periodicData as $period) {
|
|
|
|
|
+ if($array_key) {
|
|
|
|
|
+ $pass_count = $period->$array_key["pass"];
|
|
|
|
|
+ $fail_count = $period->$array_key["fail"];
|
|
|
|
|
+ }
|
|
|
|
|
+ else {
|
|
|
|
|
+ $pass_count = $period->passCount;
|
|
|
|
|
+ $fail_count = $period->failCount;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ $test_count = $pass_count + $fail_count;
|
|
|
|
|
+
|
|
|
|
|
+ if($test_count === 0) {
|
|
|
|
|
+ $pass_rates[] = 0;
|
|
|
|
|
+ $fail_rates[] = 0;
|
|
|
|
|
+ }
|
|
|
|
|
+ else {
|
|
|
|
|
+ $pass_rate = round(($pass_count / $test_count) * 100);
|
|
|
|
|
+ $pass_rates[] = $pass_rate;
|
|
|
|
|
+ $fail_rates[] = 100 - $pass_rate;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
$chart = new Chart();
|
|
$chart = new Chart();
|
|
|
$chart->addXAxis([
|
|
$chart->addXAxis([
|
|
@@ -362,10 +391,10 @@ 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("Pass Rate (%)", $this->getPeriodicPassRates(), [
|
|
|
|
|
|
|
+ $chart->addDataset("Pass Rate (%)", $pass_rates, [
|
|
|
"background_colours" => self::COLOUR_GREEN
|
|
"background_colours" => self::COLOUR_GREEN
|
|
|
]);
|
|
]);
|
|
|
- $chart->addDataset("Fail Rate (%)", $this->getPeriodicFailRates(), [
|
|
|
|
|
|
|
+ $chart->addDataset("Fail Rate (%)", $fail_rates, [
|
|
|
"background_colours" => self::COLOUR_RED
|
|
"background_colours" => self::COLOUR_RED
|
|
|
]);
|
|
]);
|
|
|
$chart->setDatalabelSuffixes("%", "%");
|
|
$chart->setDatalabelSuffixes("%", "%");
|