19 declare(strict_types=1);
21 require_once(__DIR__ .
"/../../../../../../../vendor/composer/vendor/autoload.php");
22 require_once(__DIR__ .
"/../../../Base.php");
34 return new I\Component\Chart\Bar\Factory();
45 public function listing(): I\Component\Listing\Factory
47 return new I\Component\Listing\Factory();
56 $c_dimension = $df->dimension()->cardinal();
58 $dataset = $df->dataset([
"Dataset" => $c_dimension]);
59 $dataset = $dataset->withPoint(
"Item", [
"Dataset" => 0]);
68 $c_dimension = $df->dimension()->cardinal();
69 $t_dimension = $df->dimension()->range($c_dimension);
71 $dataset = $df->dataset([
"Dataset 1" => $c_dimension,
"Dataset 2" => $t_dimension]);
72 $dataset = $dataset->withPoint(
"Item 1", [
"Dataset 1" => -1.25,
"Dataset 2" => [-2, -1]]);
73 $dataset = $dataset->withPoint(
"Item 2", [
"Dataset 1" => null,
"Dataset 2" => [0, 0.5]]);
82 $this->assertInstanceOf(
"ILIAS\\UI\\Component\\Chart\\Bar\\Factory",
$f);
91 $horizontal =
$f->horizontal(
96 $this->assertInstanceOf(
"ILIAS\\UI\\Component\\Chart\\Bar\\Bar", $horizontal);
97 $this->assertInstanceOf(
"ILIAS\\UI\\Component\\Chart\\Bar\\Horizontal", $horizontal);
99 $vertical =
$f->vertical(
103 $this->assertInstanceOf(
"ILIAS\\UI\\Component\\Chart\\Bar\\Bar", $vertical);
104 $this->assertInstanceOf(
"ILIAS\\UI\\Component\\Chart\\Bar\\Vertical", $vertical);
112 $c_dimension = $df->dimension()->cardinal();
114 $dataset = $df->dataset([
"Dataset" => $c_dimension]);
116 $this->expectException(LogicException::class);
117 $this->expectExceptionMessage(
"Dataset must not be empty.");
118 $horizontal =
$f->horizontal(
150 $horizontal =
$f->horizontal(
154 $horizontal1 = $horizontal->withTitle(
"Alternative title for Horizontal Bar");
156 $this->assertEquals(
"Horizontal Bar", $horizontal->getTitle());
157 $this->assertEquals(
"Alternative title for Horizontal Bar", $horizontal1->getTitle());
166 $horizontal =
$f->horizontal(
170 $horizontal1 = $horizontal->withTitleVisible(
false);
172 $this->assertEquals(
true, $horizontal->isTitleVisible());
173 $this->assertEquals(
false, $horizontal1->isTitleVisible());
182 $horizontal =
$f->horizontal(
186 $horizontal1 = $horizontal->withTooltipsVisible(
false);
188 $this->assertEquals(
true, $horizontal->isTooltipsVisible());
189 $this->assertEquals(
false, $horizontal1->isTooltipsVisible());
198 $horizontal =
$f->horizontal(
202 $horizontal1 = $horizontal->withLegendVisible(
false);
204 $this->assertEquals(
true, $horizontal->isLegendVisible());
205 $this->assertEquals(
false, $horizontal1->isLegendVisible());
214 $horizontal =
$f->horizontal(
218 $horizontal1 = $horizontal->withLegendPosition(
"left");
220 $this->assertEquals(
"top", $horizontal->getLegendPosition());
221 $this->assertEquals(
"left", $horizontal1->getLegendPosition());
230 $horizontal =
$f->horizontal(
235 $this->expectException(InvalidArgumentException::class);
236 $this->expectExceptionMessage(
"Position must be 'bottom', 'top', 'left' or 'right'.");
238 $horizontal = $horizontal->withLegendPosition(
"middle");
248 $horizontal =
$f->horizontal(
252 $horizontal1 = $horizontal->withDataset($e_dataset);
254 $this->assertEquals($s_dataset, $horizontal->getDataset());
255 $this->assertEquals($e_dataset, $horizontal1->getDataset());
265 $bc =
new C\Chart\Bar\BarConfig();
266 $bc = $bc->withColor($df->color(
"#d38000"));
272 $horizontal =
$f->horizontal(
276 $horizontal1 = $horizontal->withBarConfigs($bars);
278 $this->assertEquals([], $horizontal->getBarConfigs());
279 $this->assertEquals($bars, $horizontal1->getBarConfigs());
289 $gc =
new C\Chart\Bar\GroupConfig();
290 $gc = $gc->withStacked();
296 $horizontal =
$f->horizontal(
300 $horizontal1 = $horizontal->withGroupConfigs($groups);
302 $this->assertEquals([], $horizontal->getGroupConfigs());
303 $this->assertEquals($groups, $horizontal1->getGroupConfigs());
313 $horizontal =
$f->horizontal(
318 $this->assertEquals(
"y", $horizontal->getIndexAxis());
320 $vertical =
$f->vertical(
325 $this->assertEquals(
"x", $vertical->getIndexAxis());
330 $r = $this->getDefaultRenderer();
335 $horizontal =
$f->horizontal(
340 $html =
$r->render($horizontal);
342 $expected_html = <<<EOT
343 <div
class=
"il-chart-bar-horizontal">
344 <canvas
id=
"id_1" height=
"150px" aria-label=
"bar123" role=
"img"></canvas>
346 <div
class=
"sr-only">
358 $this->assertHTMLEquals(
"<div>" . $expected_html .
"</div>",
"<div>" . $html .
"</div>");
363 $r = $this->getDefaultRenderer();
368 $vertical =
$f->vertical(
373 $html =
$r->render($vertical);
375 $expected_html = <<<EOT
376 <div
class=
"il-chart-bar-vertical">
377 <canvas
id=
"id_1" height=
"165px" aria-label=
"bar123" role=
"img"></canvas>
379 <div
class=
"sr-only">
384 <li>Item 1: -1.25</li>
391 <li>Item 1: -2 - -1</li>
392 <li>Item 2: 0 - 0.5</li>
399 $this->assertHTMLEquals(
"<div>" . $expected_html .
"</div>",
"<div>" . $html .
"</div>");
testImplementsFactoryInterface()
Test on Bar Chart implementation.
Interface Observer Contains several chained tasks and infos about them.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
testWithLegendInvisible()
testWithTooltipsInvisible()
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
testWithInvalidLegendPosition()