Z axel

Möjliga användningsscenario

För vissa 3-D diagram som 3-D pelare, 3-D kon, eller 3-D pyramid som har en djup (serie) axel, även känd som Z-axeln, som du kan ändra. Du kan specificera intervallet mellan tickmarkeringar, axeletiketter och andra operationer.

Hantera primär- och sekundäraxel som i Microsoft Excel

Se följande provkod som skapar en ny Excel-fil och lägger in värdena för diagrammet i den första arbetsboken. Sedan lägger vi till ett diagram och ställer in diagramtypen till Kolumn3D, sedan kan du se att Z-axeln också kallas Djupaxel.

todo:image_alt_text

Följande exempelkod genererar utdata Excel-fil.

Exempelkod

// 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