Update a Chart Data Point Introduction
In PowerPoint presentations, data points are individual values or specific pieces of data that are plotted on a chart. Each data point represents a particular value within a dataset and is typically represented graphically as a marker, bar, line, or other visual element on the chart. Use the following method to update data points of a chart in presentations.
UpdateChartDataPoint
API
Type
Description
Resource
/slides/{name}/slides/{slideIndex}/shapes/{shapeIndex}/series/{seriesIndex}/dataPoints/{pointIndex}
PUT
Updates a data point of a chart in a presentation saved in a storage.
UpdateChartDataPoint
Request Parameters
Name
Type
Location
Required
Description
name
string
path
true
The name of a presentation file.
slideIndex
integer
path
true
The 1-based index of a presentation slide.
shapeIndex
integer
path
true
The 1-based index of a shape (must be a chart).
seriesIndex
integer
path
true
The 1-based index of a data series.
pointIndex
integer
path
true
The 1-based index of a data point.
dataPoint
DataPoint
body
true
The data transfer object of the data point.
password
string
header
false
The password to open the presentation.
folder
string
query
false
The path to the folder containing the presentation file.
storage
string
query
false
The name of the storage contaning the folder.
Examples
In the default storage, the document MyPresentation.pptx contains a scatter chart (the second shape) that displays the number of items sold for quarters 1 through 4 (one data series). Update the sales value for the 2nd quarter to 10 items.
The referenced shape must be a chart, otherwise the operation will fail.
cURL Solution
SDK Solutions
C#
using System ;
using Aspose.Slides.Cloud.Sdk ;
using Aspose.Slides.Cloud.Sdk.Model ;
class Application
{
static void Main ( string [] args )
{
SlidesApi slidesApi = new SlidesApi ( "MyClientId" , "MyClientSecret" );
string fileName = "MyPresentation.pptx" ;
int slideIndex = 1 ;
int shapeIndex = 2 ;
int seriesIndex = 1 ;
int pointIndex = 2 ;
ScatterChartDataPoint dataPoint = new ScatterChartDataPoint
{
XValue = 2 ,
YValue = 10 ,
};
Chart chart = slidesApi . UpdateChartDataPoint ( fileName , slideIndex , shapeIndex , seriesIndex , pointIndex , dataPoint );
ScatterSeries series = ( ScatterSeries ) chart . Series [ 0 ];
int dataPointCount = series . DataPoints . Count ;
Console . WriteLine ( "Number of data points: " + dataPointCount );
}
}
Java
import com.aspose.slides.ApiException ;
import com.aspose.slides.api.SlidesApi ;
import com.aspose.slides.model.ScatterChartDataPoint ;
import com.aspose.slides.model.Chart ;
import com.aspose.slides.model.ScatterSeries ;
public class Application {
public static void main ( String [] args ) throws ApiException {
SlidesApi slidesApi = new SlidesApi ( "MyClientId" , "MyClientSecret" );
String fileName = "MyPresentation.pptx" ;
int slideIndex = 1 ;
int shapeIndex = 2 ;
int seriesIndex = 1 ;
int pointIndex = 2 ;
ScatterChartDataPoint dataPoint = new ScatterChartDataPoint ();
dataPoint . setXvalue ( 2d );
dataPoint . setYvalue ( 10d );
Chart chart = slidesApi . updateChartDataPoint ( fileName , slideIndex , shapeIndex , seriesIndex , pointIndex , dataPoint , null , null , null );
ScatterSeries series = ( ScatterSeries ) chart . getSeries (). get ( 0 );
int dataPointCount = series . getDataPoints (). size ();
System . out . println ( "Number of data points: " + dataPointCount );
}
}
PHP
use Aspose\Slides\Cloud\Sdk\Api\Configuration ;
use Aspose\Slides\Cloud\Sdk\Api\SlidesApi ;
use Aspose\Slides\Cloud\Sdk\Model\ScatterChartDataPoint ;
$configuration = new Configuration ();
$configuration -> setAppSid ( "MyClientId" );
$configuration -> setAppKey ( "MyClientSecret" );
$slidesApi = new SlidesApi ( null , $configuration );
$fileName = "MyPresentation.pptx" ;
$slideIndex = 1 ;
$shapeIndex = 2 ;
$seriesIndex = 1 ;
$pointIndex = 2 ;
$dataPoint = new ScatterChartDataPoint ();
$dataPoint -> setXvalue ( 2 );
$dataPoint -> setYvalue ( 10 );
$chart = $slidesApi -> updateChartDataPoint ( $fileName , $slideIndex , $shapeIndex , $seriesIndex , $pointIndex , $dataPoint );
$dataPointCount = count ( $chart -> getSeries ()[ 0 ] -> getDataPoints ());
echo "Number of data points: " , $dataPointCount ;
Ruby
require "aspose_slides_cloud"
include AsposeSlidesCloud
configuration = Configuration . new
configuration . app_sid = "MyClientId"
configuration . app_key = "MyClientSecret"
slides_api = SlidesApi . new ( configuration )
file_name = "MyPresentation.pptx"
slide_index = 1
shape_index = 2
series_index = 1
point_index = 2
data_point = ScatterChartDataPoint . new
data_point . x_value = 2
data_point . y_value = 10
chart = slides_api . update_chart_data_point ( file_name , slide_index , shape_index , series_index , point_index , data_point )
data_point_count = chart . series [ 0 ]. data_points . length ()
print "Number of data points: " , data_point_count
Python
from asposeslidescloud.apis.slides_api import SlidesApi
from asposeslidescloud.models.scatter_chart_data_point import ScatterChartDataPoint
slides_api = SlidesApi ( None , "MyClientId" , "MyClientSecret" )
file_name = "MyPresentation.pptx"
slide_index = 1
shape_index = 2
series_index = 1
point_index = 2
data_point = ScatterChartDataPoint ()
data_point . x_value = 2
data_point . y_value = 10
chart = slides_api . update_chart_data_point ( file_name , slide_index , shape_index , series_index , point_index , data_point )
data_point_count = len ( chart . series [ 0 ] . data_points )
print ( "Number of data points:" , data_point_count )
Node.js
const cloudSdk = require ( "asposeslidescloud" );
const slidesApi = new cloudSdk . SlidesApi ( "MyClientId" , "MyClientSecret" );
fileName = "MyPresentation.pptx" ;
slideIndex = 1 ;
shapeIndex = 2 ;
seriesIndex = 1 ;
pointIndex = 2 ;
dataPoint = new cloudSdk . ScatterChartDataPoint ();
dataPoint . xValue = 2 ;
dataPoint . yValue = 10 ;
slidesApi . updateChartDataPoint ( fileName , slideIndex , shapeIndex , seriesIndex , pointIndex , dataPoint ). then ( chart => {
dataPointCount = chart . body . series [ 0 ]. dataPoints . length ;
console . log ( "Number of data points:" , dataPointCount );
});
C++
#include "asposeslidescloud/api/SlidesApi.h"
#include "asposeslidescloud/model/ScatterSeries.h"
using namespace asposeslidescloud :: api ;
int main ()
{
std :: shared_ptr < SlidesApi > slidesApi = std :: make_shared < SlidesApi > ( L "MyClientId" , L "MyClientSecret" );
const wchar_t * fileName = L "MyPresentation.pptx" ;
int slideIndex = 1 ;
int shapeIndex = 2 ;
int seriesIndex = 1 ;
int pointIndex = 2 ;
std :: shared_ptr < ScatterChartDataPoint > dataPoint = std :: make_shared < ScatterChartDataPoint > ();
dataPoint -> setXValue ( 2 );
dataPoint -> setYValue ( 10 );
std :: shared_ptr < Chart > chart = slidesApi -> updateChartDataPoint ( fileName , slideIndex , shapeIndex , seriesIndex , pointIndex , dataPoint ). get ();
std :: shared_ptr < ScatterSeries > series = std :: static_pointer_cast < ScatterSeries > ( chart -> getSeries ()[ 0 ]);
int dataPointCount = series -> getDataPoints (). size ();
std :: wcout << L "Number of data points: " << dataPointCount ;
}
Perl
use AsposeSlidesCloud::Configuration ;
use AsposeSlidesCloud::SlidesApi ;
use AsposeSlidesCloud::Object::ScatterChartDataPoint ;
my $configuration = AsposeSlidesCloud::Configuration -> new ();
$configuration -> { app_sid } = "MyClientId" ;
$configuration -> { app_key } = "MyClientSecret" ;
my $slides_api = AsposeSlidesCloud::SlidesApi -> new ( config => $configuration );
my $file_name = "MyPresentation.pptx" ;
my $slide_index = 1 ;
my $shape_index = 2 ;
my $series_index = 1 ;
my $point_index = 2 ;
my $data_point = AsposeSlidesCloud::Object::ScatterChartDataPoint -> new ();
$data_point -> { x_value } = 2 ;
$data_point -> { y_value } = 10 ;
my $chart = $slides_api -> update_chart_data_point (
name => $file_name , slide_index => $slide_index , shape_index => $shape_index , series_index => $series_index , point_index => $point_index , data_point => $data_point );
my $data_point_count = @ { $chart -> { series }[ 0 ] -> { data_points }};
print ( "Number of data points: " , $data_point_count );
Swift
Go
import (
"fmt"
asposeslidescloud "github.com/aspose-slides-cloud/aspose-slides-cloud-go/v24"
)
func main () {
configuration := asposeslidescloud . NewConfiguration ()
configuration . AppSid = "MyClientId"
configuration . AppKey = "MyClientSecret"
slidesApi := asposeslidescloud . NewAPIClient ( configuration ). SlidesApi
var fileName = "MyPresentation.pptx"
var slideIndex int32 = 1
var shapeIndex int32 = 2
var seriesIndex int32 = 1
var pointIndex int32 = 2
dataPoint := asposeslidescloud . NewScatterChartDataPoint ()
dataPoint . XValue = 2
dataPoint . YValue = 10
chart , _ , _ := slidesApi . UpdateChartDataPoint ( fileName , slideIndex , shapeIndex , seriesIndex , pointIndex , dataPoint , "" , "" , "" )
series := chart . GetSeries ()[ 0 ].( asposeslidescloud . IScatterSeries )
dataPointCount := len ( series . GetDataPoints ())
fmt . Print ( "Number of data points: " , dataPointCount )
}
The result:
SDKs
Check Available SDKs to learn how to add an SDK to your project.