Excel.ChartDataLabel class
グラフ ポイントのデータ ラベルを表します。
- Extends
注釈
例
// Link to full sample: https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/10-chart/chart-data-labels.yaml
// This function styles substrings within data label text using font formatting.
await Excel.run(async (context) => {
const sheet = context.workbook.worksheets.getItem(sheetName);
const chart = sheet.charts.getItemAt(0);
await context.sync();
const series = chart.series.getItemAt(0);
series.load("points");
await context.sync();
series.points.load("items");
await context.sync();
// Style a substring in the first data label.
let searchString = "sports";
let dataLabel = series.points.getItemAt(dataLabelInfo[0].index).dataLabel.load("text");
await context.sync();
let substringStart = dataLabel.text.indexOf(searchString);
let subLabel = dataLabel.getSubstring(substringStart, searchString.length);
subLabel.font.size = 13;
subLabel.font.bold = true;
// Style a substring in the second data label.
searchString = "'Titanic'";
dataLabel = series.points.getItemAt(dataLabelInfo[1].index).dataLabel.load("text");
await context.sync();
substringStart = dataLabel.text.indexOf(searchString);
subLabel = dataLabel.getSubstring(substringStart, searchString.length);
subLabel.font.name = "Calibri";
subLabel.font.size = 13;
subLabel.font.italic = true;
subLabel.font.color = "blue";
await context.sync();
});
プロパティ
| context | オブジェクトに関連付けられている要求コンテキスト。 これにより、アドインのプロセスが Office ホスト アプリケーションのプロセスに接続されます。 |
| position | データ ラベルの位置を表す値。 詳細は「 |
| separator | グラフのデータ ラベルに使用される区切り文字を表す文字列。 |
| show |
データ ラベルのバブル サイズを表示するかどうかを指定します。 |
| show |
データ ラベル カテゴリ名を表示するかどうかを指定します。 |
| show |
データ ラベルの凡例キーを表示するかどうかを指定します。 |
| show |
データ ラベルの割合を表示するかどうかを指定します。 |
| show |
データ ラベル系列名を表示するかどうかを指定します。 |
| show |
データ ラベルの値を表示するかどうかを指定します。 |
メソッド
| load(options) | オブジェクトの指定されたプロパティを読み込むコマンドを待ち行列に入れます。 プロパティを読み取る前に、 |
| load(property |
オブジェクトの指定されたプロパティを読み込むコマンドを待ち行列に入れます。 プロパティを読み取る前に、 |
| load(property |
オブジェクトの指定されたプロパティを読み込むコマンドを待ち行列に入れます。 プロパティを読み取る前に、 |
| set(properties, options) | オブジェクトの複数のプロパティを同時に設定します。 適切なプロパティを持つプレーン オブジェクトまたは同じ型の別の API オブジェクトを渡すことができます。 |
| set(properties) | 既存の読み込まれたオブジェクトに基づいて、オブジェクトに複数のプロパティを同時に設定します。 |
| toJSON() | API オブジェクトが |
プロパティの詳細
context
オブジェクトに関連付けられている要求コンテキスト。 これにより、アドインのプロセスが Office ホスト アプリケーションのプロセスに接続されます。
context: RequestContext;
プロパティ値
position
データ ラベルの位置を表す値。 詳細は「Excel.ChartDataLabelPosition」をご覧ください。
position: Excel.ChartDataLabelPosition | "Invalid" | "None" | "Center" | "InsideEnd" | "InsideBase" | "OutsideEnd" | "Left" | "Right" | "Top" | "Bottom" | "BestFit" | "Callout";
プロパティ値
Excel.ChartDataLabelPosition | "Invalid" | "None" | "Center" | "InsideEnd" | "InsideBase" | "OutsideEnd" | "Left" | "Right" | "Top" | "Bottom" | "BestFit" | "Callout"
注釈
separator
showBubbleSize
データ ラベルのバブル サイズを表示するかどうかを指定します。
showBubbleSize: boolean;
プロパティ値
boolean
注釈
showCategoryName
データ ラベル カテゴリ名を表示するかどうかを指定します。
showCategoryName: boolean;
プロパティ値
boolean
注釈
showLegendKey
showPercentage
showSeriesName
showValue
メソッドの詳細
load(options)
オブジェクトの指定されたプロパティを読み込むコマンドを待ち行列に入れます。 プロパティを読み取る前に、context.sync() を呼び出す必要があります。
load(options?: Excel.Interfaces.ChartDataLabelLoadOptions): Excel.ChartDataLabel;
パラメーター
読み込むオブジェクトのプロパティのオプションを提供します。
戻り値
load(propertyNames)
オブジェクトの指定されたプロパティを読み込むコマンドを待ち行列に入れます。 プロパティを読み取る前に、context.sync() を呼び出す必要があります。
load(propertyNames?: string | string[]): Excel.ChartDataLabel;
パラメーター
- propertyNames
-
string | string[]
読み込むプロパティを指定するコンマ区切り文字列または文字列の配列。
戻り値
load(propertyNamesAndPaths)
オブジェクトの指定されたプロパティを読み込むコマンドを待ち行列に入れます。 プロパティを読み取る前に、context.sync() を呼び出す必要があります。
load(propertyNamesAndPaths?: {
select?: string;
expand?: string;
}): Excel.ChartDataLabel;
パラメーター
- propertyNamesAndPaths
-
{ select?: string; expand?: string; }
propertyNamesAndPaths.select は読み込むプロパティを指定するコンマ区切りの文字列で、 propertyNamesAndPaths.expand は読み込むナビゲーション プロパティを指定するコンマ区切りの文字列です。
戻り値
set(properties, options)
オブジェクトの複数のプロパティを同時に設定します。 適切なプロパティを持つプレーン オブジェクトまたは同じ型の別の API オブジェクトを渡すことができます。
set(properties: Interfaces.ChartDataLabelUpdateData, options?: OfficeExtension.UpdateOptions): void;
パラメーター
- properties
- Excel.Interfaces.ChartDataLabelUpdateData
メソッドが呼び出されるオブジェクトのプロパティに等形的に構造化されたプロパティを持つ JavaScript オブジェクト。
- options
- OfficeExtension.UpdateOptions
properties オブジェクトが読み取り専用プロパティを設定しようとした場合にエラーを抑制するオプションを提供します。
戻り値
void
set(properties)
既存の読み込まれたオブジェクトに基づいて、オブジェクトに複数のプロパティを同時に設定します。
set(properties: Excel.ChartDataLabel): void;
パラメーター
- properties
- Excel.ChartDataLabel
戻り値
void
toJSON()
API オブジェクトがJSON.stringify()に渡されたときにより便利な出力を提供するために、JavaScript toJSON() メソッドをオーバーライドします。 (JSON.stringify、それに渡されるオブジェクトの toJSON メソッドを呼び出します)。元の Excel.ChartDataLabel オブジェクトは API オブジェクトですが、 toJSON メソッドは、元のオブジェクトから読み込まれた子プロパティの浅いコピーを含むプレーンな JavaScript オブジェクト ( Excel.Interfaces.ChartDataLabelData として型指定) を返します。
toJSON(): Excel.Interfaces.ChartDataLabelData;