Z轴

可能的使用场景

对于一些具有深度(系列)轴的3D图表,例如3D柱状图、3D圆锥体图或3D金字塔图,也称为Z轴,您可以进行更改。您可以指定刻度标记之间的间隔、轴标签和其他操作。

处理主轴和第二轴,就像处理Microsoft Excel一样

请参阅以下示例代码,创建一个新的Excel文件,并在第一个工作表中放置图表的值。然后我们添加一个图表并将图表类型设置为3D柱状图,然后您就可以看到Z轴,也称为深度轴。

todo:image_alt_text

以下示例代码生成输出Excel文件

示例代码

// 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");
view raw ZAxis.java hosted with ❤ by GitHub