ChartCollection.AddFloatingChart

ChartCollection.AddFloatingChart method

Adds a chart to the collection.

public int AddFloatingChart(ChartType type, int left, int top, int width, int height)
ParameterTypeDescription
typeChartTypeChart type
leftInt32The x offset to corner
topInt32The y offset to corner
widthInt32The chart width
heightInt32The chart height

Return Value

Chart object index.

Examples

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

namespace AsposeCellsExamples
{
    public class ChartCollectionMethodAddFloatingChartWithChartTypeInt32Int32Int32Int32Demo
    {
        public static void Run()
        {
            Workbook workbook = new Workbook();
            Worksheet sheet = workbook.Worksheets[0];
            
            // Add floating chart with specified dimensions
            int chartIndex = sheet.Charts.AddFloatingChart(ChartType.Column, 100, 100, 600, 400);
            Aspose.Cells.Charts.Chart chart = sheet.Charts[chartIndex];
            
            // Add sample data to the chart
            chart.NSeries.Add("{1,3,2,5}", false);
            
            // Save the workbook
            workbook.Save("output.xlsx");
        }
    }
}

See Also