Set a Chart Legend

Introduction

The primary function of a legend is to identify the different data series or categories represented in the chart. Legends often use colors to represent different data series. Each color in the legend corresponds to a specific element in the chart. In addition to color, some charts may use symbols or markers to distinguish between data series, especially in line charts or scatter plots. The legend explains the meaning of these symbols, ensuring clarity for the audience. Alongside the color or symbol, the legend typically includes a textual description of each data series. This description may include the name of the series or any relevant information that helps viewers understand what each element represents. The legend is usually positioned adjacent to or within the chart area for easy reference. However, its exact location can vary depending on the design of the slide and the space available. Use the following method to customize a chart legend.

SetChartLegend

API Information

API Type Description Resource
/slides/{name}/slides/{slideIndex}/shapes/{shapeIndex}/legend PUT Updates the properties of a chart legend in a presentation saved in a storage. SetChartLegend

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 slide.
shapeIndex integer path true The 1-based index of a shape (must be a chart).
legend Legend body true The data transfer object with the legend parameters.
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 chart (the second shape) on the first slide with a legend located at the bottom of the chart. Move the legend to the right and fill it with the color #77CEF9.

The chart

cURL Solution

SDK Solutions

The result:

The chart

SDKs

Check Available SDKs to learn how to add an SDK to your project.