[]
        
(Showing Draft Content)

GrapeCity.Documents.Excel.Drawing.IChart.SetSourceData

SetSourceData Method

SetSourceData(IRange, RowCol)

Sets the source data range for the chart and specifies whether each data series is taken from rows or columns.

Use the plotBy parameter to control how the chart interprets the source range when creating series and categories.

Declaration
void SetSourceData(IRange source, RowCol plotBy)
Sub SetSourceData(source As IRange, plotBy As RowCol)
Parameters
Type Name Description
IRange source

The range that contains the source data. Must not be null.

RowCol plotBy

Specifies whether the chart reads each data series from Columns or Rows.

Examples
worksheet.Range["A1:C4"].Value = new object[,] {
    {"Month", "North", "South"},
    {"Jan", 10, 12},
    {"Feb", 15, 18},
    {"Mar", 13, 16}
};
IChart chart = worksheet.Shapes.AddChart(ChartType.ColumnClustered, 20, 20, 300, 200).Chart;
chart.SetSourceData(worksheet.Range["A1:C4"], RowCol.Columns);

SetSourceData(IRange)

Sets the source data range for the chart.

The specified range is used as the chart's data source.

Declaration
void SetSourceData(IRange source)
Sub SetSourceData(source As IRange)
Parameters
Type Name Description
IRange source

The range that contains the source data. Must not be null.

Examples
IRange range = worksheet.Range["A1:B4"];
range.Value = new object[,] {
    {"Month", "Sales"},
    {"Jan", 10},
    {"Feb", 15},
    {"Mar", 12}
};
IChart chart = worksheet.Shapes.AddChart(ChartType.ColumnClustered, 20, 20, 300, 200).Chart;
chart.SetSourceData(range);