Chart module

class Chart.Chart

Bases: XlsChartShape

property ChartArea: ChartArea
<summary>

Returns a ChartArea object that represents the complete chart area for the chart.

<example>The following code illustrates how to access IChartFrameFormat using ChartArea

property and set foreground color for the ChartArea:

<code> //Create worksheet Workbook workbook = new Workbook(); Worksheet worksheet = workbook.Worksheets[0]; //Add data worksheet.Range[“A1”].Text = “Jan”;

worksheet.Range[“B1”].Text = “Feb”; worksheet.Range[“C1”].Text = “Mar”; worksheet.Range[“A2”].Text = “10”; worksheet.Range[“B2”].Text = “20”; worksheet.Range[“C2”].Text = “30”;

//Create chart and range Chart chart = worksheet.Charts.Add(); chart.DataRange = worksheet.Range[“A1:C2”]; //Set chart frame format IChartFrameFormat frameFormat = chart.ChartArea; //Set color frameFormat.Fill.ForeColor = System.Drawing.Color.Red; //Save to file workbook.SaveToFile(“Chart.xlsx”); </code> </example>

</summary>

property ChartTitleArea: ChartTextArea
<summary>

Gets title text area. Read-only.

</summary>

property DataRange: CellRange
<summary>

DataRange for the chart series.

</summary>

property DataTable: ChartDataTable
<summary>

Returns a DataTable object that represents the chart data table.

<example>The following code illustrates how to set HasDataTable to “true” to enable data table

and set IChartDataTable.HasBorders to “false” to hide the borders of data table:

<code> //Create worksheet Workbook workbook = new Workbook(); Worksheet worksheet = workbook.Worksheets[0]; //Add data worksheet.Range[“A1”].Text = “Jan”;

worksheet.Range[“B1”].Text = “Feb”; worksheet.Range[“C1”].Text = “Mar”; worksheet.Range[“A2”].Text = “10”; worksheet.Range[“B2”].Text = “20”; worksheet.Range[“C2”].Text = “30”;

//Create chart and range Chart chart = worksheet.Charts.Add(); chart.DataRange = worksheet.Range[“A1:C2”]; //Set Chart data table chart.HasDataTable = true; IChartDataTable dataTable = chart.DataTable; //Set border dataTable.HasBorders = false; //Save to file workbook.SaveToFile(“Chart.xlsx”); </code> </example>

</summary>

property Floor: ChartWallOrFloor
<summary>
Returns a Floor object that represents the floor of the 3-D chart.

<example>The following code illustrates how to access IChartWallOrFloor using Floor property and set foreground color for the chart’s Floor: <code>

//Create worksheet Workbook workbook = new Workbook(); workbook.LoadFromFile(“Sample.xlsx”); Worksheet worksheet = workbook.Worksheets[0]; //Get chart Chart chart = worksheet.Charts[0]; //Set chart wall IChartWallOrFloor floor = chart.Floor; //Set color floor.Fill.FillType = ShapeFillType.SolidColor; floor.Fill.ForeColor = System.Drawing.Color.Red; //Save to file workbook.SaveToFile(“Chart.xlsx”); </code> </example>

</summary>

property Legend: ChartLegend
<summary>

Represents chart legend.

<example>The following code illustrates how to access IChartLegend using IChart.Legend

property and set IChartLegend.Position to LegendPositionType.Left:

<code> //Create worksheet Workbook workbook = new Workbook(); Worksheet worksheet = workbook.Worksheets[0]; //Add data worksheet.Range[“A1”].Text = “Jan”;

worksheet.Range[“B1”].Text = “Feb”; worksheet.Range[“C1”].Text = “Mar”; worksheet.Range[“A2”].Text = “10”; worksheet.Range[“B2”].Text = “20”; worksheet.Range[“C2”].Text = “30”;

//Create chart and range Chart chart = worksheet.Charts.Add(); chart.DataRange = worksheet.Range[“A1:C2”]; //Set chart legend and legend position IChartLegend legend = chart.Legend; legend.Position = LegendPositionType.Left; //Save to file workbook.SaveToFile(“Chart.xlsx”); </code> </example>

</summary>

property PageSetup: ChartPageSetup
<summary>

Page setup for the chart.

</summary>

property PlotArea: ChartPlotArea
<summary>

Returns a PlotArea object that represents the plot area of a chart.

<example>The following code illustrates how to access IChartFrameFormat using PlotArea

property and set foreground color for the chart’s PlotArea:

<code> //Create worksheet Workbook workbook = new Workbook(); Worksheet worksheet = workbook.Worksheets[0]; //Add data worksheet.Range[“A1”].Text = “Jan”;

worksheet.Range[“B1”].Text = “Feb”; worksheet.Range[“C1”].Text = “Mar”; worksheet.Range[“A2”].Text = “10”; worksheet.Range[“B2”].Text = “20”; worksheet.Range[“C2”].Text = “30”;

//Create chart and range Chart chart = worksheet.Charts.Add(); chart.DataRange = worksheet.Range[“A1:C2”]; //Set chart frame format IChartFrameFormat frameFormat = chart.PlotArea; //Set color frameFormat.Fill.ForeColor = System.Drawing.Color.Red; //Save to file workbook.SaveToFile(“Chart.xlsx”); </code> </example>

</summary>

property PrimaryCategoryAxis: ChartCategoryAxis
<summary>

Returns primary category axis.

</summary>

property PrimarySerieAxis: ChartSeriesAxis
<summary>

Returns primary series axis. Read-only.

</summary>

property PrimaryValueAxis: ChartValueAxis
<summary>

Returns primary value axis.

</summary>

property SecondaryCategoryAxis: ChartCategoryAxis
<summary>

Returns secondary category axis.

</summary>

property SecondaryValueAxis: ChartValueAxis
<summary>

Returns secondary value axis. Read-only.

</summary>

property Series: ChartSeries
<summary>

Returns an object that represents either a single series (a Series object) or a collection of all the series (a SeriesCollection collection) in the chart or chart group.

</summary>

property Walls: ChartWallOrFloor
<summary>
Represents chart walls.

<example>The following code illustrates how to access IChartWallOrFloor using Walls property and set foreground color for the chart’s Walls: <code>

//Create worksheet Workbook workbook = new Workbook(); workbook.LoadFromFile(“Sample.xlsx”); Worksheet worksheet = workbook.Worksheets[0]; //Get chart Chart chart = worksheet.Charts[0]; //Set chart wall IChartWallOrFloor wall = chart.Walls; //Set color wall.Fill.FillType = ShapeFillType.SolidColor; wall.Fill.ForeColor = System.Drawing.Color.Red; //Save to file workbook.SaveToFile(“Chart.xlsx”); </code> </example>

</summary>

property Workbook: Workbook
<summary>

Workbook contains the chart.

</summary>

property Worksheet: SpireObject
<summary>

Worksheet which contains the chart.

</summary>