Spread Windows Forms 12.0 Product Documentation
AddChart(CellRange,Type,Int32,Int32,Int32,Int32,ChartViewType,Boolean) Method
Example 


FarPoint.Win.Spread Assembly > FarPoint.Win.Spread Namespace > SheetView Class > AddChart Method : AddChart(CellRange,Type,Int32,Int32,Int32,Int32,ChartViewType,Boolean) Method
The range of data used in the chart.
Type of the series.
Width of the chart.
Height of the chart.
The x-position.
The y-position.
Type of the view.
If set to true, the new chart will have a default legend area; otherwise, there is no legend area.
Adds the chart control.
Syntax
'Declaration
 
Public Overloads Function AddChart( _
   ByVal cellRange As CellRange, _
   ByVal seriesType As Type, _
   ByVal width As Integer, _
   ByVal height As Integer, _
   ByVal x As Integer, _
   ByVal y As Integer, _
   ByVal viewType As ChartViewType, _
   ByVal showLegend As Boolean _
) As SpreadChart
'Usage
 
Dim instance As SheetView
Dim cellRange As CellRange
Dim seriesType As Type
Dim width As Integer
Dim height As Integer
Dim x As Integer
Dim y As Integer
Dim viewType As ChartViewType
Dim showLegend As Boolean
Dim value As SpreadChart
 
value = instance.AddChart(cellRange, seriesType, width, height, x, y, viewType, showLegend)
public SpreadChart AddChart( 
   CellRange cellRange,
   Type seriesType,
   int width,
   int height,
   int x,
   int y,
   ChartViewType viewType,
   bool showLegend
)

Parameters

cellRange
The range of data used in the chart.
seriesType
Type of the series.
width
Width of the chart.
height
Height of the chart.
x
The x-position.
y
The y-position.
viewType
Type of the view.
showLegend
If set to true, the new chart will have a default legend area; otherwise, there is no legend area.
Remarks
The cellRange parameter indicates the data that is used by the chart. The seriesType parameter indicates which type of chart will be added. The chartWidth and chartHeight parameters specify the size (width and height) of the chart. The absolute position is specified by the x and y parameters. The ChartViewType parameter is the view type of the chart (2D or 3D). The showLegend parameter indicates whether to show a default legend area in the chart.
Example
This example adds values to the Spread control and then creates a chart.
fpSpread1.Sheets[0].Cells[0, 1].Value = "c1";
fpSpread1.Sheets[0].Cells[0, 2].Value = "c2";
fpSpread1.Sheets[0].Cells[0, 3].Value = "c3";
fpSpread1.Sheets[0].Cells[1, 0].Value = "s1";
fpSpread1.Sheets[0].Cells[2, 0].Value = "s2";
fpSpread1.Sheets[0].Cells[3, 0].Value = "s3";
fpSpread1.Sheets[0].Cells[4, 0].Value = "s4";
fpSpread1.Sheets[0].Cells[5, 0].Value = "s5";
fpSpread1.Sheets[0].Cells[6, 0].Value = "s6";

fpSpread1.Sheets[0].Cells[1, 1].Value = 1;
fpSpread1.Sheets[0].Cells[2, 1].Value = 2;
fpSpread1.Sheets[0].Cells[3, 1].Value = 3;
fpSpread1.Sheets[0].Cells[4, 1].Value = 4;
fpSpread1.Sheets[0].Cells[5, 1].Value = 5;
fpSpread1.Sheets[0].Cells[6, 1].Value = 6;

fpSpread1.Sheets[0].Cells[1, 2].Value = 7;
fpSpread1.Sheets[0].Cells[2, 2].Value = 8;
fpSpread1.Sheets[0].Cells[3, 2].Value = 9;
fpSpread1.Sheets[0].Cells[4, 2].Value = 10;
fpSpread1.Sheets[0].Cells[5, 2].Value = 11;
fpSpread1.Sheets[0].Cells[6, 2].Value = 12;

fpSpread1.Sheets[0].Cells[1, 3].Value = 13;
fpSpread1.Sheets[0].Cells[2, 3].Value = 14;
fpSpread1.Sheets[0].Cells[3, 3].Value = 15;
fpSpread1.Sheets[0].Cells[4, 3].Value = 16;
fpSpread1.Sheets[0].Cells[5, 3].Value = 17;
fpSpread1.Sheets[0].Cells[6, 3].Value = 18;

FarPoint.Win.Spread.Model.CellRange range = new FarPoint.Win.Spread.Model.CellRange(0, 0, 7, 4);
fpSpread1.Sheets[0].AddChart(range, typeof(FarPoint.Win.Chart.BarSeries), 400, 300, 0, 0, FarPoint.Win.Chart.ChartViewType.View3D, false);
fpSpread1.Sheets(0).Cells(0, 1).Value = "c1"
fpSpread1.Sheets(0).Cells(0, 2).Value = "c2"
fpSpread1.Sheets(0).Cells(0, 3).Value = "c3"
fpSpread1.Sheets(0).Cells(1, 0).Value = "s1"
fpSpread1.Sheets(0).Cells(2, 0).Value = "s2"
fpSpread1.Sheets(0).Cells(3, 0).Value = "s3"
fpSpread1.Sheets(0).Cells(4, 0).Value = "s4"
fpSpread1.Sheets(0).Cells(5, 0).Value = "s5"
fpSpread1.Sheets(0).Cells(6, 0).Value = "s6"

fpSpread1.Sheets(0).Cells(1, 1).Value = 1
fpSpread1.Sheets(0).Cells(2, 1).Value = 2
fpSpread1.Sheets(0).Cells(3, 1).Value = 3
fpSpread1.Sheets(0).Cells(4, 1).Value = 4
fpSpread1.Sheets(0).Cells(5, 1).Value = 5
fpSpread1.Sheets(0).Cells(6, 1).Value = 6

fpSpread1.Sheets(0).Cells(1, 2).Value = 7
fpSpread1.Sheets(0).Cells(2, 2).Value = 8
fpSpread1.Sheets(0).Cells(3, 2).Value = 9
fpSpread1.Sheets(0).Cells(4, 2).Value = 10
fpSpread1.Sheets(0).Cells(5, 2).Value = 11
fpSpread1.Sheets(0).Cells(6, 2).Value = 12

fpSpread1.Sheets(0).Cells(1, 3).Value = 13
fpSpread1.Sheets(0).Cells(2, 3).Value = 14
fpSpread1.Sheets(0).Cells(3, 3).Value = 15
fpSpread1.Sheets(0).Cells(4, 3).Value = 16
fpSpread1.Sheets(0).Cells(5, 3).Value = 17
fpSpread1.Sheets(0).Cells(6, 3).Value = 18

Dim range As New FarPoint.Win.Spread.Model.CellRange(0, 0, 7, 4)
fpSpread1.Sheets(0).AddChart(range, GetType(FarPoint.Win.Chart.BarSeries), 400, 300, 0, 0, FarPoint.Win.Chart.ChartViewType.View3D, False)
See Also

Reference

SheetView Class
SheetView Members
Overload List