‪TYPO3CMS  10.4
BarChartWidget.php
Go to the documentation of this file.
1 <?php
2 
3 declare(strict_types=1);
4 
5 /*
6  * This file is part of the TYPO3 CMS project.
7  *
8  * It is free software; you can redistribute it and/or modify it under
9  * the terms of the GNU General Public License, either version 2
10  * of the License, or any later version.
11  *
12  * For the full copyright and license information, please read the
13  * LICENSE.txt file that was distributed with this source code.
14  *
15  * The TYPO3 project - inspiring people to share!
16  */
17 
19 
21 
34 {
38  private ‪$configuration;
39 
43  private ‪$dataProvider;
44 
48  private ‪$view;
49 
54 
58  private ‪$options;
59 
60  public function ‪__construct(
64  ‪$buttonProvider = null,
65  array ‪$options = []
66  ) {
67  $this->configuration = ‪$configuration;
68  $this->dataProvider = ‪$dataProvider;
69  $this->view = ‪$view;
70  $this->options = ‪$options;
71  $this->buttonProvider = ‪$buttonProvider;
72  }
73 
74  public function ‪renderWidgetContent(): string
75  {
76  $this->view->setTemplate('Widget/ChartWidget');
77  $this->view->assignMultiple([
78  'button' => $this->buttonProvider,
79  'options' => $this->options,
80  'configuration' => $this->configuration,
81  ]);
82  return $this->view->render();
83  }
84 
85  public function ‪getEventData(): array
86  {
87  return [
88  'graphConfig' => [
89  'type' => 'bar',
90  'options' => [
91  'maintainAspectRatio' => false,
92  'legend' => [
93  'display' => false,
94  ],
95  'scales' => [
96  'yAxes' => [
97  [
98  'ticks' => [
99  'beginAtZero' => true,
100  ],
101  ],
102  ],
103  'xAxes' => [
104  [
105  'ticks' => [
106  'maxTicksLimit' => 15,
107  ],
108  ],
109  ],
110  ],
111  ],
112  'data' => $this->dataProvider->getChartData(),
113  ],
114  ];
115  }
116 
117  public function ‪getCssFiles(): array
118  {
119  return ['EXT:dashboard/Resources/Public/Css/Contrib/chart.css'];
120  }
121 
122  public function ‪getRequireJsModules(): array
123  {
124  return [
125  'TYPO3/CMS/Dashboard/Contrib/chartjs',
126  'TYPO3/CMS/Dashboard/ChartInitializer',
127  ];
128  }
129 }
‪TYPO3\CMS\Dashboard\Widgets\AdditionalCssInterface
Definition: AdditionalCssInterface.php:24
‪TYPO3\CMS\Dashboard\Widgets\WidgetInterface
Definition: WidgetInterface.php:26
‪TYPO3\CMS\Dashboard\Widgets\BarChartWidget\renderWidgetContent
‪renderWidgetContent()
Definition: BarChartWidget.php:69
‪TYPO3\CMS\Dashboard\Widgets\BarChartWidget\$view
‪StandaloneView $view
Definition: BarChartWidget.php:45
‪TYPO3\CMS\Dashboard\Widgets\BarChartWidget\getEventData
‪getEventData()
Definition: BarChartWidget.php:80
‪TYPO3\CMS\Dashboard\Widgets\BarChartWidget\$dataProvider
‪ChartDataProviderInterface $dataProvider
Definition: BarChartWidget.php:41
‪TYPO3\CMS\Dashboard\Widgets\BarChartWidget
Definition: BarChartWidget.php:34
‪TYPO3\CMS\Dashboard\Widgets\ChartDataProviderInterface
Definition: ChartDataProviderInterface.php:24
‪TYPO3\CMS\Dashboard\Widgets\BarChartWidget\$configuration
‪WidgetConfigurationInterface $configuration
Definition: BarChartWidget.php:37
‪TYPO3\CMS\Dashboard\Widgets\BarChartWidget\$buttonProvider
‪ButtonProviderInterface null $buttonProvider
Definition: BarChartWidget.php:49
‪TYPO3\CMS\Fluid\View\StandaloneView
Definition: StandaloneView.php:34
‪TYPO3\CMS\Dashboard\Widgets\BarChartWidget\getRequireJsModules
‪getRequireJsModules()
Definition: BarChartWidget.php:117
‪TYPO3\CMS\Dashboard\Widgets\EventDataInterface
Definition: EventDataInterface.php:24
‪TYPO3\CMS\Dashboard\Widgets
Definition: AdditionalCssInterface.php:18
‪TYPO3\CMS\Dashboard\Widgets\ButtonProviderInterface
Definition: ButtonProviderInterface.php:24
‪TYPO3\CMS\Dashboard\Widgets\WidgetConfigurationInterface
Definition: WidgetConfigurationInterface.php:26
‪TYPO3\CMS\Dashboard\Widgets\BarChartWidget\$options
‪array $options
Definition: BarChartWidget.php:53
‪TYPO3\CMS\Dashboard\Widgets\BarChartWidget\getCssFiles
‪getCssFiles()
Definition: BarChartWidget.php:112
‪TYPO3\CMS\Dashboard\Widgets\BarChartWidget\__construct
‪__construct(WidgetConfigurationInterface $configuration, ChartDataProviderInterface $dataProvider, StandaloneView $view, $buttonProvider=null, array $options=[])
Definition: BarChartWidget.php:55
‪TYPO3\CMS\Dashboard\Widgets\RequireJsModuleInterface
Definition: RequireJsModuleInterface.php:24