跳到主要内容

GetTitle

Returns the chart title text.

Syntax

expression.GetTitle();

expression - A variable that represents a ApiChart class.

Parameters

This method doesn't have any parameters.

Returns

string | null

Example

This example shows how to get the chart title text.

const doc = Api.GetDocument();
const page = doc.GetPage(0);

const chart = Api.CreateChart(
'bar3D',
[[200, 240, 280], [250, 260, 280]],
['Projected Revenue', 'Estimated Costs'],
[2014, 2015, 2016],
150 * 36000, 65 * 36000,
24
);
chart.SetShowDataLabels(false, false, true, false);
chart.SetTitle('Financial Overview', 13);

let fill = Api.CreateSolidFill(Api.RGB(51, 51, 51));
chart.SetSeriesFill(fill, 0, false);
fill = Api.CreateSolidFill(Api.RGB(255, 111, 61));
chart.SetSeriesFill(fill, 1, false);

page.AddObject(chart);

const chartTitle = chart.GetTitle();
const shape = Api.CreateShape('rect', 200 * 36000, 30 * 36000, Api.HexColor('#deadd8'), Api.CreateStroke(0, Api.CreateNoFill()));
shape.SetPosition(0, 70 * 36000);
const content = shape.GetContent();
const paragraph = content.GetElement(0);
paragraph.AddText('Chart Title: ' + chartTitle);
page.AddObject(shape);