用 Node.js via C++ 设置图表数据标签的形状类型
Contents
[
Hide
]
可能的使用场景
您可以使用 DataLabels.shapeType
属性更改图表中的数据标签的形状类型。它采用 DataLabelShapeType
枚举值,并相应地更改数据标签的形状类型。部分值包括
DataLabelShapeType.BentLineCallout
DataLabelShapeType.DownArrowCallout
DataLabelShapeType.Ellipse
DataLabelShapeType.LineCallout
DataLabelShapeType.Rect
etc.
设置图表数据标签的形状类型
以下示例代码将图表数据标签的形状类型更改为DataLabelShapeType.WedgeEllipseCallout
。请参阅此代码使用的示例Excel文件和由其生成的输出Excel文件。截屏展示了代码在示例Excel文件上的效果。
示例代码
const path = require("path");
const AsposeCells = require("aspose.cells.node");
// The path to the documents directory.
const dataDir = path.join(__dirname, "data");
const filePath = path.join(dataDir, "sampleSetShapeTypeOfDataLabelsOfChart.xlsx");
// Load source Excel file
const workbook = new AsposeCells.Workbook(filePath);
// Access first worksheet
const worksheet = workbook.getWorksheets().get(0);
// Access first chart
const chart = worksheet.getCharts().get(0);
// Access first series
const series = chart.getNSeries().get(0);
// Set the shape type of data labels i.e. Speech Bubble Oval
series.getDataLabels().setShapeType(AsposeCells.DataLabelShapeType.WedgeEllipseCallout);
// Save the output Excel file
workbook.save(path.join(dataDir, "outputSetShapeTypeOfDataLabelsOfChart.xlsx"));