Skip to main content

GetType

Returns a type of the chart object using the chart type names from the {@link ChartType} enumeration.

Syntax​

expression.GetType();

expression - A variable that represents an ApiChart class.

Parameters​

This method doesn't have any parameters.

Returns​

ChartType

Example​

Read the chart type using the chart type name and show it in the title in a spreadsheet.

// Useful for confirming a chart's type before applying type-specific formatting in a spreadsheet.

// Confirm the chart type programmatically to use its name as a label in a spreadsheet.

const worksheet = Api.GetActiveSheet();

worksheet.GetRange("B1").SetValue(2014);
worksheet.GetRange("C1").SetValue(2015);
worksheet.GetRange("D1").SetValue(2016);
worksheet.GetRange("A2").SetValue("Projected Revenue");
worksheet.GetRange("A3").SetValue("Estimated Costs");
worksheet.GetRange("B2").SetValue(200);
worksheet.GetRange("B3").SetValue(250);
worksheet.GetRange("C2").SetValue(240);
worksheet.GetRange("C3").SetValue(260);
worksheet.GetRange("D2").SetValue(280);
worksheet.GetRange("D3").SetValue(280);
const chart = worksheet.AddChart("'Sheet1'!$A$1:$D$3", true, "3DColumnClustered", 2, 100 * 36000, 70 * 36000, 0, 2 * 36000, 5, 3 * 36000);

chart.SetTitle('This is the ' + chart.GetType() + ' chart', 30);