‪TYPO3CMS  10.4
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 
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' => 'doughnut',
90  'options' => [
91  'maintainAspectRatio' => false,
92  'legend' => [
93  'display' => true,
94  'position' => 'bottom'
95  ],
96  'cutoutPercentage' => 60
97  ],
98  'data' => $this->dataProvider->getChartData(),
99  ],
100  ];
101  }
102 
103  public function ‪getCssFiles(): array
104  {
105  return ['EXT:dashboard/Resources/Public/Css/Contrib/chart.css'];
106  }
107 
108  public function ‪getRequireJsModules(): array
109  {
110  return [
111  'TYPO3/CMS/Dashboard/Contrib/chartjs',
112  'TYPO3/CMS/Dashboard/ChartInitializer',
113  ];
114  }
115 }
‪TYPO3\CMS\Dashboard\Widgets\AdditionalCssInterface
Definition: AdditionalCssInterface.php:24
‪TYPO3\CMS\Dashboard\Widgets\DoughnutChartWidget\getRequireJsModules
‪getRequireJsModules()
Definition: DoughnutChartWidget.php:103
‪TYPO3\CMS\Dashboard\Widgets\WidgetInterface
Definition: WidgetInterface.php:26
‪TYPO3\CMS\Dashboard\Widgets\DoughnutChartWidget\$options
‪array $options
Definition: DoughnutChartWidget.php:53
‪TYPO3\CMS\Dashboard\Widgets\DoughnutChartWidget\__construct
‪__construct(WidgetConfigurationInterface $configuration, ChartDataProviderInterface $dataProvider, StandaloneView $view, $buttonProvider=null, array $options=[])
Definition: DoughnutChartWidget.php:55
‪TYPO3\CMS\Dashboard\Widgets\DoughnutChartWidget\getEventData
‪getEventData()
Definition: DoughnutChartWidget.php:80
‪TYPO3\CMS\Dashboard\Widgets\DoughnutChartWidget\$dataProvider
‪ChartDataProviderInterface $dataProvider
Definition: DoughnutChartWidget.php:41
‪TYPO3\CMS\Dashboard\Widgets\ChartDataProviderInterface
Definition: ChartDataProviderInterface.php:24
‪TYPO3\CMS\Fluid\View\StandaloneView
Definition: StandaloneView.php:34
‪TYPO3\CMS\Dashboard\Widgets\DoughnutChartWidget\$view
‪StandaloneView $view
Definition: DoughnutChartWidget.php:45
‪TYPO3\CMS\Dashboard\Widgets\DoughnutChartWidget
Definition: DoughnutChartWidget.php:34
‪TYPO3\CMS\Dashboard\Widgets\DoughnutChartWidget\renderWidgetContent
‪renderWidgetContent()
Definition: DoughnutChartWidget.php:69
‪TYPO3\CMS\Dashboard\Widgets\EventDataInterface
Definition: EventDataInterface.php:24
‪TYPO3\CMS\Dashboard\Widgets\DoughnutChartWidget\$configuration
‪WidgetConfigurationInterface $configuration
Definition: DoughnutChartWidget.php:37
‪TYPO3\CMS\Dashboard\Widgets\DoughnutChartWidget\getCssFiles
‪getCssFiles()
Definition: DoughnutChartWidget.php:98
‪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\RequireJsModuleInterface
Definition: RequireJsModuleInterface.php:24
‪TYPO3\CMS\Dashboard\Widgets\DoughnutChartWidget\$buttonProvider
‪ButtonProviderInterface null $buttonProvider
Definition: DoughnutChartWidget.php:49