|
@@ -10,6 +10,7 @@ class Chart {
|
|
|
private $yAxes = [];
|
|
private $yAxes = [];
|
|
|
|
|
|
|
|
private $datalabelSuffixes = [];
|
|
private $datalabelSuffixes = [];
|
|
|
|
|
+ public $print = false;
|
|
|
|
|
|
|
|
public function __construct() {
|
|
public function __construct() {
|
|
|
$this->id = bin2hex(random_bytes(8));
|
|
$this->id = bin2hex(random_bytes(8));
|
|
@@ -71,7 +72,7 @@ class Chart {
|
|
|
if($type) $dataset["type"] = $type;
|
|
if($type) $dataset["type"] = $type;
|
|
|
if($datalabels) $dataset["datalabels"] = $datalabels;
|
|
if($datalabels) $dataset["datalabels"] = $datalabels;
|
|
|
|
|
|
|
|
- $this->datasets[] = $dataset;
|
|
|
|
|
|
|
+ $this->datasets[] = (object) $dataset;
|
|
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -124,6 +125,49 @@ class Chart {
|
|
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ public function printDataTable() {
|
|
|
|
|
+ ?>
|
|
|
|
|
+ <table class="mt-3 w-100 table table-condensed table-bordered">
|
|
|
|
|
+ <thead>
|
|
|
|
|
+ <tr>
|
|
|
|
|
+ <th></th>
|
|
|
|
|
+ <?php
|
|
|
|
|
+ foreach($this->labels as $label) {
|
|
|
|
|
+ ?>
|
|
|
|
|
+ <th><?=htmlspecialchars($label)?></th>
|
|
|
|
|
+ <?php
|
|
|
|
|
+ }
|
|
|
|
|
+ ?>
|
|
|
|
|
+ </tr>
|
|
|
|
|
+ </thead>
|
|
|
|
|
+ <tbody>
|
|
|
|
|
+ <?php
|
|
|
|
|
+ foreach($this->datasets as $index => $dataset) {
|
|
|
|
|
+
|
|
|
|
|
+ $suffix = "";
|
|
|
|
|
+ if($this->datalabelSuffixes) {
|
|
|
|
|
+ $suffix = $this->datalabelSuffixes[$index];
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ ?>
|
|
|
|
|
+ <tr>
|
|
|
|
|
+ <td><?=htmlspecialchars($dataset->label)?></td>
|
|
|
|
|
+ <?php
|
|
|
|
|
+ foreach($dataset->data as $value) {
|
|
|
|
|
+ ?>
|
|
|
|
|
+ <td class="text-right"><?=htmlspecialchars($value)?><?=htmlspecialchars($suffix)?></td>
|
|
|
|
|
+ <?php
|
|
|
|
|
+ }
|
|
|
|
|
+ ?>
|
|
|
|
|
+ </tr>
|
|
|
|
|
+ <?php
|
|
|
|
|
+ }
|
|
|
|
|
+ ?>
|
|
|
|
|
+ </tbody>
|
|
|
|
|
+ </table>
|
|
|
|
|
+ <?php
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
?>
|
|
?>
|