JavaScript を使用したプレゼンテーションでのチャート データ シリーズの管理
概要
チャートは、プロットされた値をワークブックのセルに保存することも、数値リテラルとして直接保存することもできます。A ChartSeries は関連する値のセットを表し、各 ChartDataPoint はそのシリーズ内のポイントを表します。ChartCategory オブジェクトは、シリーズが共有するラベルまたはグループ化値を提供します。デフォルトデータで作成されたチャートでは、シリーズ名、カテゴリ、およびポイント値は、チャートワークブックの ChartDataCell オブジェクトを使用します。
典型的なカテゴリチャートの場合、デフォルトワークブックは行 0 をシリーズ名に、列 0 をカテゴリ名に、残りのセルをシリーズ値に使用します。ChartDataWorkbook.getCell に渡されるワークシート、行、列のインデックスは 0 ベースです。このレイアウトはデフォルトデータでチャートを作成する場合に便利ですが、既存のすべてのチャートがこれを使用しているとは限りません。読み込んだプレゼンテーションの場合、ワークブックの値を変更する前に、シリーズ、カテゴリ、データポイントが参照しているセルを確認してください。
チャート設定には、3 つの異なるスコープがあります。
- シリーズレベルの設定(例: ChartSeries.getFormat)は、1 つのシリーズ内のすべてのポイントのデフォルトの外観を提供します。
- データポイント設定(例: ChartDataPoint.getFormat)は、1 つのポイントに対してシリーズの外観を上書きします。
- グループ設定は、同じ ChartSeriesGroup に属する互換性のあるシリーズに適用されます。オーバーラップやギャップ幅などのオプションを設定する必要がある場合は、ChartSeries.getParentSeriesGroup を介してグループにアクセスしてください。
明示的なポイントまたはシリーズの塗りつぶしが設定されていない場合、チャートのスタイルとテーマが自動外観を決定します。シリーズとポイントの書式設定の両方が存在する場合、ポイントの書式設定がそのポイントに対して優先されます。

クラスター化シリンダーチャートの場合、changing the 3D series type or bar shape が最初のシリーズにどのように影響するかをご覧ください。
数値リテラルを使用してシリーズの値を設定する
シリーズの値がアプリケーションデータや計算結果から得られ、ワークシートのセル参照が不要な場合は、数値リテラルを使用します。各ポイントの getValue 結果を setAsLiteralDouble で設定する前に、setDataSourceTypeForValues に DataSourceType.DoubleLiterals を渡してください。
コレクション設定は、そのシリーズ内のすべてのポイント値のソースタイプを制御します。各ポイント値の getDataSourceType メソッドは選択されたタイプを返します;コレクション設定を変更してタイプを切り替えてください。Worksheet を使用する場合は、getAsCell で参照セルにアクセスします。DoubleLiterals を使用する場合は、getAsLiteralDouble または setAsLiteralDouble で数値を直接読み書きします。
以下の例は、デフォルトのシリーズとカテゴリを持つ列チャートを作成し、最初のシリーズの既存ポイントに 10、20… と計算された値を割り当てます。プレゼンテーションを保存し、再度開いて格納された値を出力します。
const aspose = { slides: require("aspose.slides.via.java") };
const presentation = new aspose.slides.Presentation();
try {
const slide = presentation.getSlides().get_Item(0);
const chart = slide.getShapes().addChart(aspose.slides.ChartType.ClusteredColumn, 20, 20, 500, 300);
const series = chart.getChartData().getSeries().get_Item(0);
series.getDataPoints().setDataSourceTypeForValues(aspose.slides.DataSourceType.DoubleLiterals);
for (let i = 0; i < series.getDataPoints().size(); i++) {
series.getDataPoints().get_Item(i).getValue().setAsLiteralDouble((i + 1) * 10);
}
presentation.save("numeric_literals.pptx", aspose.slides.SaveFormat.Pptx);
} finally {
presentation.dispose();
}
const reopenedPresentation = new aspose.slides.Presentation("numeric_literals.pptx");
try {
const reopenedSlide = reopenedPresentation.getSlides().get_Item(0);
const reopenedChart = reopenedSlide.getShapes().get_Item(0);
const reopenedSeries = reopenedChart.getChartData().getSeries().get_Item(0);
for (let i = 0; i < reopenedSeries.getDataPoints().size(); i++) {
const point = reopenedSeries.getDataPoints().get_Item(i);
console.log(point.getValue().getAsLiteralDouble());
}
} finally {
reopenedPresentation.dispose();
}
ポイント値のソースタイプは、ChartData.getDataSourceType とは別で、チャートの内部または外部ワークブック構成を示します。数値リテラルを使用しても、埋め込まれたワークブックが自動で削除されるわけではありません。この例では、カテゴリラベル、シリーズ名、その他のシリーズのためにワークブックは引き続き利用可能です。ワークブックの管理については、Chart Workbook を参照してください。
散布図およびバブルチャートの場合は、setDataSourceTypeForXValues と setDataSourceTypeForYValues を使用して、getXValue と getYValue のソースを選択します。バブルチャートはさらに setDataSourceTypeForBubbleSizes を使用して getBubbleSize のソースを設定します。各該当ソースを DoubleLiterals に設定し、その値の setAsLiteralDouble メソッドで数値を割り当ててください。
チャートシリーズのオーバーラップを設定する
ChartSeries.getOverlap は、2D チャートで棒や列がどれだけ重なるかを -100% から 100% の範囲で報告します。これは、親シリーズグループの設定の読み取り専用投影です。グループ内のすべての互換シリーズを更新するには、ChartSeriesGroup.setOverlap を使用してください。このオプションは、グループ化された棒や列を表示するチャートタイプに適用され、組み合わせチャートの無関係なシリーズグループには影響しません。
以下の例は、最初のシリーズを含むグループのオーバーラップを設定します。
const aspose = {};
aspose.slides = require("aspose.slides.via.java");
const java = require("java");
const firstSlideIndex = 0;
const firstSeriesIndex = 0;
const overlapPercent = java.newByte(30);
const presentation = new aspose.slides.Presentation();
try {
const slide = presentation.getSlides().get_Item(firstSlideIndex);
// 新しいチャートにはサンプルシリーズ、カテゴリ、値が含まれています。
const chart = slide.getShapes().addChart(aspose.slides.ChartType.ClusteredColumn, 20, 20, 500, 200);
const series = chart.getChartData().getSeries().get_Item(firstSeriesIndex);
series.getParentSeriesGroup().setOverlap(overlapPercent);
presentation.save("series_overlap.pptx", aspose.slides.SaveFormat.Pptx);
} finally {
presentation.dispose();
}
結果:

シリーズの塗りつぶし色を変更する
ChartSeries.getFormat を使用して、シリーズ全体のデフォルト塗りつぶしを設定します。ポイントに明示的な塗りつぶしがある場合は、ChartDataPoint.getFormat の設定がそのポイントのシリーズ塗りつぶしを上書きします。
以下の例は、最初のシリーズに単色の青い塗りつぶしを適用します。
const aspose = {};
aspose.slides = require("aspose.slides.via.java");
const java = require("java");
const firstSlideIndex = 0;
const firstSeriesIndex = 0;
const solidFillType = java.newByte(aspose.slides.FillType.Solid);
const blueColor = java.getStaticFieldValue("java.awt.Color", "BLUE");
const presentation = new aspose.slides.Presentation();
try {
const slide = presentation.getSlides().get_Item(firstSlideIndex);
const chart = slide.getShapes().addChart(aspose.slides.ChartType.ClusteredColumn, 20, 20, 500, 200);
const series = chart.getChartData().getSeries().get_Item(firstSeriesIndex);
series.getFormat().getFill().setFillType(solidFillType);
series.getFormat().getFill().getSolidFillColor().setColor(blueColor);
presentation.save("series_color.pptx", aspose.slides.SaveFormat.Pptx);
} finally {
presentation.dispose();
}
結果:

シリーズ名を変更する
シリーズ名はチャートデータワークブックに格納され、通常は凡例に表示されます。クラスター化列チャート用に作成されたデフォルトワークブックでは、セル B1 は行 0、列 1 にあり、最初のシリーズの名前が格納されています。以下の例では、定数を使用してその構造を明示しています。
const aspose = {};
aspose.slides = require("aspose.slides.via.java");
const firstSlideIndex = 0;
const worksheetIndex = 0;
const seriesNameRowIndex = 0;
const firstSeriesColumnIndex = 1;
const presentation = new aspose.slides.Presentation();
try {
const slide = presentation.getSlides().get_Item(firstSlideIndex);
const chart = slide.getShapes().addChart(aspose.slides.ChartType.ClusteredColumn, 20, 20, 500, 200);
const workbook = chart.getChartData().getChartDataWorkbook();
const seriesNameCell = workbook.getCell(worksheetIndex, seriesNameRowIndex, firstSeriesColumnIndex);
seriesNameCell.setValue("Revenue");
presentation.save("series_name.pptx", aspose.slides.SaveFormat.Pptx);
} finally {
presentation.dispose();
}
また、ChartSeries.getName がすでに参照しているセルを更新することもできます。この方法は、既存のチャートで特定の行や列を仮定することを回避します。
const aspose = {};
aspose.slides = require("aspose.slides.via.java");
const firstSlideIndex = 0;
const firstSeriesIndex = 0;
const firstNameCellIndex = 0;
const presentation = new aspose.slides.Presentation();
try {
const slide = presentation.getSlides().get_Item(firstSlideIndex);
const chart = slide.getShapes().addChart(aspose.slides.ChartType.ClusteredColumn, 20, 20, 500, 200);
const series = chart.getChartData().getSeries().get_Item(firstSeriesIndex);
const seriesNameCell = series.getName().getAsCells().get_Item(firstNameCellIndex);
seriesNameCell.setValue("Revenue");
presentation.save("series_name.pptx", aspose.slides.SaveFormat.Pptx);
} finally {
presentation.dispose();
}
結果:

複数セルからなる名前でシリーズを作成する
製品名と報告期間が別々のワークブックセルに格納されている場合、複合的なシリーズ名を使用すると便利です。たとえば、B1 の Product A と C1 の 2026 を組み合わせて、両方のソースセルにリンクされた単一のシリーズ名にできます。
ChartDataWorkbook.getCellCollection を使用して名前範囲を取得し、そのコレクションを ChartSeriesCollection.add に渡します。skipHiddenCells 引数は非表示セルを含めるかどうかを制御します:true は除外し、false は含めます。この例では false を使用して名前範囲のすべてのセルを含めています。
以下の例は、1 つのシリーズと 2 つのデータポイントを持つプレゼンテーションを作成します。セル B1:C1 はシリーズ名のみを提供し、A2:A3 はカテゴリラベル、B2:B3 は数値を提供します。
const aspose = {};
aspose.slides = require("aspose.slides.via.java");
const presentation = new aspose.slides.Presentation();
try {
const slide = presentation.getSlides().get_Item(0);
const chart = slide.getShapes().addChart(aspose.slides.ChartType.ClusteredColumn, 50, 50, 620, 180);
chart.getChartData().getSeries().clear();
chart.getChartData().getCategories().clear();
chart.setLegend(true);
const workbook = chart.getChartData().getChartDataWorkbook();
workbook.clear(0);
// この 2 つのセルがシリーズ名を提供します。
workbook.getCell(0, 0, 1, "Product A");
workbook.getCell(0, 0, 2, "2026");
const nameCells = workbook.getCellCollection("Sheet1!$B$1:$C$1", false);
const series = chart.getChartData().getSeries().add(nameCells, aspose.slides.ChartType.ClusteredColumn);
// 別々のセルがカテゴリと数値データポイントを提供します。
const northCategory = workbook.getCell(0, 1, 0, "North");
const southCategory = workbook.getCell(0, 2, 0, "South");
chart.getChartData().getCategories().add(northCategory);
chart.getChartData().getCategories().add(southCategory);
const northValue = workbook.getCell(0, 1, 1, 120);
const southValue = workbook.getCell(0, 2, 1, 150);
series.getDataPoints().addDataPointForBarSeries(northValue);
series.getDataPoints().addDataPointForBarSeries(southValue);
presentation.save("composite_series_name.pptx", aspose.slides.SaveFormat.Pptx);
} finally {
presentation.dispose();
}
結果として得られるシリーズ名は Product A 2026 で、2 つのセル値の間にスペースが入ります。凡例は両列を 1 つのエントリとして表示します。下の画像が結果を示しています。

自動シリーズ塗りつぶし色を取得する
ChartSeries.getAutomaticSeriesColor は、シリーズインデックスとチャートスタイルから計算された色を返します。これは、シリーズの塗りつぶしが明示的に定義されていない場合に使用される色です。このメソッドを呼び出すだけで計算された色を取得でき、塗りつぶしを設定するわけではありません。
以下の例は、デフォルトシリーズそれぞれの自動色を出力します。
const aspose = {};
aspose.slides = require("aspose.slides.via.java");
const firstSlideIndex = 0;
const presentation = new aspose.slides.Presentation();
try {
const slide = presentation.getSlides().get_Item(firstSlideIndex);
const chart = slide.getShapes().addChart(aspose.slides.ChartType.ClusteredColumn, 20, 20, 500, 200);
const seriesCount = chart.getChartData().getSeries().size();
for (let seriesIndex = 0; seriesIndex < seriesCount; seriesIndex++) {
const series = chart.getChartData().getSeries().get_Item(seriesIndex);
const automaticColor = series.getAutomaticSeriesColor();
const automaticColorText = automaticColor.toString();
console.log("Series " + seriesIndex + ": " + automaticColorText);
}
} finally {
presentation.dispose();
}
デフォルトのチャートスタイルに対するサンプル出力:
Series 0: java.awt.Color[r=79,g=129,b=189]
Series 1: java.awt.Color[r=192,g=80,b=77]
Series 2: java.awt.Color[r=155,g=187,b=89]
正確な色はチャートスタイルとテーマに依存します。
シリーズの負の値用に塗りつぶし色を反転させる
棒、列、バブルシリーズでは、ChartSeries.setInvertIfNegative を使用して負の値を別の塗りつぶしで表示できます。通常のシリーズ塗りつぶしを単色に設定し、反転を有効にし、負の値の色を ChartSeries.getInvertedSolidFillColor で割り当てます。負の数自体はワークブック内で変更されず、表示色だけが変わります。
以下の例は、デフォルトのチャートデータを 1 つのシリーズで置き換えます。ワークシートの行 0 にシリーズ名、列 0 にカテゴリ名、列 1 に値が格納されます。
const aspose = {};
aspose.slides = require("aspose.slides.via.java");
const java = require("java");
const firstSlideIndex = 0;
const worksheetIndex = 0;
const headerRowIndex = 0;
const categoryColumnIndex = 0;
const firstSeriesColumnIndex = 1;
const firstDataRowIndex = 1;
const solidFillType = java.newByte(aspose.slides.FillType.Solid);
const redColor = java.getStaticFieldValue("java.awt.Color", "RED");
const categoryNames = ["Category 1", "Category 2", "Category 3"];
const seriesValues = [-20, 50, -30];
const presentation = new aspose.slides.Presentation();
try {
const slide = presentation.getSlides().get_Item(firstSlideIndex);
const chart = slide.getShapes().addChart(aspose.slides.ChartType.ClusteredColumn, 20, 20, 500, 200);
const chartData = chart.getChartData();
const workbook = chartData.getChartDataWorkbook();
chartData.getSeries().clear();
chartData.getCategories().clear();
const seriesNameCell = workbook.getCell(worksheetIndex, headerRowIndex, firstSeriesColumnIndex, "Series 1");
const chartType = chart.getType();
const series = chartData.getSeries().add(seriesNameCell, chartType);
for (let categoryIndex = 0; categoryIndex < categoryNames.length; categoryIndex++) {
const dataRowIndex = firstDataRowIndex + categoryIndex;
const categoryName = categoryNames[categoryIndex];
const seriesValue = seriesValues[categoryIndex];
const categoryCell = workbook.getCell(worksheetIndex, dataRowIndex, categoryColumnIndex, categoryName);
chartData.getCategories().add(categoryCell);
const valueCell = workbook.getCell(worksheetIndex, dataRowIndex, firstSeriesColumnIndex, seriesValue);
series.getDataPoints().addDataPointForBarSeries(valueCell);
}
const automaticSeriesColor = series.getAutomaticSeriesColor();
series.getFormat().getFill().setFillType(solidFillType);
series.getFormat().getFill().getSolidFillColor().setColor(automaticSeriesColor);
series.setInvertIfNegative(true);
series.getInvertedSolidFillColor().setColor(redColor);
presentation.save("inverted_solid_fill_color.pptx", aspose.slides.SaveFormat.Pptx);
} finally {
presentation.dispose();
}
結果:

ポイント単位で反転を有効にするには、ChartDataPoint.setInvertIfNegative を使用します。次の例では、シリーズ全体の反転を無効にし、選択したポイントだけに有効にしています。そのポイントには負の値も割り当てて、効果が確認できるようにしています。
const aspose = {};
aspose.slides = require("aspose.slides.via.java");
const java = require("java");
const firstSlideIndex = 0;
const firstSeriesIndex = 0;
const targetDataPointIndex = 2;
const negativeValue = -30;
const solidFillType = java.newByte(aspose.slides.FillType.Solid);
const redColor = java.getStaticFieldValue("java.awt.Color", "RED");
const presentation = new aspose.slides.Presentation();
try {
const slide = presentation.getSlides().get_Item(firstSlideIndex);
const chart = slide.getShapes().addChart(aspose.slides.ChartType.ClusteredColumn, 20, 20, 500, 200);
const series = chart.getChartData().getSeries().get_Item(firstSeriesIndex);
const automaticSeriesColor = series.getAutomaticSeriesColor();
series.getFormat().getFill().setFillType(solidFillType);
series.getFormat().getFill().getSolidFillColor().setColor(automaticSeriesColor);
series.getInvertedSolidFillColor().setColor(redColor);
series.setInvertIfNegative(false);
const dataPoint = series.getDataPoints().get_Item(targetDataPointIndex);
dataPoint.getValue().getAsCell().setValue(negativeValue);
dataPoint.setInvertIfNegative(true);
presentation.save("data_point_invert_color_if_negative.pptx", aspose.slides.SaveFormat.Pptx);
} finally {
presentation.dispose();
}
特定のデータポイント値をクリアする
他のポイントを削除せずに 1 つのポイントだけを空にするには、対応するワークブックセルを null に設定します。列チャートの場合、プロットされた値は ChartDataPoint.getValue で取得できます。データポイントは同じカテゴリ位置に残りますが、チャートはブランク値設定に従ってその値を空として扱います。
以下の例は、最初のシリーズの 2 番目のポイントだけをクリアします。
const aspose = {};
aspose.slides = require("aspose.slides.via.java");
const firstSlideIndex = 0;
const firstSeriesIndex = 0;
const targetDataPointIndex = 1;
const presentation = new aspose.slides.Presentation();
try {
const slide = presentation.getSlides().get_Item(firstSlideIndex);
const chart = slide.getShapes().addChart(aspose.slides.ChartType.ClusteredColumn, 20, 20, 500, 200);
const series = chart.getChartData().getSeries().get_Item(firstSeriesIndex);
const dataPoint = series.getDataPoints().get_Item(targetDataPointIndex);
dataPoint.getValue().getAsCell().setValue(null);
presentation.save("clear_data_point_value.pptx", aspose.slides.SaveFormat.Pptx);
} finally {
presentation.dispose();
}
散布図は X と Y のセルが別々にあり、バブルチャートはサイズセルも使用します。削除したい値が格納されたセルだけをクリアしてください。系列全体のポイントを削除したい場合は、ChartDataPointCollection.clear を使用してください。
空セルの表示を制御する
値を含む非表示セルは、空セルとは別個のケースです。非表示のワークシート行や列からデータを含めるか除外するには、Include Data from Hidden Rows and Columns を参照してください。
空のワークブックセルはデータが欠落していることを表し、0 が入ったセルは既知の数値を表します。セルを空にするには、ChartDataCell.setValue に null を渡します。数値のゼロは、ブランクセル設定に関係なくゼロのままです。
Chart.setDisplayBlanksAs を使用して、チャートが空セルをどのように表示するかを選択します。この設定はチャート全体に適用され、空白のプロット方法を変更しますが、空のワークブックセルをゼロや補間値で埋めることはありません。
以下の自己完結型例は、1 系列の折れ線グラフを作成し、Day 3 の値をクリアし、各モードで同じチャートを保存します。入力ファイルは不要です。ChartDataWorkbook はワークシート 0、列 0 にカテゴリラベル、列 1 に値を使用し、行 0 にシリーズ名を保持します。最終データは 10, 20, empty, 30, 40 です。
const aspose = {};
aspose.slides = require("aspose.slides.via.java");
const presentation = new aspose.slides.Presentation();
try {
const slide = presentation.getSlides().get_Item(0);
const chart = slide.getShapes().addChart(aspose.slides.ChartType.LineWithMarkers, 40, 40, 640, 400);
const chartData = chart.getChartData();
const workbook = chartData.getChartDataWorkbook();
chartData.getSeries().clear();
chartData.getCategories().clear();
const seriesNameCell = workbook.getCell(0, 0, 1, "Measurements");
const series = chartData.getSeries().add(seriesNameCell, chart.getType());
const values = [10, 20, 25, 30, 40];
for (let i = 0; i < values.length; i++) {
const categoryCell = workbook.getCell(0, i + 1, 0, "Day " + (i + 1));
chartData.getCategories().add(categoryCell);
const valueCell = workbook.getCell(0, i + 1, 1, values[i]);
series.getDataPoints().addDataPointForLineSeries(valueCell);
}
// Day 3 を実際に空のままにし、カテゴリとデータポイントは保持します。
workbook.getCell(0, 3, 1).setValue(null);
const modes = [aspose.slides.DisplayBlanksAsType.Gap, aspose.slides.DisplayBlanksAsType.Zero, aspose.slides.DisplayBlanksAsType.Span];
const modeNames = ["Gap", "Zero", "Span"];
for (let i = 0; i < modes.length; i++) {
chart.setDisplayBlanksAs(modes[i]);
presentation.save("empty_cells_" + modeNames[i] + ".pptx", aspose.slides.SaveFormat.Pptx);
}
} finally {
presentation.dispose();
}
各出力ファイルは保存前に設定したモードを保持します:empty_cells_Gap.pptx、empty_cells_Zero.pptx、empty_cells_Span.pptx。1 つのバージョンだけを保存したい場合は、目的のモードを設定してプレゼンテーションを一度だけ保存してください。
以下の比較は、3 つのファイルすべてで同じデータがどのように表示されるかを示しています。Day 3 はすべてのケースでワークブック上で空です。

可視効果はチャートタイプによって異なります。折れ線グラフはすべてのモードを比較しやすいですが、棒や列のチャートは欠落したカテゴリをつなげる線がないため、Span は上図のような接続セグメントを生成できません。欠落した列とゼロ高さの列は見た目が似ることがあります。同様に、マーカーのみの散布図も接続線がありません。すべてのチャートタイプで 3 つの結果が得られるとは限らないため、使用するタイプで出力を確認してください。
シリーズのギャップ幅を設定する
ギャップ幅は、隣接する棒または列クラスター間のスペースを棒または列幅のパーセンテージで表したものです。オーバーラップと同様に、ギャップ幅は個々のシリーズではなく、親シリーズグループに属します。ChartSeriesGroup.setGapWidth をグループに対して一度呼び出してください。値を大きくするとクラスター間のスペースが広がり、値を小さくすると密集します。
以下の例はギャップ幅を変更し、最終プレゼンテーションだけを保存します。
const aspose = {};
aspose.slides = require("aspose.slides.via.java");
const firstSlideIndex = 0;
const firstSeriesIndex = 0;
const gapWidthPercent = 30;
const presentation = new aspose.slides.Presentation();
try {
const slide = presentation.getSlides().get_Item(firstSlideIndex);
const chart = slide.getShapes().addChart(aspose.slides.ChartType.StackedColumn, 20, 20, 500, 200);
const series = chart.getChartData().getSeries().get_Item(firstSeriesIndex);
series.getParentSeriesGroup().setGapWidth(gapWidthPercent);
presentation.save("gap_width_30.pptx", aspose.slides.SaveFormat.Pptx);
} finally {
presentation.dispose();
}
結果:

シリーズラインを表示または非表示にする
シリーズラインは、チャートの関連部分を視覚的に接続します。ChartSeriesGroup.setSeriesLines を使用して、対応するスタック棒やスタック列チャート、Pie of Pie、Bar of Pie チャートで表示または非表示にできます。2 次元のスタック棒・列チャートでは、カテゴリ間のスタック境界を接続します。Pie of Pie と Bar of Pie では、メインプロットとサブプロットを接続します。この設定は他のチャートタイプ用の汎用コネクタではありません。
グループには ChartSeries.getParentSeriesGroup を介してアクセスします。この設定はそのグループ内のすべてのシリーズに適用されます。ChartSeries.hasSeriesLines は読み取り専用で、親グループの設定を示します。変更するにはグループのセッターを呼び出してください。
以下の例は、デフォルトデータの PieOfPie チャートを作成し、シリーズラインを有効にしたバージョンと無効にしたバージョンの 2 つのプレゼンテーションを保存して比較します。
const aspose = { slides: require("aspose.slides.via.java") };
const presentation = new aspose.slides.Presentation();
try {
const slide = presentation.getSlides().get_Item(0);
const chart = slide.getShapes().addChart(aspose.slides.ChartType.PieOfPie, 50, 50, 600, 400);
const series = chart.getChartData().getSeries().get_Item(0);
const seriesGroup = series.getParentSeriesGroup();
seriesGroup.setSeriesLines(true);
presentation.save("series_lines_enabled.pptx", aspose.slides.SaveFormat.Pptx);
seriesGroup.setSeriesLines(false);
presentation.save("series_lines_disabled.pptx", aspose.slides.SaveFormat.Pptx);
} finally {
presentation.dispose();
}
| Series lines enabled | Series lines disabled |
|---|---|
![]() |
![]() |
| The two lines connect the main pie to the secondary pie. | Both pies remain visible, but the connecting lines are hidden. |
シリーズラインは、データラベルのリーダーライン(ラベルとデータポイントを接続)や、軸目盛りを示すグリッドライン、データ値を表す折れ線チャートの線とは異なります。この設定はそれらの要素を制御しません。
FAQ
Which chart types support data series?
All chart types represented by the ChartType enumeration use chart data, but their series do not all have the same value structure or settings. For example, category charts use categories and values, scatter charts use X and Y values, and bubble charts add bubble sizes. Use the data-point creation method that matches the series type. Options such as overlap and gap width apply only to compatible bar or column groups.
What is a chart series group?
A ChartSeriesGroup contains compatible series that share group-level plotting settings. A combination chart can contain more than one group, so changing the group reached through one series does not necessarily change every series in the chart.
Does a newly created chart contain default data?
Yes. By default, ShapeCollection.addChart creates sample series, categories, and values. You can edit those cells or clear both the series and category collections before adding a completely custom data set. An overload can also create a chart without default data.
How are chart objects connected to workbook cells?
Series names, category labels, and data-point values reference cells in a ChartDataWorkbook. Changing a referenced cell updates the corresponding chart element. When you build custom data, keep category rows and series-value rows aligned so that each point is plotted under the intended category.
How do I clear one point instead of the whole series?
Set the relevant value cell to null to retain the point’s category position as an empty point. Use ChartDataPointCollection.clear only when you intend to remove all points from that series. If you also remove categories, update every series so their values remain aligned with the category collection.
How are empty points displayed?
The result depends on the chart type and the value configured through Chart.setDisplayBlanksAs. Supported charts can display blanks as gaps, as zero values, or by connecting neighboring points. Choose the setting that matches the meaning of missing data in your presentation. See Control the Display of Empty Cells for a complete example and visual comparison.
How are negative values formatted?
For supported bar, column, and bubble series, call ChartSeries.setInvertIfNegative and set the color returned by ChartSeries.getInvertedSolidFillColor. You can override the behavior for an individual point with ChartDataPoint.setInvertIfNegative. These methods affect formatting, not the stored numeric values.
Which formatting wins when both a series and a point are formatted?
Explicit data-point formatting takes precedence for that point. Other points continue to use the explicit series format or, when the series format is not defined, the automatic chart style and theme. Group settings such as overlap and gap width control layout and are not point-level formatting overrides.
Is there a limit to how many series a chart can contain?
Aspose.Slides does not impose a separate fixed series-count limit. In practice, presentation file constraints, available memory, rendering time, and chart readability determine a useful limit.
What should I change when columns are too close together or too far apart?
Call ChartSeriesGroup.setGapWidth on the appropriate parent series group. Increase the value to widen the space between clusters, or decrease it to bring the clusters closer together.

