ILIAS  trunk Revision v11.0_alpha-1715-g7fc467680fb
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
custom.php
Go to the documentation of this file.
1 <?php
2 
19 declare(strict_types=1);
20 
22 
26 
35 function custom()
36 {
37  //Loading factories
38  global $DIC;
39  $f = $DIC->ui()->factory();
40  $df = new \ILIAS\Data\Factory();
41  $renderer = $DIC->ui()->renderer();
42 
43  //Generating Dimensions
44  $c_dimension = $df->dimension()->cardinal();
45 
46  //Generating Dataset with points and tooltips
47  $dataset = $df->dataset([
48  "Dataset 1" => $c_dimension,
49  "Dataset 2" => $c_dimension,
50  "Dataset 3" => $c_dimension,
51  ]);
52 
53  $dataset = $dataset->withPoint(
54  "Item 1",
55  [
56  "Dataset 1" => 75,
57  "Dataset 2" => 80,
58  "Dataset 3" => 100
59  ]
60  );
61  $dataset = $dataset->withPoint(
62  "Item 2",
63  [
64  "Dataset 1" => 45,
65  "Dataset 2" => 30,
66  "Dataset 3" => 90
67  ]
68  );
69  $dataset = $dataset->withPoint(
70  "Item 3",
71  [
72  "Dataset 1" => 50,
73  "Dataset 2" => 100,
74  "Dataset 3" => 65.5
75  ]
76  );
77 
78  //Generating Bar Configurations
79  $b1 = new BarConfig();
80  $b1 = $b1->withColor($df->color("#12436D"));
81  $b2 = new BarConfig();
82  $b2 = $b2->withColor($df->color("#28A197"));
83  $b3 = new BarConfig();
84  $b3 = $b3->withColor($df->color("#801650"));
85 
86  $bars = [
87  "Dataset 1" => $b1,
88  "Dataset 2" => $b2,
89  "Dataset 3" => $b3
90  ];
91 
92  //Generating and rendering the vertical chart
93  $bar = $f->chart()->bar()->vertical(
94  "A vertical bar chart",
95  $dataset,
96  $bars
97  );
98  $bar = $bar->withTitleVisible(false);
99  $bar = $bar->withLegendPosition("left");
100  $y_axis = new YAxis();
101  $y_axis = $y_axis->withPosition("right");
102  $y_axis = $y_axis->withStepSize(10);
103  $y_axis = $y_axis->withBeginAtZero(false);
104  $bar = $bar->withCustomYAxis($y_axis);
105 
106  // render
107  return $renderer->render($bar);
108 }
$renderer
global $DIC
Definition: shib_login.php:22
custom()
expected output: > ILIAS shows a base column-chart but customized.
Definition: custom.php:35