Explorar o código

Add data table for "Tests by Stage"

Alan Lam %!s(int64=8) %!d(string=hai) anos
pai
achega
7d8e6e8b87
Modificáronse 1 ficheiros con 62 adicións e 2 borrados
  1. 62 2
      controllers/performance.php

+ 62 - 2
controllers/performance.php

@@ -443,10 +443,70 @@ if($submit) {
 				"#F44336",
 				"#F44336",
 			],
 			],
 			"datalabels" => [
 			"datalabels" => [
-				"textAlign" => "center"
+				"display" => false,
 			],
 			],
 		]);
 		]);
-		$chart->setDatalabelFormatterCallback("testsByStageFormatter");
+
+		// Generate table
+		ob_start();
+		?>
+
+		<table class="table table-sm small table-bordered mt-3">
+			<thead>
+				<tr>
+					<th></th>
+					<th>Stage 1</th>
+					<th>Stage 2</th>
+					<th>Stage 3</th>
+					<th>Stage 4</th>
+					<th>Stage 5</th>
+				</tr>
+			</thead>
+			<tbody>
+			<?php
+			foreach(["value", "percent"] as $field) {
+
+				switch($field) {
+					case "value": $label = "Test Count"; break;
+					case "percent": $label = "Percentage"; break;
+				}
+
+				?>
+				<tr>
+					<td><?=htmlspecialchars($label)?></td>
+					<?php
+					foreach(range(1, 5) as $stage) {
+
+						$key = "stage{$stage}Count";
+						$count = $total_data->{$key};
+
+						switch($field) {
+							case "value":
+								$string = $count;
+								break;
+							case "percent":
+								$string = (floor(($count * 10000) / $test_count) / 100) . "%";
+								break;
+						}
+
+						?>
+						<td class="text-right"><?=$string?></td>
+						<?php
+					}
+					?>
+				</tr>
+				<?php
+
+			}
+			?>
+			</tbody>
+		</table>
+
+		<?php
+		$html = ob_get_clean();
+
+		$chart->setAfterHtml($html);
+
 		$charts[] = $chart;
 		$charts[] = $chart;