Excel.ChartSeries class

代表图表上的系列。

Extends

注解

[ API 集:ExcelApi 1.1 ]

属性

axisGroup

指定指定系列的组。

binOptions

封装直方图和排列图的容器选项。

boxwhiskerOptions

封装箱形图的选项。

bubbleScale

这可以是从 0(零)到 300 的整数值,表示默认大小的百分比。 该属性仅适用于气泡图。

chartType

表示系列的图表类型。 有关详细信息,请参阅 Excel.ChartType

context

与 对象关联的请求上下文。 这会将加载项的进程连接到 Office 主机应用程序的进程。

dataLabels

表示系列中的所有数据标签的集合。

doughnutHoleSize

表示图表系列的圆环孔大小。 仅适用于圆环图和圆环图分解图。 在 InvalidArgument 无效图表上引发错误。

explosion

指定饼图或圆环图切片的爆炸值。 如果未分解(切片尖端位于饼图中心),则返回 0(零)。

filtered

指定是否筛选序列。 不适用于曲面图。

firstSliceAngle

指定第一个饼图或圆环图切片的角度,以度为单位, (垂直) 顺时针。 只适用于饼图、三维饼图和圆环图。 可以是 0 到 360 之间的值。

format

表示图表系列的格式,包括填充和线条格式。

gapWidth

表示图表系列的间隙宽度。 仅适用于条形图和柱形图,以及折线图和饼图的特定类。 在无效图表上引发无效参数异常。

gradientMaximumColor

指定区域地图图表系列最大值的颜色。

gradientMaximumType

指定区域地图图表系列最大值的类型。

gradientMaximumValue

指定区域地图图表系列的最大值。

gradientMidpointColor

指定区域地图图表系列的中点值的颜色。

gradientMidpointType

指定区域地图图表系列的中点值的类型。

gradientMidpointValue

指定区域地图图表系列的中点值。

gradientMinimumColor

指定区域地图图表系列的最小值的颜色。

gradientMinimumType

指定区域地图图表系列的最小值的类型。

gradientMinimumValue

指定区域地图图表系列的最小值。

gradientStyle

指定区域地图图表的系列渐变样式。

hasDataLabels

指定序列是否具有数据标签。

invertColor

指定序列中负数据点的填充颜色。

invertIfNegative

如此 如果 Excel 反转项中的模式时它对应于负数。

mapOptions

封装区域地图图表的选项。

markerBackgroundColor

指定图表系列的标记背景色。

markerForegroundColor

指定图表系列的标记前景色。

markerSize

指定图表系列的标记大小。 支持的大小范围为 2 到 72。 如果设置为超出支持范围的大小,此方法将返回 InvalidArgument 错误。

markerStyle

指定图表系列的标记样式。 有关详细信息,请参阅 Excel.ChartMarkerStyle

name

指定图表中序列的名称。 名称的长度不应大于 255 个字符。

overlap

指定条柱的摆放方式。 可以是 -100 到 100 之间的值。 只适用于二维条形图和二维柱形图。

parentLabelStrategy

指定树状图的系列父标签策略区域。

plotOrder

指定图表组中图表系列的绘图顺序。

points

返回序列中所有点的集合。

secondPlotSize

以主饼图大小百分比的形式指定饼图或饼图条形图的次要部分的大小。 可以是 5 到 200 之间的值。

showConnectorLines

指定是否在瀑布图中显示连接线。

showLeaderLines

指定是否为系列中的每个数据标签显示前导线。

showShadow

指定序列是否具有阴影。

smooth

指定序列是否平滑。 仅适用于折线图和散点图。

splitType

指定饼图或饼图条形图的两个部分的拆分方式。

splitValue

指定用于分隔饼图或饼条形图的两个部分的阈值。

trendlines

系列中趋势线的集合。

varyByCategories

如果 Excel 为每个数据标记分配不同的颜色或图案,则为 True。 图表必须只包含一个系列。

xErrorBars

表示图表系列的误差线对象。

yErrorBars

表示图表系列的误差线对象。

方法

delete()

删除 chart series 对象。

getDimensionDataSourceString(dimension)

获取图表系列数据源的字符串表示形式。 字符串表示形式可以是单元格地址等信息。

getDimensionDataSourceString(dimensionString)

获取图表系列数据源的字符串表示形式。 字符串表示形式可以是单元格地址等信息。

getDimensionDataSourceType(dimension)

获取图表系列的数据源类型。

getDimensionDataSourceType(dimensionString)

获取图表系列的数据源类型。

getDimensionValues(dimension)

从图表系列的单个维度获取值。 这些值可以是类别值或数据值,具体取决于指定的维度以及图表系列数据的映射方式。

getDimensionValues(dimensionString)

从图表系列的单个维度获取值。 这些值可以是类别值或数据值,具体取决于指定的维度以及图表系列数据的映射方式。

load(options)

将命令加入队列以加载对象的指定属性。 阅读属性前必须先调用 context.sync()

load(propertyNames)

将命令加入队列以加载对象的指定属性。 阅读属性前必须先调用 context.sync()

load(propertyNamesAndPaths)

将命令加入队列以加载对象的指定属性。 阅读属性前必须先调用 context.sync()

set(properties, options)

同时设置对象的多个属性。 可以传递具有相应属性的纯对象,也可以传递同一类型的另一个 API 对象。

set(properties)

基于现有的已加载对象,同时对对象设置多个属性。

setBubbleSizes(sourceData)

设置图表系列的气泡大小。 仅适用于气泡图。

setValues(sourceData)

设置图表系列的值。 对于散点图,它指的是 y 轴值。

setXAxisValues(sourceData)

设置图表系列的 x 轴值。

toJSON()

重写 JavaScript toJSON() 方法,以便在将 API 对象传递给 JSON.stringify()时提供更有用的输出。 JSON.stringify (,反过来,调用toJSON传递给它的 对象的 方法。) 虽然原始 Excel.ChartSeries 对象是 API 对象,但toJSON该方法返回一个纯 JavaScript 对象, (类型为 Excel.Interfaces.ChartSeriesData) ,其中包含从原始对象加载的任何子属性的浅表副本。

属性详细信息

axisGroup

指定指定系列的组。

axisGroup: Excel.ChartAxisGroup | "Primary" | "Secondary";

属性值

Excel.ChartAxisGroup | "Primary" | "Secondary"

注解

[ API 集:ExcelApi 1.8 ]

binOptions

封装直方图和排列图的容器选项。

readonly binOptions: Excel.ChartBinOptions;

属性值

注解

[ API 集:ExcelApi 1.9 ]

boxwhiskerOptions

封装箱形图的选项。

readonly boxwhiskerOptions: Excel.ChartBoxwhiskerOptions;

属性值

注解

[ API 集:ExcelApi 1.9 ]

bubbleScale

这可以是从 0(零)到 300 的整数值,表示默认大小的百分比。 该属性仅适用于气泡图。

bubbleScale: number;

属性值

number

注解

[ API 集:ExcelApi 1.9 ]

chartType

表示系列的图表类型。 有关详细信息,请参阅 Excel.ChartType

chartType: Excel.ChartType | "Invalid" | "ColumnClustered" | "ColumnStacked" | "ColumnStacked100" | "3DColumnClustered" | "3DColumnStacked" | "3DColumnStacked100" | "BarClustered" | "BarStacked" | "BarStacked100" | "3DBarClustered" | "3DBarStacked" | "3DBarStacked100" | "LineStacked" | "LineStacked100" | "LineMarkers" | "LineMarkersStacked" | "LineMarkersStacked100" | "PieOfPie" | "PieExploded" | "3DPieExploded" | "BarOfPie" | "XYScatterSmooth" | "XYScatterSmoothNoMarkers" | "XYScatterLines" | "XYScatterLinesNoMarkers" | "AreaStacked" | "AreaStacked100" | "3DAreaStacked" | "3DAreaStacked100" | "DoughnutExploded" | "RadarMarkers" | "RadarFilled" | "Surface" | "SurfaceWireframe" | "SurfaceTopView" | "SurfaceTopViewWireframe" | "Bubble" | "Bubble3DEffect" | "StockHLC" | "StockOHLC" | "StockVHLC" | "StockVOHLC" | "CylinderColClustered" | "CylinderColStacked" | "CylinderColStacked100" | "CylinderBarClustered" | "CylinderBarStacked" | "CylinderBarStacked100" | "CylinderCol" | "ConeColClustered" | "ConeColStacked" | "ConeColStacked100" | "ConeBarClustered" | "ConeBarStacked" | "ConeBarStacked100" | "ConeCol" | "PyramidColClustered" | "PyramidColStacked" | "PyramidColStacked100" | "PyramidBarClustered" | "PyramidBarStacked" | "PyramidBarStacked100" | "PyramidCol" | "3DColumn" | "Line" | "3DLine" | "3DPie" | "Pie" | "XYScatter" | "3DArea" | "Area" | "Doughnut" | "Radar" | "Histogram" | "Boxwhisker" | "Pareto" | "RegionMap" | "Treemap" | "Waterfall" | "Sunburst" | "Funnel";

属性值

Excel.ChartType | "Invalid" | "ColumnClustered" | "ColumnStacked" | "ColumnStacked100" | "3DColumnClustered" | "3DColumnStacked" | "3DColumnStacked100" | "BarClustered" | "BarStacked" | "BarStacked100" | "3DBarClustered" | "3DBarStacked" | "3DBarStacked100" | "LineStacked" | "LineStacked100" | "LineMarkers" | "LineMarkersStacked" | "LineMarkersStacked100" | "PieOfPie" | "PieExploded" | "3DPieExploded" | "BarOfPie" | "XYScatterSmooth" | "XYScatterSmoothNoMarkers" | "XYScatterLines" | "XYScatterLinesNoMarkers" | "AreaStacked" | "AreaStacked100" | "3DAreaStacked" | "3DAreaStacked100" | "DoughnutExploded" | "RadarMarkers" | "RadarFilled" | "Surface" | "SurfaceWireframe" | "SurfaceTopView" | "SurfaceTopViewWireframe" | "Bubble" | "Bubble3DEffect" | "StockHLC" | "StockOHLC" | "StockVHLC" | "StockVOHLC" | "CylinderColClustered" | "CylinderColStacked" | "CylinderColStacked100" | "CylinderBarClustered" | "CylinderBarStacked" | "CylinderBarStacked100" | "CylinderCol" | "ConeColClustered" | "ConeColStacked" | "ConeColStacked100" | "ConeBarClustered" | "ConeBarStacked" | "ConeBarStacked100" | "ConeCol" | "PyramidColClustered" | "PyramidColStacked" | "PyramidColStacked100" | "PyramidBarClustered" | "PyramidBarStacked" | "PyramidBarStacked100" | "PyramidCol" | "3DColumn" | "Line" | "3DLine" | "3DPie" | "Pie" | "XYScatter" | "3DArea" | "Area" | "Doughnut" | "Radar" | "Histogram" | "Boxwhisker" | "Pareto" | "RegionMap" | "Treemap" | "Waterfall" | "Sunburst" | "Funnel"

注解

[ API 集:ExcelApi 1.7 ]

context

与 对象关联的请求上下文。 这会将加载项的进程连接到 Office 主机应用程序的进程。

context: RequestContext;

属性值

dataLabels

表示系列中的所有数据标签的集合。

readonly dataLabels: Excel.ChartDataLabels;

属性值

注解

[ API 集:ExcelApi 1.8 ]

doughnutHoleSize

表示图表系列的圆环孔大小。 仅适用于圆环图和圆环图分解图。 在 InvalidArgument 无效图表上引发错误。

doughnutHoleSize: number;

属性值

number

注解

[ API 集:ExcelApi 1.7 ]

explosion

指定饼图或圆环图切片的爆炸值。 如果未分解(切片尖端位于饼图中心),则返回 0(零)。

explosion: number;

属性值

number

注解

[ API 集:ExcelApi 1.8 ]

filtered

指定是否筛选序列。 不适用于曲面图。

filtered: boolean;

属性值

boolean

注解

[ API 集:ExcelApi 1.7 ]

firstSliceAngle

指定第一个饼图或圆环图切片的角度,以度为单位, (垂直) 顺时针。 只适用于饼图、三维饼图和圆环图。 可以是 0 到 360 之间的值。

firstSliceAngle: number;

属性值

number

注解

[ API 集:ExcelApi 1.8 ]

format

表示图表系列的格式,包括填充和线条格式。

readonly format: Excel.ChartSeriesFormat;

属性值

注解

[ API 集:ExcelApi 1.1 ]

gapWidth

表示图表系列的间隙宽度。 仅适用于条形图和柱形图,以及折线图和饼图的特定类。 在无效图表上引发无效参数异常。

gapWidth: number;

属性值

number

注解

[ API 集:ExcelApi 1.7 ]

gradientMaximumColor

指定区域地图图表系列最大值的颜色。

gradientMaximumColor: string;

属性值

string

注解

[ API 集:ExcelApi 1.9 ]

gradientMaximumType

指定区域地图图表系列最大值的类型。

gradientMaximumType: Excel.ChartGradientStyleType | "ExtremeValue" | "Number" | "Percent";

属性值

Excel.ChartGradientStyleType | "ExtremeValue" | "Number" | "Percent"

注解

[ API 集:ExcelApi 1.9 ]

gradientMaximumValue

指定区域地图图表系列的最大值。

gradientMaximumValue: number;

属性值

number

注解

[ API 集:ExcelApi 1.9 ]

gradientMidpointColor

指定区域地图图表系列的中点值的颜色。

gradientMidpointColor: string;

属性值

string

注解

[ API 集:ExcelApi 1.9 ]

gradientMidpointType

指定区域地图图表系列的中点值的类型。

gradientMidpointType: Excel.ChartGradientStyleType | "ExtremeValue" | "Number" | "Percent";

属性值

Excel.ChartGradientStyleType | "ExtremeValue" | "Number" | "Percent"

注解

[ API 集:ExcelApi 1.9 ]

gradientMidpointValue

指定区域地图图表系列的中点值。

gradientMidpointValue: number;

属性值

number

注解

[ API 集:ExcelApi 1.9 ]

gradientMinimumColor

指定区域地图图表系列的最小值的颜色。

gradientMinimumColor: string;

属性值

string

注解

[ API 集:ExcelApi 1.9 ]

gradientMinimumType

指定区域地图图表系列的最小值的类型。

gradientMinimumType: Excel.ChartGradientStyleType | "ExtremeValue" | "Number" | "Percent";

属性值

Excel.ChartGradientStyleType | "ExtremeValue" | "Number" | "Percent"

注解

[ API 集:ExcelApi 1.9 ]

gradientMinimumValue

指定区域地图图表系列的最小值。

gradientMinimumValue: number;

属性值

number

注解

[ API 集:ExcelApi 1.9 ]

gradientStyle

指定区域地图图表的系列渐变样式。

gradientStyle: Excel.ChartGradientStyle | "TwoPhaseColor" | "ThreePhaseColor";

属性值

Excel.ChartGradientStyle | "TwoPhaseColor" | "ThreePhaseColor"

注解

[ API 集:ExcelApi 1.9 ]

hasDataLabels

指定序列是否具有数据标签。

hasDataLabels: boolean;

属性值

boolean

注解

[ API 集:ExcelApi 1.7 ]

invertColor

指定序列中负数据点的填充颜色。

invertColor: string;

属性值

string

注解

[ API 集:ExcelApi 1.9 ]

invertIfNegative

如此 如果 Excel 反转项中的模式时它对应于负数。

invertIfNegative: boolean;

属性值

boolean

注解

[ API 集:ExcelApi 1.8 ]

mapOptions

封装区域地图图表的选项。

readonly mapOptions: Excel.ChartMapOptions;

属性值

注解

[ API 集:ExcelApi 1.9 ]

markerBackgroundColor

指定图表系列的标记背景色。

markerBackgroundColor: string;

属性值

string

注解

[ API 集:ExcelApi 1.7 ]

示例

// Link to full sample: https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/10-chart/chart-series-markers.yaml

await Excel.run(async (context) => {
    let sheet = context.workbook.worksheets.getItem("Sample");
    let salesTable = sheet.tables.getItem("SalesTable");
    let dataRange = sheet.getRange("A1:E7");

    // Create an XY scatter chart.
    let chart = sheet.charts.add("XYScatterSmooth", dataRange, "Auto");
    chart.title.text = "Bicycle Parts Quarterly Sales"; 
  
    let series = chart.series;
    let series0 = series.getItemAt(0);
    let series1 = series.getItemAt(1);
    let series2 = series.getItemAt(2);
    let series3 = series.getItemAt(3);

    // Set markers.
    series0.markerStyle = "Dash";
    series0.markerForegroundColor = "black";
    series1.markerStyle = "Star";
    series1.markerForegroundColor = "black";
    series2.markerStyle = "X";
    series2.markerSize = 12;
    series3.markerStyle = "Triangle";
    series3.markerBackgroundColor = "purple";

    await context.sync();
});

markerForegroundColor

指定图表系列的标记前景色。

markerForegroundColor: string;

属性值

string

注解

[ API 集:ExcelApi 1.7 ]

示例

// Link to full sample: https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/10-chart/chart-series-markers.yaml

await Excel.run(async (context) => {
    let sheet = context.workbook.worksheets.getItem("Sample");
    let salesTable = sheet.tables.getItem("SalesTable");
    let dataRange = sheet.getRange("A1:E7");

    // Create an XY scatter chart.
    let chart = sheet.charts.add("XYScatterSmooth", dataRange, "Auto");
    chart.title.text = "Bicycle Parts Quarterly Sales"; 
  
    let series = chart.series;
    let series0 = series.getItemAt(0);
    let series1 = series.getItemAt(1);
    let series2 = series.getItemAt(2);
    let series3 = series.getItemAt(3);

    // Set markers.
    series0.markerStyle = "Dash";
    series0.markerForegroundColor = "black";
    series1.markerStyle = "Star";
    series1.markerForegroundColor = "black";
    series2.markerStyle = "X";
    series2.markerSize = 12;
    series3.markerStyle = "Triangle";
    series3.markerBackgroundColor = "purple";

    await context.sync();
});

markerSize

指定图表系列的标记大小。 支持的大小范围为 2 到 72。 如果设置为超出支持范围的大小,此方法将返回 InvalidArgument 错误。

markerSize: number;

属性值

number

注解

[ API 集:ExcelApi 1.7 ]

示例

// Link to full sample: https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/10-chart/chart-series-markers.yaml

await Excel.run(async (context) => {
    let sheet = context.workbook.worksheets.getItem("Sample");
    let salesTable = sheet.tables.getItem("SalesTable");
    let dataRange = sheet.getRange("A1:E7");

    // Create an XY scatter chart.
    let chart = sheet.charts.add("XYScatterSmooth", dataRange, "Auto");
    chart.title.text = "Bicycle Parts Quarterly Sales"; 
  
    let series = chart.series;
    let series0 = series.getItemAt(0);
    let series1 = series.getItemAt(1);
    let series2 = series.getItemAt(2);
    let series3 = series.getItemAt(3);

    // Set markers.
    series0.markerStyle = "Dash";
    series0.markerForegroundColor = "black";
    series1.markerStyle = "Star";
    series1.markerForegroundColor = "black";
    series2.markerStyle = "X";
    series2.markerSize = 12;
    series3.markerStyle = "Triangle";
    series3.markerBackgroundColor = "purple";

    await context.sync();
});

markerStyle

指定图表系列的标记样式。 有关详细信息,请参阅 Excel.ChartMarkerStyle

markerStyle: Excel.ChartMarkerStyle | "Invalid" | "Automatic" | "None" | "Square" | "Diamond" | "Triangle" | "X" | "Star" | "Dot" | "Dash" | "Circle" | "Plus" | "Picture";

属性值

Excel.ChartMarkerStyle | "Invalid" | "Automatic" | "None" | "Square" | "Diamond" | "Triangle" | "X" | "Star" | "Dot" | "Dash" | "Circle" | "Plus" | "Picture"

注解

[ API 集:ExcelApi 1.7 ]

示例

// Link to full sample: https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/10-chart/chart-series-markers.yaml

await Excel.run(async (context) => {
    let sheet = context.workbook.worksheets.getItem("Sample");
    let salesTable = sheet.tables.getItem("SalesTable");
    let dataRange = sheet.getRange("A1:E7");

    // Create an XY scatter chart.
    let chart = sheet.charts.add("XYScatterSmooth", dataRange, "Auto");
    chart.title.text = "Bicycle Parts Quarterly Sales"; 
  
    let series = chart.series;
    let series0 = series.getItemAt(0);
    let series1 = series.getItemAt(1);
    let series2 = series.getItemAt(2);
    let series3 = series.getItemAt(3);

    // Set markers.
    series0.markerStyle = "Dash";
    series0.markerForegroundColor = "black";
    series1.markerStyle = "Star";
    series1.markerForegroundColor = "black";
    series2.markerStyle = "X";
    series2.markerSize = 12;
    series3.markerStyle = "Triangle";
    series3.markerBackgroundColor = "purple";

    await context.sync();
});

name

指定图表中序列的名称。 名称的长度不应大于 255 个字符。

name: string;

属性值

string

注解

[ API 集:ExcelApi 1.1 ]

overlap

指定条柱的摆放方式。 可以是 -100 到 100 之间的值。 只适用于二维条形图和二维柱形图。

overlap: number;

属性值

number

注解

[ API 集:ExcelApi 1.8 ]

parentLabelStrategy

指定树状图的系列父标签策略区域。

parentLabelStrategy: Excel.ChartParentLabelStrategy | "None" | "Banner" | "Overlapping";

属性值

Excel.ChartParentLabelStrategy | "None" | "Banner" | "Overlapping"

注解

[ API 集:ExcelApi 1.9 ]

plotOrder

指定图表组中图表系列的绘图顺序。

plotOrder: number;

属性值

number

注解

[ API 集:ExcelApi 1.7 ]

points

返回序列中所有点的集合。

readonly points: Excel.ChartPointsCollection;

属性值

注解

[ API 集:ExcelApi 1.1 ]

secondPlotSize

以主饼图大小百分比的形式指定饼图或饼图条形图的次要部分的大小。 可以是 5 到 200 之间的值。

secondPlotSize: number;

属性值

number

注解

[ API 集:ExcelApi 1.8 ]

showConnectorLines

指定是否在瀑布图中显示连接线。

showConnectorLines: boolean;

属性值

boolean

注解

[ API 集:ExcelApi 1.9 ]

showLeaderLines

指定是否为系列中的每个数据标签显示前导线。

showLeaderLines: boolean;

属性值

boolean

注解

[ API 集:ExcelApi 1.9 ]

showShadow

指定序列是否具有阴影。

showShadow: boolean;

属性值

boolean

注解

[ API 集:ExcelApi 1.7 ]

smooth

指定序列是否平滑。 仅适用于折线图和散点图。

smooth: boolean;

属性值

boolean

注解

[ API 集:ExcelApi 1.7 ]

splitType

指定饼图或饼图条形图的两个部分的拆分方式。

splitType: Excel.ChartSplitType | "SplitByPosition" | "SplitByValue" | "SplitByPercentValue" | "SplitByCustomSplit";

属性值

Excel.ChartSplitType | "SplitByPosition" | "SplitByValue" | "SplitByPercentValue" | "SplitByCustomSplit"

注解

[ API 集:ExcelApi 1.8 ]

splitValue

指定用于分隔饼图或饼条形图的两个部分的阈值。

splitValue: number;

属性值

number

注解

[ API 集:ExcelApi 1.9 ]

trendlines

系列中趋势线的集合。

readonly trendlines: Excel.ChartTrendlineCollection;

属性值

注解

[ API 集:ExcelApi 1.7 ]

varyByCategories

如果 Excel 为每个数据标记分配不同的颜色或图案,则为 True。 图表必须只包含一个系列。

varyByCategories: boolean;

属性值

boolean

注解

[ API 集:ExcelApi 1.8 ]

xErrorBars

表示图表系列的误差线对象。

readonly xErrorBars: Excel.ChartErrorBars;

属性值

注解

[ API 集:ExcelApi 1.9 ]

yErrorBars

表示图表系列的误差线对象。

readonly yErrorBars: Excel.ChartErrorBars;

属性值

注解

[ API 集:ExcelApi 1.9 ]

方法详细信息

delete()

删除 chart series 对象。

delete(): void;

返回

void

注解

[ API 集:ExcelApi 1.7 ]

示例

// Link to full sample: https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/10-chart/chart-series.yaml

await Excel.run(async (context) => {
  const sheet = context.workbook.worksheets.getItem("Sample");
  const seriesCollection = sheet.charts.getItemAt(0).series;
  seriesCollection.load("count");
  await context.sync();

  if (seriesCollection.count > 0) {
    const series = seriesCollection.getItemAt(0);

    // Delete the first series.
    series.delete();
  }

  await context.sync();
});

getDimensionDataSourceString(dimension)

获取图表系列数据源的字符串表示形式。 字符串表示形式可以是单元格地址等信息。

getDimensionDataSourceString(dimension: Excel.ChartSeriesDimension): OfficeExtension.ClientResult<string>;

参数

dimension
Excel.ChartSeriesDimension

数据所在轴的维度。

返回

注解

[ API 集:ExcelApi 1.15 ]

示例

// Link to full sample: https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/10-chart/chart-data-source.yaml

// This function retrieves the data source information of a chart series in the Sample worksheet.
await Excel.run(async (context) => {
  const sheet = context.workbook.worksheets.getItem("Sample");

  // Get the first chart series from the first chart on the worksheet.
  const seriesCollection = sheet.charts.getItemAt(0).series;
  const series = seriesCollection.getItemAt(0);

  // Get the series data source string and type values. 
  const dataSourceString = series.getDimensionDataSourceString("Values");
  const dataSourceType = series.getDimensionDataSourceType("Values");

  series.load("name");
  await context.sync();
  
  // Log the data source information to the console.
  console.log(series.name + " data source string: " + dataSourceString.value);
  console.log(series.name + " data source type: " + dataSourceType.value);
});

getDimensionDataSourceString(dimensionString)

获取图表系列数据源的字符串表示形式。 字符串表示形式可以是单元格地址等信息。

getDimensionDataSourceString(dimensionString: "Categories" | "Values" | "XValues" | "YValues" | "BubbleSizes"): OfficeExtension.ClientResult<string>;

参数

dimensionString

"Categories" | "Values" | "XValues" | "YValues" | "BubbleSizes"

数据所在轴的维度。

返回

注解

[ API 集:ExcelApi 1.15 ]

getDimensionDataSourceType(dimension)

获取图表系列的数据源类型。

getDimensionDataSourceType(dimension: Excel.ChartSeriesDimension): OfficeExtension.ClientResult<Excel.ChartDataSourceType>;

参数

dimension
Excel.ChartSeriesDimension

数据所在轴的维度。

返回

注解

[ API 集:ExcelApi 1.15 ]

示例

// Link to full sample: https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/10-chart/chart-data-source.yaml

// This function retrieves the data source information of a chart series in the Sample worksheet.
await Excel.run(async (context) => {
  const sheet = context.workbook.worksheets.getItem("Sample");

  // Get the first chart series from the first chart on the worksheet.
  const seriesCollection = sheet.charts.getItemAt(0).series;
  const series = seriesCollection.getItemAt(0);

  // Get the series data source string and type values. 
  const dataSourceString = series.getDimensionDataSourceString("Values");
  const dataSourceType = series.getDimensionDataSourceType("Values");

  series.load("name");
  await context.sync();
  
  // Log the data source information to the console.
  console.log(series.name + " data source string: " + dataSourceString.value);
  console.log(series.name + " data source type: " + dataSourceType.value);
});

getDimensionDataSourceType(dimensionString)

获取图表系列的数据源类型。

getDimensionDataSourceType(dimensionString: "Categories" | "Values" | "XValues" | "YValues" | "BubbleSizes"): OfficeExtension.ClientResult<Excel.ChartDataSourceType>;

参数

dimensionString

"Categories" | "Values" | "XValues" | "YValues" | "BubbleSizes"

数据所在轴的维度。

返回

注解

[ API 集:ExcelApi 1.15 ]

getDimensionValues(dimension)

从图表系列的单个维度获取值。 这些值可以是类别值或数据值,具体取决于指定的维度以及图表系列数据的映射方式。

getDimensionValues(dimension: Excel.ChartSeriesDimension): OfficeExtension.ClientResult<string[]>;

参数

dimension
Excel.ChartSeriesDimension

数据所在轴的维度。

返回

注解

[ API 集:ExcelApi 1.12 ]

示例

// Link to full sample: https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/10-chart/chart-bubble-chart.yaml

await Excel.run(async (context) => {
  const sheet = context.workbook.worksheets.getItem("Sample");

  // The sample chart is of type `Excel.ChartType.bubble`.
  const bubbleChart = sheet.charts.getItem("Product Chart");

  // Get the first series in the chart.
  const firstSeries = bubbleChart.series.getItemAt(0);

  // Get the values for the dimensions we're interested in.
  const bubbleSize = firstSeries.getDimensionValues(Excel.ChartSeriesDimension.bubbleSizes);
  const xValues = firstSeries.getDimensionValues(Excel.ChartSeriesDimension.xvalues);
  const yValues = firstSeries.getDimensionValues(Excel.ChartSeriesDimension.yvalues);
  const category = firstSeries.getDimensionValues(Excel.ChartSeriesDimension.categories);

  await context.sync();

  // Log the information.
  console.log(`Series ${category.value} - X:${xValues.value},Y:${yValues.value},Bubble:${bubbleSize.value}`);
});

getDimensionValues(dimensionString)

从图表系列的单个维度获取值。 这些值可以是类别值或数据值,具体取决于指定的维度以及图表系列数据的映射方式。

getDimensionValues(dimensionString: "Categories" | "Values" | "XValues" | "YValues" | "BubbleSizes"): OfficeExtension.ClientResult<string[]>;

参数

dimensionString

"Categories" | "Values" | "XValues" | "YValues" | "BubbleSizes"

数据所在轴的维度。

返回

注解

[ API 集:ExcelApi 1.12 ]

load(options)

将命令加入队列以加载对象的指定属性。 阅读属性前必须先调用 context.sync()

load(options?: Excel.Interfaces.ChartSeriesLoadOptions): Excel.ChartSeries;

参数

options
Excel.Interfaces.ChartSeriesLoadOptions

提供要加载对象的属性的选项。

返回

load(propertyNames)

将命令加入队列以加载对象的指定属性。 阅读属性前必须先调用 context.sync()

load(propertyNames?: string | string[]): Excel.ChartSeries;

参数

propertyNames

string | string[]

逗号分隔的字符串或指定要加载的属性的字符串数组。

返回

示例

// Rename the 1st series of Chart1 to "New Series Name".
await Excel.run(async (context) => { 
    const chart = context.workbook.worksheets.getItem("Sheet1").charts.getItem("Chart1");    
    chart.series.getItemAt(0).name = "New Series Name";
    await context.sync();

    console.log("Series1 Renamed");
});

load(propertyNamesAndPaths)

将命令加入队列以加载对象的指定属性。 阅读属性前必须先调用 context.sync()

load(propertyNamesAndPaths?: {
            select?: string;
            expand?: string;
        }): Excel.ChartSeries;

参数

propertyNamesAndPaths

{ select?: string; expand?: string; }

propertyNamesAndPaths.select 是一个逗号分隔的字符串,指定要加载的属性,是 propertyNamesAndPaths.expand 一个逗号分隔的字符串,指定要加载的导航属性。

返回

set(properties, options)

同时设置对象的多个属性。 可以传递具有相应属性的纯对象,也可以传递同一类型的另一个 API 对象。

set(properties: Interfaces.ChartSeriesUpdateData, options?: OfficeExtension.UpdateOptions): void;

参数

properties
Excel.Interfaces.ChartSeriesUpdateData

一个 JavaScript 对象,其属性按同构方式构造为调用方法的对象的属性。

options
OfficeExtension.UpdateOptions

提供一个选项,用于在 properties 对象尝试设置任何只读属性时禁止显示错误。

返回

void

set(properties)

基于现有的已加载对象,同时对对象设置多个属性。

set(properties: Excel.ChartSeries): void;

参数

properties
Excel.ChartSeries

返回

void

setBubbleSizes(sourceData)

设置图表系列的气泡大小。 仅适用于气泡图。

setBubbleSizes(sourceData: Range): void;

参数

sourceData
Excel.Range

对应于 Range 源数据的对象。

返回

void

注解

[ API 集:ExcelApi 1.7 ]

示例

// Link to full sample: https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/10-chart/chart-bubble-chart.yaml

await Excel.run(async (context) => {
  /*
    The table is expected to look like this:
    Product, Inventory, Price, Current Market Share
    Calamansi, 2000, $2.45, 10%
    ...

    We want each bubble to represent a single row.
  */

  // Get the worksheet and table data.
  const sheet = context.workbook.worksheets.getItem("Sample");
  const table = sheet.tables.getItem("Sales");
  const dataRange = table.getDataBodyRange();

  // Get the table data without the row names.
  const valueRange = dataRange.getOffsetRange(0, 1).getResizedRange(0, -1);

  // Create the chart.
  const bubbleChart = sheet.charts.add(Excel.ChartType.bubble, valueRange);
  bubbleChart.name = "Product Chart";

  // Remove the default series, since we want a unique series for each row.
  bubbleChart.series.getItemAt(0).delete();

  // Load the data necessary to make a chart series.
  dataRange.load(["rowCount", "values"]);
  await context.sync();

  // For each row, create a chart series (a bubble).
  for (let i = 0; i < dataRange.rowCount; i++) {
    const newSeries = bubbleChart.series.add(dataRange.values[i][0], i);
    newSeries.setXAxisValues(dataRange.getCell(i, 1));
    newSeries.setValues(dataRange.getCell(i, 2));
    newSeries.setBubbleSizes(dataRange.getCell(i, 3));

    // Show the product name and market share percentage.
    newSeries.dataLabels.showSeriesName = true;
    newSeries.dataLabels.showBubbleSize = true;
    newSeries.dataLabels.showValue = false;
  }

  await context.sync();
});

setValues(sourceData)

设置图表系列的值。 对于散点图,它指的是 y 轴值。

setValues(sourceData: Range): void;

参数

sourceData
Excel.Range

对应于 Range 源数据的对象。

返回

void

注解

[ API 集:ExcelApi 1.7 ]

示例

// Link to full sample: https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/10-chart/chart-series.yaml

await Excel.run(async (context) => {
  const sheet = context.workbook.worksheets.getItem("Sample");

  let seriesCollection = sheet.charts.getItemAt(0);
  let rangeSelection = sheet.getRange("C2:C7");
  let xRangeSelection = sheet.getRange("A1:A7");

  // Add a series.
  let newSeries = seriesCollection.series.add("Qtr2");
  newSeries.setValues(rangeSelection);
  newSeries.setXAxisValues(xRangeSelection);

  await context.sync();
});

setXAxisValues(sourceData)

设置图表系列的 x 轴值。

setXAxisValues(sourceData: Range): void;

参数

sourceData
Excel.Range

对应于 Range 源数据的对象。

返回

void

注解

[ API 集:ExcelApi 1.7 ]

toJSON()

重写 JavaScript toJSON() 方法,以便在将 API 对象传递给 JSON.stringify()时提供更有用的输出。 JSON.stringify (,反过来,调用toJSON传递给它的 对象的 方法。) 虽然原始 Excel.ChartSeries 对象是 API 对象,但toJSON该方法返回一个纯 JavaScript 对象, (类型为 Excel.Interfaces.ChartSeriesData) ,其中包含从原始对象加载的任何子属性的浅表副本。

toJSON(): Excel.Interfaces.ChartSeriesData;

返回