-
-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathExampleDoughnutChart.php
43 lines (36 loc) · 1.14 KB
/
ExampleDoughnutChart.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
<?php
namespace Fidum\ChartTile\Examples;
use Fidum\ChartTile\Charts\Chart;
use Fidum\ChartTile\Contracts\ChartFactory;
class ExampleDoughnutChart implements ChartFactory
{
public static function make(array $settings): ChartFactory
{
return new static;
}
public function chart(): Chart
{
$chart = new Chart();
$data = [rand(5, 20), rand(20, 40), rand(5, 30)];
$data[] = 100 - array_sum($data);
$chart->labels(['Tea', 'Coffee', 'Soda', 'Juice'])
->options([
'responsive' => true,
'maintainAspectRatio' => true,
'animation' => [
'duration' => 0,
],
'legend' => [
'display' => true,
'position' => 'right',
],
'scales' => [
'xAxes' => ['display' => false],
'yAxes' => ['display' => false],
],
])
->dataset('Drinks', 'doughnut', $data)
->backgroundColor(['#FF9CEE', '#B28DFF', '#6EB5FF', '#BFFCC6']);
return $chart;
}
}