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(
49 new I\
Component\Listing\CharacteristicValue\Factory(),
60 $c_dimension = $df->dimension()->cardinal();
62 $dataset = $df->dataset([
"Dataset" => $c_dimension]);
63 $dataset = $dataset->withPoint(
"Item", [
"Dataset" => 0]);
72 $c_dimension = $df->dimension()->cardinal();
73 $t_dimension = $df->dimension()->range($c_dimension);
75 $dataset = $df->dataset([
"Dataset 1" => $c_dimension,
"Dataset 2" => $t_dimension]);
76 $dataset = $dataset->withPoint(
"Item 1", [
"Dataset 1" => -1.25,
"Dataset 2" => [-2, -1]]);
77 $dataset = $dataset->withPoint(
"Item 2", [
"Dataset 1" =>
null,
"Dataset 2" => [0, 0.5]]);
86 $this->assertInstanceOf(
"ILIAS\\UI\\Component\\Chart\\Bar\\Factory",
$f);
95 $horizontal =
$f->horizontal(
100 $this->assertInstanceOf(
"ILIAS\\UI\\Component\\Chart\\Bar\\Bar", $horizontal);
101 $this->assertInstanceOf(
"ILIAS\\UI\\Component\\Chart\\Bar\\Horizontal", $horizontal);
103 $vertical =
$f->vertical(
107 $this->assertInstanceOf(
"ILIAS\\UI\\Component\\Chart\\Bar\\Bar", $vertical);
108 $this->assertInstanceOf(
"ILIAS\\UI\\Component\\Chart\\Bar\\Vertical", $vertical);
116 $c_dimension = $df->dimension()->cardinal();
118 $dataset = $df->dataset([
"Dataset" => $c_dimension]);
120 $this->expectException(LogicException::class);
121 $this->expectExceptionMessage(
"Dataset must not be empty.");
122 $horizontal =
$f->horizontal(
154 $horizontal =
$f->horizontal(
158 $horizontal1 = $horizontal->withTitle(
"Alternative title for Horizontal Bar");
160 $this->assertEquals(
"Horizontal Bar", $horizontal->getTitle());
161 $this->assertEquals(
"Alternative title for Horizontal Bar", $horizontal1->getTitle());
170 $horizontal =
$f->horizontal(
174 $horizontal1 = $horizontal->withTitleVisible(
false);
176 $this->assertEquals(
true, $horizontal->isTitleVisible());
177 $this->assertEquals(
false, $horizontal1->isTitleVisible());
186 $horizontal =
$f->horizontal(
190 $horizontal1 = $horizontal->withTooltipsVisible(
false);
192 $this->assertEquals(
true, $horizontal->isTooltipsVisible());
193 $this->assertEquals(
false, $horizontal1->isTooltipsVisible());
202 $horizontal =
$f->horizontal(
206 $horizontal1 = $horizontal->withLegendVisible(
false);
208 $this->assertEquals(
true, $horizontal->isLegendVisible());
209 $this->assertEquals(
false, $horizontal1->isLegendVisible());
218 $horizontal =
$f->horizontal(
222 $horizontal1 = $horizontal->withLegendPosition(
"left");
224 $this->assertEquals(
"top", $horizontal->getLegendPosition());
225 $this->assertEquals(
"left", $horizontal1->getLegendPosition());
234 $horizontal =
$f->horizontal(
239 $this->expectException(InvalidArgumentException::class);
240 $this->expectExceptionMessage(
"Position must be 'bottom', 'top', 'left' or 'right'.");
242 $horizontal = $horizontal->withLegendPosition(
"middle");
252 $horizontal =
$f->horizontal(
256 $horizontal1 = $horizontal->withDataset($e_dataset);
258 $this->assertEquals($s_dataset, $horizontal->getDataset());
259 $this->assertEquals($e_dataset, $horizontal1->getDataset());
269 $bc =
new C\Chart\Bar\BarConfig();
270 $bc = $bc->withColor($df->color(
"#d38000"));
276 $horizontal =
$f->horizontal(
280 $horizontal1 = $horizontal->withBarConfigs($bars);
282 $this->assertEquals([], $horizontal->getBarConfigs());
283 $this->assertEquals($bars, $horizontal1->getBarConfigs());
293 $gc =
new C\Chart\Bar\GroupConfig();
294 $gc = $gc->withStacked();
300 $horizontal =
$f->horizontal(
304 $horizontal1 = $horizontal->withGroupConfigs($groups);
306 $this->assertEquals([], $horizontal->getGroupConfigs());
307 $this->assertEquals($groups, $horizontal1->getGroupConfigs());
317 $horizontal =
$f->horizontal(
322 $this->assertEquals(
"y", $horizontal->getIndexAxis());
324 $vertical =
$f->vertical(
329 $this->assertEquals(
"x", $vertical->getIndexAxis());
334 $r = $this->getDefaultRenderer();
339 $horizontal =
$f->horizontal(
344 $html =
$r->render($horizontal);
346 $expected_html = <<<EOT
347 <div
class=
"il-chart-bar-horizontal">
348 <canvas
id=
"id_1" height=
"150px" aria-label=
"bar123" role=
"img"></canvas>
350 <div
class=
"sr-only">
362 $this->assertHTMLEquals(
"<div>" . $expected_html .
"</div>",
"<div>" . $html .
"</div>");
367 $r = $this->getDefaultRenderer();
372 $vertical =
$f->vertical(
377 $html =
$r->render($vertical);
379 $expected_html = <<<EOT
380 <div
class=
"il-chart-bar-vertical">
381 <canvas
id=
"id_1" height=
"165px" aria-label=
"bar123" role=
"img"></canvas>
383 <div
class=
"sr-only">
388 <li>Item 1: -1.25</li>
395 <li>Item 1: -2 - -1</li>
396 <li>Item 2: 0 - 0.5</li>
403 $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.
testWithLegendInvisible()
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
testWithTooltipsInvisible()
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
testWithInvalidLegendPosition()