跳到主要内容

GetType

使用 {@link ChartType} 枚举中的图表类型名称返回当前系列的图表类型。

语法​

expression.GetType();

expression - 表示 ApiChartSeries 类的变量。

参数​

此方法没有任何参数。

返回值​

ChartType

示例​

在演示文稿中从组合图中检索系列的图表类型名称。

// Extract and display the chart series type information in a presentation.

// Get the chart type of the first series and show it as slide title text.

const presentation = Api.GetPresentation();
const slide = presentation.GetSlideByIndex(0);
slide.RemoveAllObjects();

const chart = Api.CreateChart("ComboColumnClusteredLine", [
[200, 240, 280],
[250, 260, 280]
], ["Projected Revenue", "Estimated Costs"], [2014, 2015, 2016], 4051300, 2347595, 24);
chart.SetVerAxisTitle("USD In Hundred Thousands", 20);
chart.SetHorAxisTitle("Year", 22);
chart.SetLegendPos("bottom");
chart.SetShowDataLabels(false, false, true, false);

const series = chart.GetSeries(0);
const seriesType = series.GetType();
const title = "Series Type = " + seriesType + "\n";
chart.SetTitle(title, 40);
const chartWidth = 300 * 36000;
const chartHeight = 130 * 36000;
chart.SetSize(chartWidth, chartHeight);
chart.SetPosition((presentation.GetWidth() - chartWidth) / 2, (presentation.GetHeight() - chartHeight) / 2);
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);
slide.AddObject(chart);