面积图

类型

  1. \Vtiful\Kernel\Chart::CHART_AREA

图标

php-excel

实例

  1. <?php
  2.  
  3. $config = ['path' => './tests'];
  4.  
  5. $fileObject = new \Vtiful\Kernel\Excel($config);
  6.  
  7. $fileObject = $fileObject->fileName('tutorial.xlsx');
  8. $fileHandle = $fileObject->getHandle();
  9.  
  10. $chart = new \Vtiful\Kernel\Chart($fileHandle, \Vtiful\Kernel\Chart::CHART_AREA);
  11.  
  12. $chartResource = $chart
  13. ->series('=Sheet1!$B$2:$B$7', '=Sheet1!$A$2:$A$7')
  14. ->seriesName('=Sheet1!$B$1')
  15. ->series('=Sheet1!$C$2:$C$7', '=Sheet1!$A$2:$A$7')
  16. ->seriesName('=Sheet1!$C$1')
  17. ->style(11)// 值为 1 - 48,可参考 Excel 2007 "设计" 选项卡中的 48 种样式
  18. ->axisNameX('Test number') // 设置 X 轴名称
  19. ->axisNameY('Sample length (mm)') // 设置 Y 轴名称
  20. ->title('Results of sample analysis') // 设置图表 Title
  21. ->toResource();
  22.  
  23. $filePath = $fileObject->header(['Number', 'Batch 1', 'Batch 2'])
  24. ->data([
  25. [2, 40, 30],
  26. [3, 40, 25],
  27. [4, 50, 30],
  28. [5, 30, 10],
  29. [6, 25, 5],
  30. [7, 50, 10],
  31. ])->insertChart(0, 3, $chartResource)->output();