Interface IChartSerieDataFormat
Represents formatting options for the series data.
Inherited Members
Namespace: Syncfusion.XlsIO
Assembly: Syncfusion.XlsIO.UWP.dll
Syntax
public interface IChartSerieDataFormat : IChartFillBorder
Properties
AreaProperties
Gets the area properties of the chart. Read-only.
Declaration
IChartInterior AreaProperties { get; }
Property Value
Type |
---|
IChartInterior |
Examples
The following code illustrates how to access AreaProperties properties and set color to ForegroundColorIndex property.
using (ExcelEngine excelEngine = new ExcelEngine())
{
//Create worksheet
IApplication application = excelEngine.Excel;
application.DefaultVersion = ExcelVersion.Excel2013;
IWorkbook workbook = application.Workbooks.Create(1);
IWorksheet sheet = workbook.Worksheets[0];
//Add data
sheet.Range["A1"].Text = "Jan";
sheet.Range["B1"].Text = "Feb";
sheet.Range["C1"].Text = "Mar";
sheet.Range["A2"].Value = "10";
sheet.Range["B2"].Value = "20";
sheet.Range["C2"].Value = "30";
//Create chart
IChart chart = sheet.Charts.Add();
//Set range
chart.DataRange = sheet.Range["A1:C2"];
//Set interior
IChartInterior interior = chart.Series[0].SerieFormat.AreaProperties;
//Set color
interior.ForegroundColorIndex = ExcelKnownColors.Red;
//Save and Dispose
workbook.SaveAs("Chart.xlsx");
workbook.Close();
}
BarShapeBase
Gets or sets the base shape used with the 3-D bar or column chart.
Declaration
ExcelBaseFormat BarShapeBase { get; set; }
Property Value
Type |
---|
ExcelBaseFormat |
Examples
By default BarShapeBase is set to Rectangle. Here for example, we set Circle to BarShapeBase.
using (ExcelEngine excelEngine = new ExcelEngine())
{
//Create worksheet
IApplication application = excelEngine.Excel;
application.DefaultVersion = ExcelVersion.Excel2013;
IWorkbook workbook = application.Workbooks.Create(1);
IWorksheet sheet = workbook.Worksheets[0];
//Add data
sheet.Range["A1"].Text = "Jan";
sheet.Range["B1"].Text = "Feb";
sheet.Range["C1"].Text = "Mar";
sheet.Range["A2"].Value = "10";
sheet.Range["B2"].Value = "20";
sheet.Range["C2"].Value = "30";
//Create chart
IChart chart = sheet.Charts.Add();
//Set range
chart.DataRange = sheet.Range["A1:C2"];
//Set chart type
chart.ChartType = ExcelChartType.Bar_Stacked_3D;
//Set Bar shape base
chart.Series[0].SerieFormat.BarShapeBase = ExcelBaseFormat.Circle;
//Save and Dispose
workbook.SaveAs("Chart.xlsx");
workbook.Close();
}
BarShapeTop
Represents the top shape used with the 3-D bar or column chart.
Declaration
ExcelTopFormat BarShapeTop { get; set; }
Property Value
Type |
---|
ExcelTopFormat |
Examples
By default BarShapeTop is set to Straight. Here for example, we set Sharp to BarShapeTop property.
using (ExcelEngine excelEngine = new ExcelEngine())
{
//Create worksheet
IApplication application = excelEngine.Excel;
application.DefaultVersion = ExcelVersion.Excel2013;
IWorkbook workbook = application.Workbooks.Create(1);
IWorksheet sheet = workbook.Worksheets[0];
//Add data
sheet.Range["A1"].Text = "Jan";
sheet.Range["B1"].Text = "Feb";
sheet.Range["C1"].Text = "Mar";
sheet.Range["A2"].Value = "10";
sheet.Range["B2"].Value = "20";
sheet.Range["C2"].Value = "30";
//Create chart
IChart chart = sheet.Charts.Add();
//Set range
chart.DataRange = sheet.Range["A1:C2"];
//Set chart type
chart.ChartType = ExcelChartType.Bar_Stacked_3D;
//Set Bar shape base
chart.Series[0].SerieFormat.BarShapeTop = ExcelTopFormat.Sharp;
//Save and Dispose
workbook.SaveAs("Chart.xlsx");
workbook.Close();
}
CommonSerieOptions
Gets the common series options. Read-only.
Declaration
IChartFormat CommonSerieOptions { get; }
Property Value
Type |
---|
IChartFormat |
Examples
The following code illustrates how GapWidth can be set by accessing CommonSerieOptions property.
using (ExcelEngine excelEngine = new ExcelEngine())
{
//Create worksheet
IApplication application = excelEngine.Excel;
application.DefaultVersion = ExcelVersion.Excel2013;
IWorkbook workbook = application.Workbooks.Create(1);
IWorksheet sheet = workbook.Worksheets[0];
//Add data
sheet.Range["A1"].Text = "Jan";
sheet.Range["B1"].Text = "Feb";
sheet.Range["C1"].Text = "Mar";
sheet.Range["A2"].Value = "10";
sheet.Range["B2"].Value = "20";
sheet.Range["C2"].Value = "30";
//Create chart
IChart chart = sheet.Charts.Add();
//Set range
chart.DataRange = sheet.Range["A1:C2"];
//Set chart type
chart.ChartType = ExcelChartType.Column_Stacked_3D;
//Set common serie options
IChartFormat commonSerieOptions = chart.Series[0].SerieFormat.CommonSerieOptions;
//Set Gap width
commonSerieOptions.GapWidth = 400;
//Save and Dispose
workbook.SaveAs("Chart.xlsx");
workbook.Close();
}
Is3DBubbles
True to draw bubbles with 3D effects. otherwise False.
Declaration
bool Is3DBubbles { get; set; }
Property Value
Type |
---|
System.Boolean |
Examples
The following code illustrates how Is3DBubbles property can be used.
using (ExcelEngine excelEngine = new ExcelEngine())
{
//Create worksheet
IApplication application = excelEngine.Excel;
application.DefaultVersion = ExcelVersion.Excel2013;
IWorkbook workbook = application.Workbooks.Create(1);
IWorksheet sheet = workbook.Worksheets[0];
//Add data
sheet.Range["A1"].Value = "50";
sheet.Range["B1"].Value = "60";
sheet.Range["C1"].Value = "5";
sheet.Range["A2"].Value = "1";
sheet.Range["B2"].Value = "4";
sheet.Range["C2"].Value = "2";
//Create chart
IChart chart = sheet.Charts.Add();
//Set range
chart.DataRange = sheet.Range["A1:C2"];
//Set chart type
chart.ChartType = ExcelChartType.Bubble_3D;
//Set serie format
IChartSerieDataFormat format = chart.Series[0].SerieFormat;
//Check type
Console.WriteLine(format.Is3DBubbles);
//Save and Dispose
workbook.SaveAs("Chart.xlsx");
workbook.Close();
Console.ReadKey();
}
//Output will be
//True
IsAutoMarker
True if the series has auto marker. otherwise False.
Declaration
bool IsAutoMarker { get; set; }
Property Value
Type |
---|
System.Boolean |
Examples
The following code illustrates how IsAutoMarker property can be used.
using (ExcelEngine excelEngine = new ExcelEngine())
{
//Create worksheet
IApplication application = excelEngine.Excel;
application.DefaultVersion = ExcelVersion.Excel2013;
IWorkbook workbook = application.Workbooks.Create(1);
IWorksheet sheet = workbook.Worksheets[0];
//Add data
sheet.Range["A1"].Text = "Jan";
sheet.Range["B1"].Text = "Feb";
sheet.Range["C1"].Text = "Mar";
sheet.Range["D1"].Text = "Apr";
sheet.Range["E1"].Text = "May";
sheet.Range["F1"].Text = "Jun";
sheet.Range["A2"].Value = "5";
sheet.Range["B2"].Value = "21";
sheet.Range["C2"].Value = "15";
sheet.Range["D2"].Value = "12";
sheet.Range["E2"].Value = "28";
sheet.Range["F2"].Value = "9";
//Create chart
IChart chart = sheet.Charts.Add();
//Set range
chart.DataRange = sheet.Range["A1:F2"];
//Set chart type
chart.ChartType = ExcelChartType.Line_Markers;
//Set serie data format
IChartSerieDataFormat format = chart.Series[0].DataPoints.DefaultDataPoint.DataFormat;
//Check auto marker
Console.Write(format.IsAutoMarker);
//Save and Dispose
workbook.SaveAs("Chart.xlsx");
workbook.Close();
Console.ReadKey();
}
//Output will be
//True
IsMarkerSupported
True if the marker is supported by this chart/series. otherwise False. Read-only.
Declaration
bool IsMarkerSupported { get; }
Property Value
Type |
---|
System.Boolean |
Examples
The following code illustrates how to access the IsMarkerSupported property.
using (ExcelEngine excelEngine = new ExcelEngine())
{
//Create worksheet
IApplication application = excelEngine.Excel;
application.DefaultVersion = ExcelVersion.Excel2013;
IWorkbook workbook = application.Workbooks.Create(1);
IWorksheet sheet = workbook.Worksheets[0];
//Add data
sheet.Range["A1"].Text = "Jan";
sheet.Range["B1"].Text = "Feb";
sheet.Range["C1"].Text = "Mar";
sheet.Range["A2"].Value = "50";
sheet.Range["B2"].Value = "60";
sheet.Range["C2"].Value = "5";
//Create chart
IChart chart = sheet.Charts.Add();
//Set range
chart.DataRange = sheet.Range["A1:C2"];
//Set chart type
chart.ChartType = ExcelChartType.Pie;
//Set serie format
IChartSerieDataFormat format = chart.Series[0].SerieFormat;
//Check marker support
Console.WriteLine(format.IsMarkerSupported);
//Save and Dispose
workbook.SaveAs("Chart.xlsx");
workbook.Close();
Console.ReadKey();
}
//Output will be
//False
MarkerBackgroundColor
Gets or sets the marker fill color.
Declaration
Color MarkerBackgroundColor { get; set; }
Property Value
Type |
---|
Windows.UI.Color |
Examples
The following code illustrates how to set color to markers in charts.
using (ExcelEngine excelEngine = new ExcelEngine())
{
//Create worksheet
IApplication application = excelEngine.Excel;
application.DefaultVersion = ExcelVersion.Excel2013;
IWorkbook workbook = application.Workbooks.Create(1);
IWorksheet sheet = workbook.Worksheets[0];
//Add data
sheet.Range["A1"].Text = "Jan";
sheet.Range["B1"].Text = "Feb";
sheet.Range["C1"].Text = "Mar";
sheet.Range["A2"].Value = "10";
sheet.Range["B2"].Value = "20";
sheet.Range["C2"].Value = "30";
//Create chart
IChart chart = sheet.Charts.Add();
//Set range
chart.DataRange = sheet.Range["A1:C2"];
//Set chart type
chart.ChartType = ExcelChartType.Line;
//Set serie format
IChartSerieDataFormat format = chart.Series[0].SerieFormat;
//Set marker style
format.MarkerStyle = ExcelChartMarkerType.Circle;
//Set color
format.MarkerBackgroundColor = System.Drawing.Color.Red;
format.MarkerForegroundColor = System.Drawing.Color.Black;
//Save and Dispose
workbook.SaveAs("Chart.xlsx");
workbook.Close();
}
MarkerBackgroundColorIndex
Gets or sets the index of marker fill color from predefined colors (ExcelKnownColors).
Declaration
ExcelKnownColors MarkerBackgroundColorIndex { get; set; }
Property Value
Type |
---|
ExcelKnownColors |
Examples
The following code illustrates how to set a color from ExcelKnownColors enumeration to marker applied.
using (ExcelEngine excelEngine = new ExcelEngine())
{
//Create worksheet
IApplication application = excelEngine.Excel;
application.DefaultVersion = ExcelVersion.Excel2013;
IWorkbook workbook = application.Workbooks.Create(1);
IWorksheet sheet = workbook.Worksheets[0];
//Add data
sheet.Range["A1"].Text = "Jan";
sheet.Range["B1"].Text = "Feb";
sheet.Range["C1"].Text = "Mar";
sheet.Range["A2"].Value = "10";
sheet.Range["B2"].Value = "20";
sheet.Range["C2"].Value = "30";
//Create chart
IChart chart = sheet.Charts.Add();
//Set range
chart.DataRange = sheet.Range["A1:C2"];
//Set chart type
chart.ChartType = ExcelChartType.Line;
//Set serie format
IChartSerieDataFormat format = chart.Series[0].SerieFormat;
//Set marker style
format.MarkerStyle = ExcelChartMarkerType.Circle;
//Set color
format.MarkerBackgroundColorIndex = ExcelKnownColors.Red;
format.MarkerForegroundColorIndex = ExcelKnownColors.Black;
//Save and Dispose
workbook.SaveAs("Chart.xlsx");
workbook.Close();
}
MarkerForegroundColor
Gets or sets the marker fill color.
Declaration
Color MarkerForegroundColor { get; set; }
Property Value
Type |
---|
Windows.UI.Color |
Examples
The following code illustrates how to set color for markers in charts.
using (ExcelEngine excelEngine = new ExcelEngine())
{
//Create worksheet
IApplication application = excelEngine.Excel;
application.DefaultVersion = ExcelVersion.Excel2013;
IWorkbook workbook = application.Workbooks.Create(1);
IWorksheet sheet = workbook.Worksheets[0];
//Add data
sheet.Range["A1"].Text = "Jan";
sheet.Range["B1"].Text = "Feb";
sheet.Range["C1"].Text = "Mar";
sheet.Range["A2"].Value = "10";
sheet.Range["B2"].Value = "20";
sheet.Range["C2"].Value = "30";
//Create chart
IChart chart = sheet.Charts.Add();
//Set range
chart.DataRange = sheet.Range["A1:C2"];
//Set chart type
chart.ChartType = ExcelChartType.Line;
//Set serie format
IChartSerieDataFormat format = chart.Series[0].SerieFormat;
//Set marker style
format.MarkerStyle = ExcelChartMarkerType.Circle;
//Set color
format.MarkerBackgroundColor = System.Drawing.Color.Red;
format.MarkerForegroundColor = System.Drawing.Color.Black;
//Save and Dispose
workbook.SaveAs("Chart.xlsx");
workbook.Close();
}
MarkerForegroundColorIndex
Gets or sets the index of marker fill color from predefined colors (ExcelKnownColors).
Declaration
ExcelKnownColors MarkerForegroundColorIndex { get; set; }
Property Value
Type |
---|
ExcelKnownColors |
Examples
The following code illustrates how to set a color from ExcelKnownColors enumeration to marker applied.
using (ExcelEngine excelEngine = new ExcelEngine())
{
//Create worksheet
IApplication application = excelEngine.Excel;
application.DefaultVersion = ExcelVersion.Excel2013;
IWorkbook workbook = application.Workbooks.Create(1);
IWorksheet sheet = workbook.Worksheets[0];
//Add data
sheet.Range["A1"].Text = "Jan";
sheet.Range["B1"].Text = "Feb";
sheet.Range["C1"].Text = "Mar";
sheet.Range["A2"].Value = "10";
sheet.Range["B2"].Value = "20";
sheet.Range["C2"].Value = "30";
//Create chart
IChart chart = sheet.Charts.Add();
//Set range
chart.DataRange = sheet.Range["A1:C2"];
//Set chart type
chart.ChartType = ExcelChartType.Line;
//Set serie format
IChartSerieDataFormat format = chart.Series[0].SerieFormat;
//Set marker style
format.MarkerStyle = ExcelChartMarkerType.Circle;
//Set color
format.MarkerBackgroundColorIndex = ExcelKnownColors.Red;
format.MarkerForegroundColorIndex = ExcelKnownColors.Black;
//Save and Dispose
workbook.SaveAs("Chart.xlsx");
workbook.Close();
}
MarkerSize
Gets or sets the size of markers.
Declaration
int MarkerSize { get; set; }
Property Value
Type |
---|
System.Int32 |
Examples
The following code illustrates how to set MarkerSize for applied markers in charts.
using (ExcelEngine excelEngine = new ExcelEngine())
{
//Create worksheet
IApplication application = excelEngine.Excel;
application.DefaultVersion = ExcelVersion.Excel2013;
IWorkbook workbook = application.Workbooks.Create(1);
IWorksheet sheet = workbook.Worksheets[0];
//Add data
sheet.Range["A1"].Text = "Jan";
sheet.Range["B1"].Text = "Feb";
sheet.Range["C1"].Text = "Mar";
sheet.Range["A2"].Value = "10";
sheet.Range["B2"].Value = "20";
sheet.Range["C2"].Value = "30";
//Create chart
IChart chart = sheet.Charts.Add();
//Set range
chart.DataRange = sheet.Range["A1:C2"];
//Set chart type
chart.ChartType = ExcelChartType.Line;
//Set serie format
IChartSerieDataFormat format = chart.Series[0].SerieFormat;
//Set marker style
format.MarkerStyle = ExcelChartMarkerType.Circle;
//Set marker size
format.MarkerSize = 10;
//Save and Dispose
workbook.SaveAs("Chart.xlsx");
workbook.Close();
}
MarkerStyle
Gets or sets the marker style for a point or series in a line chart, scatter chart, or radar chart.
Declaration
ExcelChartMarkerType MarkerStyle { get; set; }
Property Value
Type |
---|
ExcelChartMarkerType |
Examples
The following code illustrates how marker style can be applied to charts.
using (ExcelEngine excelEngine = new ExcelEngine())
{
//Create worksheet
IApplication application = excelEngine.Excel;
application.DefaultVersion = ExcelVersion.Excel2013;
IWorkbook workbook = application.Workbooks.Create(1);
IWorksheet sheet = workbook.Worksheets[0];
//Add data
sheet.Range["A1"].Text = "Jan";
sheet.Range["B1"].Text = "Feb";
sheet.Range["C1"].Text = "Mar";
sheet.Range["A2"].Value = "10";
sheet.Range["B2"].Value = "20";
sheet.Range["C2"].Value = "30";
//Create chart
IChart chart = sheet.Charts.Add();
//Set range
chart.DataRange = sheet.Range["A1:C2"];
//Set chart type
chart.ChartType = ExcelChartType.Line;
//Set serie format
IChartSerieDataFormat format = chart.Series[0].SerieFormat;
//Set marker style
format.MarkerStyle = ExcelChartMarkerType.Star;
//Save and Dispose
workbook.SaveAs("Chart.xlsx");
workbook.Close();
}
Percent
Gets or sets the distance of pie slice from center of pie.
Declaration
int Percent { get; set; }
Property Value
Type |
---|
System.Int32 |
Examples
The following code illustrates how to set Percent property.
using (ExcelEngine excelEngine = new ExcelEngine())
{
//Create worksheet
IApplication application = excelEngine.Excel;
application.DefaultVersion = ExcelVersion.Excel2013;
IWorkbook workbook = application.Workbooks.Create(1);
IWorksheet sheet = workbook.Worksheets[0];
//Add data
sheet.Range["A1"].Text = "Jan";
sheet.Range["B1"].Text = "Feb";
sheet.Range["C1"].Text = "Mar";
sheet.Range["A2"].Value = "10";
sheet.Range["B2"].Value = "20";
sheet.Range["C2"].Value = "30";
//Create chart
IChart chart = sheet.Charts.Add();
//Set range
chart.DataRange = sheet.Range["A1:C2"];
//Set chart type
chart.ChartType = ExcelChartType.Pie;
//Set percent
chart.Series[0].SerieFormat.Percent = 30;
//Save and Dispose
workbook.SaveAs("Chart.xlsx");
workbook.Close();
}
QuartileCalculationType
Gets / Sets whether the Quartile calculation is InclusiveMedian or ExclusiveMedian.
Declaration
ExcelQuartileCalculation QuartileCalculationType { get; set; }
Property Value
Type |
---|
ExcelQuartileCalculation |
Remarks
Applies only to BoxAndWhisker Charts
Examples
By default QuartileCalculationType for BoxAndWhisker is set to ExclusiveMedian. Here for example, we set InclusiveMedian to QuartileCalculationType property.
using (ExcelEngine excelEngine = new ExcelEngine())
{
//Create worksheet
IApplication application = excelEngine.Excel;
application.DefaultVersion = ExcelVersion.Excel2013;
IWorkbook workbook = application.Workbooks.Create(1);
IWorksheet sheet = workbook.Worksheets[0];
//Add data
sheet.ImportDataTable(GetData(), true, 1, 1);
//Create chart
IChart chart = sheet.Charts.Add();
//Set chart type
chart.ChartType = ExcelChartType.BoxAndWhisker;
//Set range
chart.DataRange = sheet.Range["B1:C17"];
//Set serie data format
IChartSerieDataFormat format = chart.Series[0].DataPoints.DefaultDataPoint.DataFormat;
//Set quartile calculation type
format.QuartileCalculationType = ExcelQuartileCalculation.InclusiveMedian;
//Save and Dispose
workbook.SaveAs("Chart.xlsx");
workbook.Close();
}
System.Data.DataTable GetData()
{
System.Data.DataTable dt = new System.Data.DataTable();
dt.Columns.Add("Book ID");
dt.Columns.Add("Category");
dt.Columns.Add("Price");
dt.Rows.Add("SBA2465", "Children's", 26);
dt.Rows.Add("SBA3222", "Children's", 8);
dt.Rows.Add("SBA2391", "Children's", 9);
dt.Rows.Add("SBA3823", "Children's", 17);
dt.Rows.Add("SBA3197", "Children's", 32);
dt.Rows.Add("SBA1160", "Romance", 34);
dt.Rows.Add("SBA3092", "Romance", 20);
dt.Rows.Add("SBA1016", "Romance", 5);
dt.Rows.Add("SBA3266", "Romance", 12);
dt.Rows.Add("SBA3381", "Romance", 13);
dt.Rows.Add("SBA1870", "Romance", 4);
dt.Rows.Add("SBA2072", "Mystery", 61);
dt.Rows.Add("SBA3969", "Mystery", 15);
dt.Rows.Add("SBA3124", "Mystery", 40);
dt.Rows.Add("SBA3693", "Mystery", 19);
dt.Rows.Add("SBA2543", "Mystery", 72);
return dt;
}
ShowConnectorLines
Gets / Sets a boolean value indicating whether to display Connector Lines between data points
Declaration
bool ShowConnectorLines { get; set; }
Property Value
Type |
---|
System.Boolean |
Remarks
Applies only to Waterfall Charts
Examples
The following code illustrates how to set connector line visibility for WaterFall chart.
using (ExcelEngine excelEngine = new ExcelEngine())
{
//Create worksheet
IApplication application = excelEngine.Excel;
application.DefaultVersion = ExcelVersion.Excel2013;
IWorkbook workbook = application.Workbooks.Create(1);
IWorksheet sheet = workbook.Worksheets[0];
//Add data
sheet.Range["A1"].Text = "Jan";
sheet.Range["B1"].Text = "Feb";
sheet.Range["C1"].Text = "Mar";
sheet.Range["A2"].Value = "10";
sheet.Range["B2"].Value = "20";
sheet.Range["C2"].Value = "30";
//Create chart
IChart chart = sheet.Charts.Add();
//Set range
chart.DataRange = sheet.Range["A1:C2"];
//Set chart type
chart.ChartType = ExcelChartType.WaterFall;
//Set serie format
IChartSerieDataFormat format = chart.Series[0].SerieFormat;
//Set visibility
format.ShowConnectorLines = false;
//Save and Dispose
workbook.SaveAs("Chart.xlsx");
workbook.Close();
}
ShowInnerPoints
Gets / Sets a boolean value indicating whether to display Inner Points in BoxAndWhisker chart.
Declaration
bool ShowInnerPoints { get; set; }
Property Value
Type |
---|
System.Boolean |
Examples
The following code illustrates how to set the visibility of inner points in BoxAndWhisker chart.
using (ExcelEngine excelEngine = new ExcelEngine())
{
//Create worksheet
IApplication application = excelEngine.Excel;
application.DefaultVersion = ExcelVersion.Excel2013;
IWorkbook workbook = application.Workbooks.Create(1);
IWorksheet sheet = workbook.Worksheets[0];
//Add data
sheet.ImportDataTable(GetData(), true, 1, 1);
//Create chart
IChart chart = sheet.Charts.Add();
//Set chart type
chart.ChartType = ExcelChartType.BoxAndWhisker;
//Set range
chart.DataRange = sheet.Range["B1:C17"];
//Set serie data format
IChartSerieDataFormat format = chart.Series[0].DataPoints.DefaultDataPoint.DataFormat;
//Set ShowInnerPoints
format.ShowInnerPoints = true;
//Save and Dispose
workbook.SaveAs("Chart.xlsx");
workbook.Close();
}
System.Data.DataTable GetData()
{
System.Data.DataTable dt = new System.Data.DataTable();
dt.Columns.Add("Book ID");
dt.Columns.Add("Category");
dt.Columns.Add("Price");
dt.Rows.Add("SBA2465", "Children's", 26);
dt.Rows.Add("SBA3222", "Children's", 8);
dt.Rows.Add("SBA2391", "Children's", 9);
dt.Rows.Add("SBA3823", "Children's", 17);
dt.Rows.Add("SBA3197", "Children's", 32);
dt.Rows.Add("SBA1160", "Romance", 34);
dt.Rows.Add("SBA3092", "Romance", 20);
dt.Rows.Add("SBA1016", "Romance", 5);
dt.Rows.Add("SBA3266", "Romance", 12);
dt.Rows.Add("SBA3381", "Romance", 13);
dt.Rows.Add("SBA1870", "Romance", 4);
dt.Rows.Add("SBA2072", "Mystery", 61);
dt.Rows.Add("SBA3969", "Mystery", 15);
dt.Rows.Add("SBA3124", "Mystery", 40);
dt.Rows.Add("SBA3693", "Mystery", 19);
dt.Rows.Add("SBA2543", "Mystery", 72);
return dt;
}
ShowMeanLine
Gets / Sets a boolean value indicating whether to display Mean Line in BoxAndWhisker chart
Declaration
bool ShowMeanLine { get; set; }
Property Value
Type |
---|
System.Boolean |
Examples
The following code illustrates how to set the visibility of mean lines in BoxAndWhisker chart.
using (ExcelEngine excelEngine = new ExcelEngine())
{
//Create worksheet
IApplication application = excelEngine.Excel;
application.DefaultVersion = ExcelVersion.Excel2013;
IWorkbook workbook = application.Workbooks.Create(1);
IWorksheet sheet = workbook.Worksheets[0];
//Add data
sheet.Range["A1"].Text = "Jan";
sheet.Range["B1"].Text = "Feb";
sheet.Range["C1"].Text = "Mar";
sheet.Range["A2"].Value = "10";
sheet.Range["B2"].Value = "20";
sheet.Range["C2"].Value = "30";
//Create chart
IChart chart = sheet.Charts.Add();
//Set range
chart.DataRange = sheet.Range["A1:C2"];
//Set chart type
chart.ChartType = ExcelChartType.BoxAndWhisker;
//Set serie format
IChartSerieDataFormat format = chart.Series[0].SerieFormat;
//Set visibility
format.ShowMeanLine = true;
//Save and Dispose
workbook.SaveAs("Chart.xlsx");
workbook.Close();
}
ShowMeanMarkers
Gets / Sets a boolean value indicating whether to display Mean Marker in BoxAndWhisker chart.
Declaration
bool ShowMeanMarkers { get; set; }
Property Value
Type |
---|
System.Boolean |
Examples
The following code illustrates how to set the visibility of mean markers in BoxAndWhisker chart.
using (ExcelEngine excelEngine = new ExcelEngine())
{
//Create worksheet
IApplication application = excelEngine.Excel;
application.DefaultVersion = ExcelVersion.Excel2013;
IWorkbook workbook = application.Workbooks.Create(1);
IWorksheet sheet = workbook.Worksheets[0];
//Add data
sheet.Range["A1"].Text = "Jan";
sheet.Range["B1"].Text = "Feb";
sheet.Range["C1"].Text = "Mar";
sheet.Range["A2"].Value = "10";
sheet.Range["B2"].Value = "20";
sheet.Range["C2"].Value = "30";
//Create chart
IChart chart = sheet.Charts.Add();
//Set range
chart.DataRange = sheet.Range["A1:C2"];
//Set chart type
chart.ChartType = ExcelChartType.BoxAndWhisker;
//Set serie format
IChartSerieDataFormat format = chart.Series[0].SerieFormat;
//Set visibility
format.ShowMeanMarkers = true;
//Save and Dispose
workbook.SaveAs("Chart.xlsx");
workbook.Close();
}
ShowOutlierPoints
Gets / Sets a boolean value indicating whether to display Outlier Points in BoxAndWhisker chart.
Declaration
bool ShowOutlierPoints { get; set; }
Property Value
Type |
---|
System.Boolean |
Examples
The following code illustrates how to set the visibility of outlier points in BoxAndWhisker chart.
using (ExcelEngine excelEngine = new ExcelEngine())
{
//Create worksheet
IApplication application = excelEngine.Excel;
application.DefaultVersion = ExcelVersion.Excel2013;
IWorkbook workbook = application.Workbooks.Create(1);
IWorksheet sheet = workbook.Worksheets[0];
//Add data
sheet.ImportDataTable(GetData(), true, 1, 1);
//Create chart
IChart chart = sheet.Charts.Add();
//Set chart type
chart.ChartType = ExcelChartType.BoxAndWhisker;
//Set range
chart.DataRange = sheet.Range["B1:C17"];
//Set serie data format
IChartSerieDataFormat format = chart.Series[0].DataPoints.DefaultDataPoint.DataFormat;
//Set ShowOutlierPoints
format.ShowOutlierPoints = true;
//Save and Dispose
workbook.SaveAs("Chart.xlsx");
workbook.Close();
}
System.Data.DataTable GetData()
{
System.Data.DataTable dt = new System.Data.DataTable();
dt.Columns.Add("Book ID");
dt.Columns.Add("Category");
dt.Columns.Add("Price");
dt.Rows.Add("SBA2465", "Children's", 26);
dt.Rows.Add("SBA3222", "Children's", 8);
dt.Rows.Add("SBA2391", "Children's", 9);
dt.Rows.Add("SBA3823", "Children's", 17);
dt.Rows.Add("SBA3197", "Children's", 32);
dt.Rows.Add("SBA1160", "Romance", 34);
dt.Rows.Add("SBA3092", "Romance", 20);
dt.Rows.Add("SBA1016", "Romance", 5);
dt.Rows.Add("SBA3266", "Romance", 12);
dt.Rows.Add("SBA3381", "Romance", 13);
dt.Rows.Add("SBA1870", "Romance", 4);
dt.Rows.Add("SBA2072", "Mystery", 61);
dt.Rows.Add("SBA3969", "Mystery", 15);
dt.Rows.Add("SBA3124", "Mystery", 40);
dt.Rows.Add("SBA3693", "Mystery", 19);
dt.Rows.Add("SBA2543", "Mystery", 72);
return dt;
}
TreeMapLabelOption
Gets / Sets the Display label position in Tree map chart
Declaration
ExcelTreeMapLabelOption TreeMapLabelOption { get; set; }
Property Value
Type |
---|
ExcelTreeMapLabelOption |
Examples
For TreeMap chart by default TreeMapLabelOption is set to Overlapping. Here for example, we set Banner to TreeMapLabelOption.
using (ExcelEngine excelEngine = new ExcelEngine())
{
//Create worksheet
IApplication application = excelEngine.Excel;
application.DefaultVersion = ExcelVersion.Excel2013;
IWorkbook workbook = application.Workbooks.Create(1);
IWorksheet sheet = workbook.Worksheets[0];
//Add data
sheet.Range["A1"].Text = "Fall";
sheet.Range["B1"].Text = "Month";
sheet.Range["C1"].Text = "Total";
sheet.Range["A2:A4"].Text = "Quarter1";
sheet.Range["A5:A7"].Text = "Quarter2";
sheet.Range["B2"].Text = "Jan";
sheet.Range["B3"].Text = "Feb";
sheet.Range["B4"].Text = "Mar";
sheet.Range["B5"].Text = "Apr";
sheet.Range["B6"].Text = "May";
sheet.Range["B7"].Text = "Jun";
sheet.Range["C2"].Value = "10";
sheet.Range["C3"].Value = "20";
sheet.Range["C4"].Value = "30";
sheet.Range["C5"].Value = "35";
sheet.Range["C6"].Value = "25";
sheet.Range["C7"].Value = "15";
//Create chart
IChart chart = sheet.Charts.Add();
//Set chart type
chart.ChartType = ExcelChartType.TreeMap;
//Set range
chart.DataRange = sheet.Range["A1:C7"];
//Set chart format
IChartSerieDataFormat format = chart.Series[0].SerieFormat;
//Set label option
format.TreeMapLabelOption = ExcelTreeMapLabelOption.Banner;
//Save and Dispose
workbook.SaveAs("Chart.xlsx");
workbook.Close();
}