Z軸
Contents
[
Hide
]
可能な使用シナリオ
3-D列や3-Dコーン、または3-Dピラミッドなどの一部の3-Dチャートには深度(系列)軸として知られるZ軸があります。この軸の間隔、軸ラベル、およびその他の操作を指定することができます。
Microsoft Excelのようにプライマリおよびセカンダリ軸を処理する
新しいExcelファイルを作成し、チャートの値を最初のワークシートに入力した後、チャートを追加し、チャートの種類を3D列に設定します。すると、深度軸であるZ軸が表示されます。
以下のサンプルコードは出力Excelファイルを生成します。
サンプルコード
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Create an instance of Workbook | |
Workbook workbook = new Workbook(); | |
// Get the first worksheet | |
Worksheet worksheet = workbook.getWorksheets().get(0); | |
// Put values to cells for creating chart | |
worksheet.getCells().get("A1").putValue("A"); | |
worksheet.getCells().get("B1").putValue("B"); | |
worksheet.getCells().get("C1").putValue("C"); | |
worksheet.getCells().get("A2").putValue(2); | |
worksheet.getCells().get("A3").putValue(1); | |
worksheet.getCells().get("B2").putValue(2); | |
worksheet.getCells().get("B3").putValue(3); | |
worksheet.getCells().get("C2").putValue(2); | |
worksheet.getCells().get("C3").putValue(3); | |
// Add a chart to the worksheet | |
int chartIndex = worksheet.getCharts().add(ChartType.COLUMN_3_D, 9, 6, 25, 16); | |
// Access the instance of the newly added chart | |
Chart chart = worksheet.getCharts().get(chartIndex); | |
// Calculate the hart | |
chart.calculate(); | |
// Add SeriesCollection (chart data source) to the chart ranging from "A2" cell to "C3" | |
chart.setChartDataRange("A2:C3", true); | |
// Hide the CategoryAxis axis | |
chart.getCategoryAxis().setVisible(false); | |
// Hide the ValueAxis axis | |
chart.getValueAxis().setVisible(false); | |
// Save the file | |
workbook.save("ZAxis.xlsx"); | |