1
0
Эх сурвалжийг харах

Add box datalabels to more charts

Alan Lam 8 жил өмнө
parent
commit
a46a3495d5

+ 8 - 14
controllers/reports.php

@@ -453,10 +453,7 @@ if($submit) {
 				"#FFAB91",
 				"#F44336",
 			],
-			"datalabels" => [
-				"backgroundColor" => "rgba(0, 0, 0, 0.75)",
-				"borderRadius" => "2",
-			],
+			"datalabels" => Chart::DATALABELS_BOX,
 		]);
 		$chart->setPrintSuffixes("");
 		$chart->print = true;
@@ -480,9 +477,9 @@ if($submit) {
 				"#2196F3",
 				"#E91E63",
 				"#9E9E9E",
-			]
+			],
+			"datalabels" => Chart::DATALABELS_BOX,
 		]);
-		$chart->setDatalabelSuffixes(" Test");
 		$charts[] = $chart;
 
 		// Tester Gender
@@ -497,9 +494,9 @@ if($submit) {
 			"background_colours" => [
 				"#2196F3",
 				"#E91E63",
-			]
+			],
+			"datalabels" => Chart::DATALABELS_BOX,
 		]);
-		$chart->setDatalabelSuffixes(" Test");
 		$charts[] = $chart;
 
 		// Pass / Fail
@@ -514,9 +511,9 @@ if($submit) {
 			"background_colours" => [
 				"#4CAF50",
 				"#F44336",
-			]
+			],
+			"datalabels" => Chart::DATALABELS_BOX,
 		]);
-		$chart->setDatalabelSuffixes(" Test");
 		$charts[] = $chart;
 
 		// Pass Rate Period
@@ -640,10 +637,7 @@ if($submit) {
 					"#FFAB91",
 					"#F44336",
 				],
-				"datalabels" => [
-					"backgroundColor" => "rgba(0, 0, 0, 0.75)",
-					"borderRadius" => "2",
-				],
+				"datalabels" => Chart::DATALABELS_BOX,
 			]);
 			$charts[] = $chart;
 		}

+ 5 - 0
engine/chart.php

@@ -2,6 +2,11 @@
 
 class Chart {
 
+	const DATALABELS_BOX = [
+		"backgroundColor" => "rgba(0, 0, 0, 0.75)",
+		"borderRadius" => "2",
+	];
+
 	private $id = "";
 	private $title = "Untitled";
 	private $type = "bar";