Forráskód Böngészése

Add support for setting HTML before and after charts

Alan Lam 8 éve
szülő
commit
2fbd3385ce
2 módosított fájl, 21 hozzáadás és 1 törlés
  1. 11 1
      engine/chart.php
  2. 10 0
      views/performance.php

+ 11 - 1
engine/chart.php

@@ -14,6 +14,8 @@ class Chart {
 	private $datalabelSuffixes = [];
 	private $datalabelFormatterCallback = false;
 
+	public $beforeHtml = null;
+	public $afterHtml = null;
 	public $print = false;
 
 	public function __construct() {
@@ -176,7 +178,7 @@ class Chart {
 
 	public function printDataTable() {
 		?>
-		<table class="mt-3 w-100 table-bordered">
+		<table class="mt-3 w-100 table table-sm small table-bordered">
 			<thead>
 				<tr>
 					<th></th>
@@ -217,6 +219,14 @@ class Chart {
 		<?php
 	}
 
+	public function setBeforeHtml($html) {
+		$this->beforeHtml = $html;
+	}
+
+	public function setAfterHtml($html) {
+		$this->afterHtml = $html;
+	}
+
 }
 
 ?>

+ 10 - 0
views/performance.php

@@ -265,6 +265,11 @@ $date_range_custom_style = ($date_range == "custom") ? "" : "display: none";
 					<br />
 					<?php
 				}
+
+				if($chart->beforeHtml) {
+					echo $chart->beforeHtml;
+				}
+
 				?>
 				<a id="chart-<?=$index?>" style="display: block; position: relative; top: -7rem; visibility: hidden;"></a>
 				<canvas id="<?=$chart->getID()?>" data-chart="<?=htmlspecialchars($chart->getJSON())?>" width="400" height="300">
@@ -273,6 +278,11 @@ $date_range_custom_style = ($date_range == "custom") ? "" : "display: none";
 				if($chart->print) {
 					$chart->printDataTable();
 				}
+
+				if($chart->afterHtml) {
+					echo $chart->afterHtml;
+				}
+
 			}
 			?>
 			</div>