[]
        
(Showing Draft Content)

GrapeCity.Documents.Excel.Drawing.IShapes.AddChartInPixel

AddChartInPixel Method

AddChartInPixel(ChartType, double, double, double, double)

Creates a chart at the specified location on the active sheet.

This method positions the chart by using pixel-based coordinates and size values. The returned IShape represents the newly created chart shape.

Declaration
IShape AddChartInPixel(ChartType chartType, double left, double top, double width, double height)
Function AddChartInPixel(chartType As ChartType, left As Double, top As Double, width As Double, height As Double) As IShape
Parameters
Type Name Description
ChartType chartType

The chart type.

double left

The distance, in pixels, from the left edge of the object to the left edge of column A (on a worksheet) or the left edge of the chart area (on a chart).

double top

The distance, in pixels, from the top edge of the new chart shape to the top edge of the worksheet.

double width

The width, in pixels, of the object.

double height

The height, in pixels, of the object.

Returns
Type Description
IShape

The IShape object.

Examples
worksheet.Range["A1:B4"].Value = new object[,] {
    {"Month", "Sales"},
    {"Jan", 100},
    {"Feb", 120},
    {"Mar", 140}
};
IShape shape = worksheet.Shapes.AddChartInPixel(ChartType.ColumnClustered, 20, 30, 320, 220);
shape.Chart.SeriesCollection.Add(worksheet.Range["A1:B4"], RowCol.Columns, true, true);

AddChartInPixel(string, ChartType, double, double, double, double)

Creates a chart with the specified name at the specified location on the active sheet.

The chart position and size are measured in pixels.

Declaration
IShape AddChartInPixel(string name, ChartType chartType, double left, double top, double width, double height)
Function AddChartInPixel(name As String, chartType As ChartType, left As Double, top As Double, width As Double, height As Double) As IShape
Parameters
Type Name Description
string name

The chart name.

ChartType chartType

The chart type.

double left

The distance, in pixels, from the left edge of the object to the left edge of column A (on a worksheet) or the left edge of the chart area (on a chart).

double top

The distance, in pixels, from the top edge of the new chart shape to the top edge of the worksheet.

double width

The width, in pixels, of the object.

double height

The height, in pixels, of the object.

Returns
Type Description
IShape

The IShape object that represents the new chart.

Examples
worksheet.Range["A1:B4"].Value = new object[,] {
    {"Month", "Sales"},
    {"Jan", 100},
    {"Feb", 120},
    {"Mar", 140}
};
IShape shape = worksheet.Shapes.AddChartInPixel("SalesChart", ChartType.ColumnClustered, 20, 30, 320, 220);
shape.Chart.SeriesCollection.Add(worksheet.Range["A1:B4"], RowCol.Columns, true, true);