Change Tick Label Direction with Node.js via C++

Change Tick Label Direction

Aspose.Cells provides you with the ability to change the chart tick label direction by using the TickLabels.getDirectionType() property. The TickLabels.getDirectionType() property accepts the ChartTextDirectionType enumeration value. The ChartTextDirectionType enumeration provides the following members:

  • Horizontal
  • Vertical
  • Rotate90
  • Rotate270
  • Stacked

The following image compares the source and output files

Source file image

todo:image_alt_text

Output file image

todo:image_alt_text

The following code snippet changes the tick label direction from Rotate90 to Horizontal.

Sample Code

const path = require("path");
const AsposeCells = require("aspose.cells.node");

// The path to the documents directory.
const sourceDir = path.join(__dirname, "data");
const outputDir = path.join(__dirname, "output");
const filePath = path.join(sourceDir, "SampleChangeTickLabelDirection.xlsx");

// Loads the workbook which contains hidden external links
const workbook = new AsposeCells.Workbook(filePath);

const worksheet = workbook.getWorksheets().get(0);

// Load the chart from source worksheet
const chart = worksheet.getCharts().get(0);

chart.getCategoryAxis().getTickLabels().setDirectionType(AsposeCells.ChartTextDirectionType.Horizontal);

// Output the file
workbook.save(path.join(outputDir, "outputChangeChartDataLableDirection.xlsx"));

The source and output files can be downloaded from the following links.

Source File

Output File