ILIAS  release_10 Revision v10.1-43-ga1241a92c2f
custom.php
Go to the documentation of this file.
1 <?php
2 
3 declare(strict_types=1);
4 
6 
10 
19 function custom()
20 {
21  //Loading factories
22  global $DIC;
23  $f = $DIC->ui()->factory();
24  $df = new \ILIAS\Data\Factory();
25  $renderer = $DIC->ui()->renderer();
26 
27  //Generating Dimensions
28  $c_dimension = $df->dimension()->cardinal();
29 
30  //Generating Dataset with points and tooltips
31  $dataset = $df->dataset([
32  "Dataset 1" => $c_dimension,
33  "Dataset 2" => $c_dimension,
34  "Dataset 3" => $c_dimension,
35  ]);
36 
37  $dataset = $dataset->withPoint(
38  "Item 1",
39  [
40  "Dataset 1" => 75,
41  "Dataset 2" => 80,
42  "Dataset 3" => 100
43  ]
44  );
45  $dataset = $dataset->withPoint(
46  "Item 2",
47  [
48  "Dataset 1" => 45,
49  "Dataset 2" => 30,
50  "Dataset 3" => 90
51  ]
52  );
53  $dataset = $dataset->withPoint(
54  "Item 3",
55  [
56  "Dataset 1" => 50,
57  "Dataset 2" => 100,
58  "Dataset 3" => 65.5
59  ]
60  );
61 
62  //Generating Bar Configurations
63  $b1 = new BarConfig();
64  $b1 = $b1->withColor($df->color("#12436D"));
65  $b2 = new BarConfig();
66  $b2 = $b2->withColor($df->color("#28A197"));
67  $b3 = new BarConfig();
68  $b3 = $b3->withColor($df->color("#801650"));
69 
70  $bars = [
71  "Dataset 1" => $b1,
72  "Dataset 2" => $b2,
73  "Dataset 3" => $b3
74  ];
75 
76  //Generating and rendering the vertical chart
77  $bar = $f->chart()->bar()->vertical(
78  "A vertical bar chart",
79  $dataset,
80  $bars
81  );
82  $bar = $bar->withTitleVisible(false);
83  $bar = $bar->withLegendPosition("left");
84  $y_axis = new YAxis();
85  $y_axis = $y_axis->withPosition("right");
86  $y_axis = $y_axis->withStepSize(10);
87  $y_axis = $y_axis->withBeginAtZero(false);
88  $bar = $bar->withCustomYAxis($y_axis);
89 
90  // render
91  return $renderer->render($bar);
92 }
$renderer
global $DIC
Definition: shib_login.php:25
custom()
expected output: > ILIAS shows a base column-chart but customized.
Definition: custom.php:19