Doughnut chart

2D ring chart

1
<?php declare(strict_types = 1);
2
3
$config = [
4
'path' => './tests',
5
];
6
7
$dataHeader = [
8
'Category', 'Values',
9
];
10
11
$dataRows = [
12
['Glazed', 50],
13
['Chocolate', 35],
14
['Cream', 15],
15
];
16
17
$fileObject = new \Vtiful\Kernel\Excel($config);
18
19
$fileObject = $fileObject->fileName('tutorial.xlsx');
20
$fileHandle = $fileObject->getHandle();
21
22
$chart = new \Vtiful\Kernel\Chart($fileHandle, \Vtiful\Kernel\Chart::CHART_DOUGHNUT);
23
24
$chartResource = $chart
25
// series(string $value [, string $category])
26
->series('=Sheet1!$B$2:$B$4', '=Sheet1!$A$2:$A$4')
27
->seriesName('Doughnut sales data')
28
->title('Popular Doughnut Types')
29
->style(10)
30
->toResource();
31
32
$filePath = $fileObject
33
->header($dataHeader)
34
->data($dataRows)
35
->insertChart(0, 4, $chartResource)
36
->output();
Copied!
Last modified 2yr ago
Copy link