‪TYPO3CMS  11.5
DoughnutChartWidget.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' => 'doughnut',
91  'options' => [
92  'maintainAspectRatio' => false,
93  'legend' => [
94  'display' => true,
95  'position' => 'bottom',
96  ],
97  'cutoutPercentage' => 60,
98  ],
99  'data' => $this->dataProvider->getChartData(),
100  ],
101  ];
102  }
103 
104  public function ‪getCssFiles(): array
105  {
106  return ['EXT:dashboard/Resources/Public/Css/Contrib/chart.css'];
107  }
108 
109  public function ‪getJavaScriptModuleInstructions(): array
110  {
111  return [
112  ‪JavaScriptModuleInstruction::forRequireJS('TYPO3/CMS/Dashboard/Contrib/chartjs'),
113  ‪JavaScriptModuleInstruction::forRequireJS('TYPO3/CMS/Dashboard/ChartInitializer'),
114  ];
115  }
116 
120  public function ‪getOptions(): array
121  {
122  return ‪$this->options;
123  }
124 }
‪TYPO3\CMS\Dashboard\Widgets\DoughnutChartWidget\getOptions
‪array getOptions()
Definition: DoughnutChartWidget.php:115
‪TYPO3\CMS\Dashboard\Widgets\AdditionalCssInterface
Definition: AdditionalCssInterface.php:24
‪TYPO3\CMS\Dashboard\Widgets\WidgetInterface
Definition: WidgetInterface.php:26
‪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\DoughnutChartWidget\$options
‪array $options
Definition: DoughnutChartWidget.php:54
‪TYPO3\CMS\Dashboard\Widgets\DoughnutChartWidget\__construct
‪__construct(WidgetConfigurationInterface $configuration, ChartDataProviderInterface $dataProvider, StandaloneView $view, $buttonProvider=null, array $options=[])
Definition: DoughnutChartWidget.php:56
‪TYPO3\CMS\Dashboard\Widgets\DoughnutChartWidget\getEventData
‪getEventData()
Definition: DoughnutChartWidget.php:81
‪TYPO3\CMS\Dashboard\Widgets\DoughnutChartWidget\$dataProvider
‪ChartDataProviderInterface $dataProvider
Definition: DoughnutChartWidget.php:42
‪TYPO3\CMS\Dashboard\Widgets\ChartDataProviderInterface
Definition: ChartDataProviderInterface.php:24
‪TYPO3\CMS\Dashboard\Widgets\DoughnutChartWidget\getJavaScriptModuleInstructions
‪getJavaScriptModuleInstructions()
Definition: DoughnutChartWidget.php:104
‪TYPO3\CMS\Fluid\View\StandaloneView
Definition: StandaloneView.php:31
‪TYPO3\CMS\Dashboard\Widgets\DoughnutChartWidget\$view
‪StandaloneView $view
Definition: DoughnutChartWidget.php:46
‪TYPO3\CMS\Dashboard\Widgets\DoughnutChartWidget
Definition: DoughnutChartWidget.php:35
‪TYPO3\CMS\Dashboard\Widgets\DoughnutChartWidget\renderWidgetContent
‪renderWidgetContent()
Definition: DoughnutChartWidget.php:70
‪TYPO3\CMS\Dashboard\Widgets\EventDataInterface
Definition: EventDataInterface.php:24
‪TYPO3\CMS\Dashboard\Widgets\JavaScriptInterface
Definition: JavaScriptInterface.php:26
‪TYPO3\CMS\Dashboard\Widgets\DoughnutChartWidget\$configuration
‪WidgetConfigurationInterface $configuration
Definition: DoughnutChartWidget.php:38
‪TYPO3\CMS\Dashboard\Widgets\DoughnutChartWidget\getCssFiles
‪getCssFiles()
Definition: DoughnutChartWidget.php:99
‪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\DoughnutChartWidget\$buttonProvider
‪ButtonProviderInterface null $buttonProvider
Definition: DoughnutChartWidget.php:50