Set the Shape Type of Data Labels of Chart
Contents
[
Hide
]
Possible Usage Scenarios
You can change the shape type of data labels of the chart using the DataLabels.ShapeType property. It takes the value of DataLabelShapeType enumeration and changes the shape type of data labels accordingly. Some of its values are
DataLabelShapeType.BentLineCallout
DataLabelShapeType.DownArrowCallout
DataLabelShapeType.Ellipse
DataLabelShapeType.LineCallout
DataLabelShapeType.Rect
etc.
Set the Shape Type of Data Labels of Chart
The following sample code changes the shape type of data labels of the chart to DataLabelShapeType.WedgeEllipseCallout. Please see the sample Excel file used in this code and the output Excel file generated by it. The screenshot shows the effect of the code on sample Excel file.
Sample Code
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"); |