Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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