二维圆环图

圆环图 - 图1

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