Excel.ChartSeries class

グラフのデータ系列を表します。

Extends

注釈

API セット: ExcelApi 1.1

使用元

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

// The following code adds data labels to the chart and positions them to demonstrate leader lines.
await Excel.run(async (context) => {
  const sheet = context.workbook.worksheets.getItem(sheetName);
  const chart = sheet.charts.getItemAt(0);
  const series = chart.series.getItemAt(0);
  
  // Enable data labels for the series. Leader lines are enabled by default.
  series.hasDataLabels = true;
  series.points.load("items");
  await context.sync();
  
  // Load the top position for each data label.
  series.points.items.forEach((point) => point.dataLabel.load("top"));
  await context.sync();

  // Move some data labels to create distance from their chart points.
  const point1 = series.points.items[1]; 
  const point2 = series.points.items[2]; 
  point1.dataLabel.top -= 50; 
  point2.dataLabel.top += 50;
  
  // Format the data labels.
  series.dataLabels.geometricShapeType = Excel.GeometricShapeType.rectangle;
  series.dataLabels.showCategoryName = true;
  series.dataLabels.format.border.weight = 1;
  
  await context.sync();
});

プロパティ

context

オブジェクトに関連付けられている要求コンテキスト。 これにより、アドインのプロセスが Office ホスト アプリケーションのプロセスに接続されます。

format

塗りつぶしと線の書式設定を含むグラフ系列の書式設定を表します。

name

グラフ内の系列の名前を指定します。 名前の長さは 255 文字を超えてはなりません。

points

系列内のすべてのポイントのコレクションを返します。

メソッド

load(options)

オブジェクトの指定されたプロパティを読み込むコマンドを待ち行列に入れます。 プロパティを読み取る前に、context.sync() を呼び出す必要があります。

load(propertyNames)

オブジェクトの指定されたプロパティを読み込むコマンドを待ち行列に入れます。 プロパティを読み取る前に、context.sync() を呼び出す必要があります。

load(propertyNamesAndPaths)

オブジェクトの指定されたプロパティを読み込むコマンドを待ち行列に入れます。 プロパティを読み取る前に、context.sync() を呼び出す必要があります。

set(properties, options)

オブジェクトの複数のプロパティを同時に設定します。 適切なプロパティを持つプレーン オブジェクトまたは同じ型の別の API オブジェクトを渡すことができます。

set(properties)

既存の読み込まれたオブジェクトに基づいて、オブジェクトに複数のプロパティを同時に設定します。

toJSON()

API オブジェクトがJSON.stringify()に渡されたときにより便利な出力を提供するために、JavaScript toJSON() メソッドをオーバーライドします。 (JSON.stringify、それに渡されるオブジェクトの toJSON メソッドを呼び出します)。元の Excel.ChartSeries オブジェクトは API オブジェクトですが、 toJSON メソッドは、元のオブジェクトから読み込まれた子プロパティの浅いコピーを含むプレーンな JavaScript オブジェクト ( Excel.Interfaces.ChartSeriesData として型指定) を返します。

プロパティの詳細

context

オブジェクトに関連付けられている要求コンテキスト。 これにより、アドインのプロセスが Office ホスト アプリケーションのプロセスに接続されます。

context: RequestContext;

プロパティ値

format

塗りつぶしと線の書式設定を含むグラフ系列の書式設定を表します。

readonly format: Excel.ChartSeriesFormat;

プロパティ値

注釈

API セット: ExcelApi 1.1

name

グラフ内の系列の名前を指定します。 名前の長さは 255 文字を超えてはなりません。

name: string;

プロパティ値

string

注釈

API セット: ExcelApi 1.1

points

系列内のすべてのポイントのコレクションを返します。

readonly points: Excel.ChartPointsCollection;

プロパティ値

注釈

API セット: ExcelApi 1.1

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

// The following code adds data labels to the chart and positions them to demonstrate leader lines.
await Excel.run(async (context) => {
  const sheet = context.workbook.worksheets.getItem(sheetName);
  const chart = sheet.charts.getItemAt(0);
  const series = chart.series.getItemAt(0);
  
  // Enable data labels for the series. Leader lines are enabled by default.
  series.hasDataLabels = true;
  series.points.load("items");
  await context.sync();
  
  // Load the top position for each data label.
  series.points.items.forEach((point) => point.dataLabel.load("top"));
  await context.sync();

  // Move some data labels to create distance from their chart points.
  const point1 = series.points.items[1]; 
  const point2 = series.points.items[2]; 
  point1.dataLabel.top -= 50; 
  point2.dataLabel.top += 50;
  
  // Format the data labels.
  series.dataLabels.geometricShapeType = Excel.GeometricShapeType.rectangle;
  series.dataLabels.showCategoryName = true;
  series.dataLabels.format.border.weight = 1;
  
  await context.sync();
});

メソッドの詳細

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

toJSON()

API オブジェクトがJSON.stringify()に渡されたときにより便利な出力を提供するために、JavaScript toJSON() メソッドをオーバーライドします。 (JSON.stringify、それに渡されるオブジェクトの toJSON メソッドを呼び出します)。元の Excel.ChartSeries オブジェクトは API オブジェクトですが、 toJSON メソッドは、元のオブジェクトから読み込まれた子プロパティの浅いコピーを含むプレーンな JavaScript オブジェクト ( Excel.Interfaces.ChartSeriesData として型指定) を返します。

toJSON(): Excel.Interfaces.ChartSeriesData;

返品