Table of Contents

Interface IChartFormat

Namespace
Spire.Xls.Core
Assembly
Spire.XLS.dll

Provides access to the formatting options for chart elements.

public interface IChartFormat

Properties

BubbleScale

Percent of largest bubble compared to chart in general. ( 0 - 300 ). The following code illustrates how to set BubbleScale for ExcelChartType.Bubble3D chart:

//Create worksheet
Workbook workbook = new Workbook();
workbook.LoadFromFile("Sample.xlsx");
Worksheet worksheet = workbook.Worksheets[0];

//Create chart and set range
IChart chart = worksheet.Charts.Add(ExcelChartType.Bubble3D);
chart.DataRange = worksheet.Range["A1:C2"];
chart.Series[0].Bubbles = worksheet.Range["A2:C3"];

//Set chart format
IChartFormat format = chart.Series[0].Format.Options;

//Set bubble scale
format.BubbleScale = 50;

//Save to file
workbook.SaveToFile("Chart.xlsx");
int BubbleScale { get; set; }

Property Value

int

DoughnutHoleSize

Size of center hole in a doughnut chart (as a percentage).( 10 - 90 ). The following code illustrates how to set DoughnutHoleSize for ExcelChartType.Doughnut chart:

//Create worksheet
Workbook workbook = new Workbook();
workbook.LoadFromFile("Sample.xlsx");
Worksheet worksheet = workbook.Worksheets[0];

//Create chart and set range
IChart chart = worksheet.Charts.Add();
chart.DataRange = worksheet.Range["A1:C2"];

//Set chart type
chart.ChartType = ExcelChartType.Doughnut;

//Set chart format
IChartFormat format = chart.Series[0].Format.Options;

//Set Doughnut hole size
format.DoughnutHoleSize = 60;

//Save to file
workbook.SaveToFile("Chart.xlsx");
int DoughnutHoleSize { get; set; }

Property Value

int

FirstDropBar

Returns object that represents first drop bar. The following code illustrates how to access FirstDropBar:

//Create worksheet
Workbook workbook = new Workbook();
workbook.LoadFromFile("Sample.xlsx");
Worksheet worksheet = workbook.Worksheets[0];

//Create chart and set range
IChart chart = worksheet.Charts.Add();
chart.DataRange = worksheet.Range["A1:C3"];

//Set chart type
chart.ChartType = ExcelChartType.Line;

//Set chart drop bar
IChartDropBar dropBar = chart.Series[0].Format.Options.FirstDropBar;
IChartDropBar FirstDropBar { get; }

Property Value

IChartDropBar

FirstSliceAngle

Angle of the first pie slice expressed in degrees. ( 0 - 360 ). The following code illustrates how to set FirstSliceAngle for ExcelChartType.Pie chart:

//Create worksheet
Workbook workbook = new Workbook();
workbook.LoadFromFile("Sample.xlsx");
Worksheet worksheet = workbook.Worksheets[0];

//Create chart and set range
IChart chart = worksheet.Charts.Add();
chart.DataRange = worksheet.Range["A1:C2"];

//Set chart type
chart.ChartType = ExcelChartType.Pie;

//Set chart format
IChartFormat format = chart.Series[0].Format.Options;

//Set Gap width
format.FirstSliceAngle = 60;

//Save to file
workbook.SaveToFile("Chart.xlsx");
int FirstSliceAngle { get; set; }

Property Value

int

GapWidth

Space between categories (percent of bar width), default = 50. The following code illustrates how to set GapWidth for ExcelChartType.Column3DStacked chart:

//Create worksheet
Workbook workbook = new Workbook();
workbook.LoadFromFile("Sample.xlsx");
Worksheet worksheet = workbook.Worksheets[0];

//Create chart and set range
IChart chart = worksheet.Charts.Add();
chart.DataRange = worksheet.Range["A1:C3"];

//Set chart type
chart.ChartType = ExcelChartType.Column3DStacked;

//Set chart format
IChartFormat format = chart.Series[0].Format.Options;

//Set Gap width
format.GapWidth = 400;

//Save to file
workbook.SaveToFile("Chart.xlsx");
int GapWidth { get; set; }

Property Value

int

HasRadarAxisLabels

True if a radar chart has axis labels. Applies only to radar charts. The following code illustrates how to hide the axis labels of radar charts:

//Create worksheet
Workbook workbook = new Workbook();
workbook.LoadFromFile("Sample.xlsx");
Worksheet worksheet = workbook.Worksheets[0];

//Create chart and set range
IChart chart = worksheet.Charts.Add();
chart.DataRange = worksheet.Range["A1:C2"];

//Set chart type
chart.ChartType = ExcelChartType.Radar;

//Set chart format
IChartFormat format = chart.Series[0].Format.Options;

//Set radar label visibility
format.HasRadarAxisLabels = false;

//Save to file
workbook.SaveToFile("Chart.xlsx");
bool HasRadarAxisLabels { get; set; }

Property Value

bool

IsVaryColor

Vary color for each data point. The following code illustrates how to set IsVaryColor for charts:

//Create worksheet
Workbook workbook = new Workbook();
workbook.LoadFromFile("Sample.xlsx");
Worksheet worksheet = workbook.Worksheets[0];

//Create chart and set range
IChart chart = worksheet.Charts.Add();
chart.DataRange = worksheet.Range["A1:C2"];

//Set chart format
IChartFormat format = chart.Series[0].Format.Options;

//Set vary color
format.IsVaryColor = true;

//Save to file
workbook.SaveToFile("Chart.xlsx");
bool IsVaryColor { get; set; }

Property Value

bool

Overlap

Space between bars ( -100 : 100 ). The following code illustrates how to set Overlap for charts:

//Create worksheet
Workbook workbook = new Workbook();
workbook.LoadFromFile("Sample.xlsx");
Worksheet worksheet = workbook.Worksheets[0];

//Create chart and set range
IChart chart = worksheet.Charts.Add();
chart.DataRange = worksheet.Range["A1:C3"];

//Set chart type
chart.ChartType = ExcelChartType.ColumnStacked;

//Set chart format
IChartFormat format = chart.Series[0].Format.Options;

//Set overlap
format.Overlap = 20;

//Save to file
workbook.SaveToFile("Chart.xlsx");
int Overlap { get; set; }

Property Value

int

PieSecondSize

Returns or sets the size of the secondary section of either a pie of pie chart or a bar of pie chart, as a percentage of the size of the primary pie. ( 5 - 200 ). The following code illustrates how to set PieSecondSize for charts:

//Create worksheet
Workbook workbook = new Workbook();
workbook.LoadFromFile("Sample.xlsx");
Worksheet worksheet = workbook.Worksheets[0];

//Create chart and set range
IChart chart = worksheet.Charts.Add();
chart.DataRange = worksheet.Range["A1:F2"];

//Set chart type
chart.ChartType = ExcelChartType.PieOfPie;

//Set chart format
IChartFormat format = chart.Series[0].Format.Options;

//Set second pie size
format.PieSecondSize = 40;

//Save to file
workbook.SaveToFile("Chart.xlsx");
int PieSecondSize { get; set; }

Property Value

int

PieSeriesLine

Represents series line properties. ( For pie of pie or pie of bar chart types only. ) Read only. The following code illusrates how to set color to IChartBorder.Color property for ExcelChartType.PieOfPie chart using PieSeriesLine property:

//Create worksheet
Workbook workbook = new Workbook();
workbook.LoadFromFile("Sample.xlsx");
Worksheet worksheet = workbook.Worksheets[0];

//Create chart and set range
IChart chart = worksheet.Charts.Add();
chart.DataRange = worksheet.Range["A1:F2"];

//Set chart type
chart.ChartType = ExcelChartType.PieOfPie;

//Set pie series line border
IChartBorder border =  chart.Series[0].Format.Options.PieSeriesLine;

//Set color
border.Color = Color.Red;

//Save to file
workbook.SaveToFile("Chart.xlsx");
IChartBorder PieSeriesLine { get; }

Property Value

IChartBorder

SecondDropBar

Returns object that represents second drop bar. The following code illustrates how to access SecondDropBar:

//Create worksheet
Workbook workbook = new Workbook();
workbook.LoadFromFile("Sample.xlsx");
Worksheet worksheet = workbook.Worksheets[0];

//Create chart and set range
IChart chart = worksheet.Charts.Add();
chart.DataRange = worksheet.Range["A1:C3"];

//Set chart type
chart.ChartType = ExcelChartType.Line;

//Set chart first drop bar
IChartDropBar dropBar = chart.Series[0].Format.Options.FirstDropBar;

//Set chart second drop bar
dropBar = chart.Series[0].Format.Options.SecondDropBar;
IChartDropBar SecondDropBar { get; }

Property Value

IChartDropBar

ShowNegativeBubbles

True to show negative bubbles. The following code illustrates how to load negative values to ExcelChartType.Bubble3D chart value axis and set ShowNegativeBubbles to "true":

//Create worksheet
Workbook workbook = new Workbook();
workbook.LoadFromFile("Sample.xlsx");
Worksheet worksheet = workbook.Worksheets[0];

//Create chart and set range
IChart chart = worksheet.Charts.Add(ExcelChartType.Bubble3D);
chart.DataRange = worksheet.Range["A1:D2"];
chart.Series[0].Bubbles = worksheet.Range["A2:C3"];

//Set chart format
IChartFormat format = chart.Series[0].Format.Options;

//Set negative bubble visibility
format.ShowNegativeBubbles = true;

//Save to file
workbook.SaveToFile("Chart.xlsx");
bool ShowNegativeBubbles { get; set; }

Property Value

bool

SizeRepresents

Returns or sets what the bubble size represents on a bubble chart. The following code illustrates how to set BubbleSizeType.Width to SizeRepresents property:

//Create worksheet
Workbook workbook = new Workbook();
workbook.LoadFromFile("Sample.xlsx");
Worksheet worksheet = workbook.Worksheets[0];

//Create chart and set range
IChart chart = worksheet.Charts.Add(ExcelChartType.Bubble3D);
chart.DataRange = worksheet.Range["A1:C2"];
chart.Series[0].Bubbles = worksheet.Range["A2:C3"];

//Set chart format
IChartFormat format = chart.Series[0].Format.Options;

//Set bubble scale and size represents
format.BubbleScale = 50;
format.SizeRepresents = BubbleSizeType.Width;

//Save to file
workbook.SaveToFile("Chart.xlsx");
BubbleSizeType SizeRepresents { get; set; }

Property Value

BubbleSizeType

SplitType

Returns or sets the way the two sections of either a pie of pie chart or a bar of pie chart are split. The following code illustrates how to set SplitType.Value to SplitType:

//Create worksheet
Workbook workbook = new Workbook();
workbook.LoadFromFile("Sample.xlsx");
Worksheet worksheet = workbook.Worksheets[0];

//Create chart and set range
IChart chart = worksheet.Charts.Add();
chart.DataRange = worksheet.Range["A1:F2"];

//Set chart type
chart.ChartType = ExcelChartType.PieOfPie;

//Set chart format
IChartFormat format = chart.Series[0].Format.Options;

//Set split type
format.SplitType = SplitType.Value;

//Save to file
workbook.SaveToFile("Chart.xlsx");
SplitType SplitType { get; set; }

Property Value

SplitType

SplitValue

Returns or sets the threshold value separating the two sections of either a pie of pie chart or a bar of pie chart. The following code illustrates how to set SplitValue for charts:

//Create worksheet
Workbook workbook = new Workbook();
workbook.LoadFromFile("Sample.xlsx");
Worksheet worksheet = workbook.Worksheets[0];

//Create chart and set range
IChart chart = worksheet.Charts.Add();
chart.DataRange = worksheet.Range["A1:F2"];

//Set chart type
chart.ChartType = ExcelChartType.PieOfPie;

//Set chart format
IChartFormat format = chart.Series[0].Format.Options;

//Set split value
format.SplitValue = 20;

//Save to file
workbook.SaveToFile("Chart.xlsx");
int SplitValue { get; set; }

Property Value

int