设置图表数据标签的形状类型
Contents
[
Hide
]
可能的使用场景
您可以使用DataLabels.ShapeType属性更改图表的数据标签的形状类型。它采用DataLabelShapeType枚举的值,并相应地更改数据标签的形状类型。其中一些取值为
DataLabelShapeType.BentLineCallout
DataLabelShapeType.DownArrowCallout
DataLabelShapeType.Ellipse
DataLabelShapeType.LineCallout
DataLabelShapeType.Rect
etc.
设置图表数据标签的形状类型
以下示例代码将图表的数据标签形状类型更改为DataLabelShapeType.WedgeEllipseCallout。请参阅此代码中使用的示例Excel文件和由其生成的输出Excel文件。截图显示了代码对示例Excel文件的效果。
示例代码
This file contains hidden or 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
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET | |
//Load source Excel file | |
Workbook wb = new Workbook("sampleSetShapeTypeOfDataLabelsOfChart.xlsx"); | |
//Access first worksheet | |
Worksheet ws = wb.Worksheets[0]; | |
//Access first chart | |
Chart ch = ws.Charts[0]; | |
//Access first series | |
Series srs = ch.NSeries[0]; | |
//Set the shape type of data labels i.e. Speech Bubble Oval | |
srs.DataLabels.ShapeType = DataLabelShapeType.WedgeEllipseCallout; | |
//Save the output Excel file | |
wb.Save("outputSetShapeTypeOfDataLabelsOfChart.xlsx"); |