Skip to content

Instantly share code, notes, and snippets.

@userneeds-ahe
Last active March 11, 2022 06:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save userneeds-ahe/80b008ceeaa2abc85f97eaed24dcae3e to your computer and use it in GitHub Desktop.
Save userneeds-ahe/80b008ceeaa2abc85f97eaed24dcae3e to your computer and use it in GitHub Desktop.
createChartSeries
<?php
// file: https://filebin.net/tgroei6wb1fbn48s
namespace Userneeds\Reporting\Services\Powerpoint\Aspose;
use Aspose\Slides\Cloud\Sdk\Api\SlidesApi;
use Aspose\Slides\Cloud\Sdk\Model\OneValueChartDataPoint;
use Aspose\Slides\Cloud\Sdk\Model\OneValueSeries;
class Chart extends AsposeApi
{
protected $api;
/**
* Add series to slide chart at index
* @param string $file_name
* @param int $slideIndex
* @param array $values
* @param int $chartIndex
* @return int The final series count.
* @throws \Aspose\Slides\Cloud\Sdk\Api\ApiException
*/
public function addChartSeries(
string $file_name,
// array $values,
int $slideIndex,
int $chartIndex = 0,
int $seriesIndex = null
): int {
// Override
$this->api = new SlidesApi();
$slideIndex = 2;
$values = [11, 12, 13];
$dto = new OneValueSeries();
$dataPoints = [];
foreach ($values as $value) {
$dataPoint = new OneValueChartDataPoint();
$dataPoint->setValue($value);
$dataPoints[] = $dataPoint;
}
$dto->setDataPoints($dataPoints);
$result = $this->api()->createChartSeries($file_name, $slideIndex, $chartIndex, $dto);
return count($result->getSeries());
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment