ShapeCollection.AddShapeInChart

AddShapeInChart(MsoDrawingType, PlacementType, int, int, int, int, byte[])

Add a shape to chart .All unit is 1/4000 of chart area.

public Shape AddShapeInChart(MsoDrawingType type, PlacementType placement, int left, int top, 
    int right, int bottom, byte[] imageData)
ParameterTypeDescription
typeMsoDrawingTypeThe drawing type.
placementPlacementTypethe placement type.
leftInt32In unit of 1/4000 chart area width.
topInt32In unit of 1/4000 chart area height.
rightInt32In unit of 1/4000 chart area width.
bottomInt32In unit of 1/4000 chart area height.
imageDataByte[]If the shape is not a picture or ole object,imageData should be null.

See Also


AddShapeInChart(MsoDrawingType, PlacementType, int, int, int, int)

Add a shape to chart .All unit is 1/4000 of chart area.

public Shape AddShapeInChart(MsoDrawingType type, PlacementType placement, int left, int top, 
    int right, int bottom)
ParameterTypeDescription
typeMsoDrawingTypeThe drawing type.
placementPlacementTypethe placement type.
leftInt32In unit of 1/4000 chart area width.
topInt32In unit of 1/4000 chart area height.
rightInt32In unit of 1/4000 chart area width.
bottomInt32In unit of 1/4000 chart area height.

Examples

using System;
using Aspose.Cells;
using Aspose.Cells.Charts;
using Aspose.Cells.Drawing;

namespace AsposeCellsExamples
{
    public class ShapeCollectionMethodAddShapeInChartWithMsoDrawingTypePlacementTypeIntDemo
    {
        public static void Run()
        {
            Workbook workbook = new Workbook();
            Worksheet worksheet = workbook.Worksheets[0];

            // Add sample data for chart
            worksheet.Cells["A1"].PutValue("Category");
            worksheet.Cells["A2"].PutValue("A");
            worksheet.Cells["A3"].PutValue("B");
            worksheet.Cells["A4"].PutValue("C");
            worksheet.Cells["B1"].PutValue("Value");
            worksheet.Cells["B2"].PutValue(10);
            worksheet.Cells["B3"].PutValue(20);
            worksheet.Cells["B4"].PutValue(30);

            // Add a chart
            int chartIndex = worksheet.Charts.Add(ChartType.Column, 5, 1, 20, 10);
            Chart chart = worksheet.Charts[chartIndex];
            chart.NSeries.Add("B2:B4", true);
            chart.NSeries.CategoryData = "A2:A4";
            
            // Add shape to chart
            chart.Shapes.AddShapeInChart(MsoDrawingType.CheckBox, PlacementType.Move, 100, 100, 1000, 1000);
            
            // Set shape text
            chart.Shapes[0].Text = "Sample CheckBox";
            
            // Save workbook
            workbook.Save("AddShapeInChartWithMsoDrawingType.xlsx");
        }
    }
}

See Also