‪TYPO3CMS  11.5
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 
22 
35 {
39  private ‪$configuration;
40 
44  private ‪$dataProvider;
45 
49  private ‪$view;
50 
55 
59  private ‪$options;
60 
61  public function ‪__construct(
65  ‪$buttonProvider = null,
66  array ‪$options = []
67  ) {
68  $this->configuration = ‪$configuration;
69  $this->dataProvider = ‪$dataProvider;
70  $this->view = ‪$view;
71  $this->options = ‪$options;
72  $this->buttonProvider = ‪$buttonProvider;
73  }
74 
75  public function ‪renderWidgetContent(): string
76  {
77  $this->view->setTemplate('Widget/ChartWidget');
78  $this->view->assignMultiple([
79  'button' => $this->buttonProvider,
80  'options' => $this->options,
81  'configuration' => $this->configuration,
82  ]);
83  return $this->view->render();
84  }
85 
86  public function ‪getEventData(): array
87  {
88  return [
89  'graphConfig' => [
90  'type' => 'bar',
91  'options' => [
92  'maintainAspectRatio' => false,
93  'legend' => [
94  'display' => false,
95  ],
96  'scales' => [
97  'yAxes' => [
98  [
99  'ticks' => [
100  'beginAtZero' => true,
101  ],
102  ],
103  ],
104  'xAxes' => [
105  [
106  'ticks' => [
107  'maxTicksLimit' => 15,
108  ],
109  ],
110  ],
111  ],
112  ],
113  'data' => $this->dataProvider->getChartData(),
114  ],
115  ];
116  }
117 
118  public function ‪getCssFiles(): array
119  {
120  return ['EXT:dashboard/Resources/Public/Css/Contrib/chart.css'];
121  }
122 
123  public function ‪getJavaScriptModuleInstructions(): array
124  {
125  return [
126  ‪JavaScriptModuleInstruction::forRequireJS('TYPO3/CMS/Dashboard/Contrib/chartjs'),
127  ‪JavaScriptModuleInstruction::forRequireJS('TYPO3/CMS/Dashboard/ChartInitializer'),
128  ];
129  }
130 
134  public function ‪getOptions(): array
135  {
136  return ‪$this->options;
137  }
138 }
‪TYPO3\CMS\Dashboard\Widgets\BarChartWidget\getOptions
‪array getOptions()
Definition: BarChartWidget.php: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:70
‪TYPO3\CMS\Core\Page\JavaScriptModuleInstruction
Definition: JavaScriptModuleInstruction.php:23
‪TYPO3\CMS\Core\Page\JavaScriptModuleInstruction\forRequireJS
‪static self forRequireJS(string $name, string $exportName=null)
Definition: JavaScriptModuleInstruction.php:49
‪TYPO3\CMS\Dashboard\Widgets\BarChartWidget\$view
‪StandaloneView $view
Definition: BarChartWidget.php:46
‪TYPO3\CMS\Dashboard\Widgets\BarChartWidget\getEventData
‪getEventData()
Definition: BarChartWidget.php:81
‪TYPO3\CMS\Dashboard\Widgets\BarChartWidget\$dataProvider
‪ChartDataProviderInterface $dataProvider
Definition: BarChartWidget.php:42
‪TYPO3\CMS\Dashboard\Widgets\BarChartWidget
Definition: BarChartWidget.php:35
‪TYPO3\CMS\Dashboard\Widgets\ChartDataProviderInterface
Definition: ChartDataProviderInterface.php:24
‪TYPO3\CMS\Dashboard\Widgets\BarChartWidget\getJavaScriptModuleInstructions
‪getJavaScriptModuleInstructions()
Definition: BarChartWidget.php:118
‪TYPO3\CMS\Dashboard\Widgets\BarChartWidget\$configuration
‪WidgetConfigurationInterface $configuration
Definition: BarChartWidget.php:38
‪TYPO3\CMS\Dashboard\Widgets\BarChartWidget\$buttonProvider
‪ButtonProviderInterface null $buttonProvider
Definition: BarChartWidget.php:50
‪TYPO3\CMS\Fluid\View\StandaloneView
Definition: StandaloneView.php:31
‪TYPO3\CMS\Dashboard\Widgets\EventDataInterface
Definition: EventDataInterface.php:24
‪TYPO3\CMS\Dashboard\Widgets\JavaScriptInterface
Definition: JavaScriptInterface.php:26
‪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:54
‪TYPO3\CMS\Dashboard\Widgets\BarChartWidget\getCssFiles
‪getCssFiles()
Definition: BarChartWidget.php:113
‪TYPO3\CMS\Dashboard\Widgets\BarChartWidget\__construct
‪__construct(WidgetConfigurationInterface $configuration, ChartDataProviderInterface $dataProvider, StandaloneView $view, $buttonProvider=null, array $options=[])
Definition: BarChartWidget.php:56