チャートに存在する軸を特定する

チャートに存在する軸を特定する

次のスクリーンショットは、プライマリ カテゴリと値軸のみを含むグラフを示しています。セカンダリ カテゴリと値軸はありません。

todo:画像_代替_文章

次のサンプル コードは、[Chart.hasAxis(int axisType, boolean isPrimary)](https://reference.aspose.com/cells/java/com.aspose.cells/chart#hasAxis(int,%20boolean)を使用して、サンプル グラフにプライマリおよびセカンダリ カテゴリと値軸があるかどうかを判断します。コードのコンソール出力を以下に示します。これは、プライマリ カテゴリおよび値軸に対して true を表示し、セカンダリ カテゴリおよび値軸に対して false を表示します。

Java チャートに存在する軸を決定するコード

// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-Java
// The path to the documents directory.
String dataDir = Utils.getDataDir(DetermineWhichAxisExistsInChart.class);
// Create workbook object
Workbook workbook = new Workbook(dataDir + "source.xlsx");
// Access the first worksheet
Worksheet worksheet = workbook.getWorksheets().get(0);
// Access the chart
Chart chart = worksheet.getCharts().get(0);
// Determine which axis exists in chart
boolean ret = chart.hasAxis(AxisType.CATEGORY, true);
System.out.println("Has Primary Category Axis: " + ret);
ret = chart.hasAxis(AxisType.CATEGORY, false);
System.out.println("Has Secondary Category Axis: " + ret);
ret = chart.hasAxis(AxisType.VALUE, true);
System.out.println("Has Primary Value Axis: " + ret);
ret = chart.hasAxis(AxisType.VALUE, false);
System.out.println("Has Secondary Value Axis: " + ret);

サンプル コードによって生成されたコンソール出力

上記のサンプル コードのコンソール出力を次に示します。

Has Primary Category Axis: true

Has Secondary Category Axis: false

Has Primary Value Axis: true

Has Secondary Value Axis: false