Interface IChartSerie
Represents a series in the chart.
Namespace: Syncfusion.XlsIO
Assembly: Syncfusion.XlsIO.UWP.dll
Syntax
public interface IChartSerie : IParentApplication
Properties
Bubbles
Gets or sets series values of the bubble chart.
Declaration
IRange Bubbles { get; set; }
Property Value
Type |
---|
IRange |
Examples
For bubble chart both horizontal and vertical axes are value axes so for the first value axis we set serie value to Values property and the next value axis we make use of Bubbles 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"].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 serie
IChartSerie serie = chart.Series.Add(ExcelChartType.Bubble);
//Set values
serie.Values = sheet.Range["A1:C1"];
//Set bubble chart range
serie.Bubbles = sheet.Range["A2:C2"];
//Save and Dispose
workbook.SaveAs("Chart.xlsx");
workbook.Close();
}
CategoryLabels
Gets or sets category labels for the series.
Declaration
IRange CategoryLabels { get; set; }
Property Value
Type |
---|
IRange |
Examples
The following code illustrates how to set category labels for IChartSerie 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 serie
IChartSerie serie = chart.Series.Add();
//Set category labels and values
serie.CategoryLabels = sheet.Range["A1:C1"];
serie.Values = sheet.Range["A2:C2"];
//Save and Dispose
workbook.SaveAs("Chart.xlsx");
workbook.Close();
}
DataPoints
Gets the IChartDataPoints collection in the series. Read-only.
Declaration
IChartDataPoints DataPoints { get; }
Property Value
Type |
---|
IChartDataPoints |
Examples
The following code illustrates how to access the IChartDataPoints collection from IChartSerie.
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 data points
IChartDataPoints dataPoints = chart.Series[0].DataPoints;
//Set data labels value visibility
dataPoints.DefaultDataPoint.DataLabels.IsValue = true;
//Save and Dispose
workbook.SaveAs("Chart.xlsx");
workbook.Close();
}
EnteredDirectlyBubbles
Gets or sets the directly entered series values for Bubble chart.
Declaration
object[] EnteredDirectlyBubbles { get; set; }
Property Value
Type |
---|
System.Object[] |
Examples
The following code illustrates how series data for second value axis of Bubble charts can be directly given for 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];
//Create chart
IChart chart = sheet.Charts.Add();
//Set serie
IChartSerie serie = chart.Series.Add(ExcelChartType.Bubble);
//Set direct values
serie.EnteredDirectlyValues = new object[] { 10, 20, 30 };
//Set bubble chart direct values
serie.EnteredDirectlyBubbles = new object[] { 1, 4, 2 };
//Save and Dispose
workbook.SaveAs("Chart.xlsx");
workbook.Close();
}
EnteredDirectlyCategoryLabels
Gets or sets the directly entered category values.
Declaration
object[] EnteredDirectlyCategoryLabels { get; set; }
Property Value
Type |
---|
System.Object[] |
Examples
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];
//Create chart
IChart chart = sheet.Charts.Add();
//Set serie
IChartSerie serie = chart.Series.Add(ExcelChartType.Pie);
//Set direct values
serie.EnteredDirectlyValues = new object[] { 2000, 1000, 1000 };
//Set direct category label
serie.EnteredDirectlyCategoryLabels = new object[] { "Total Income", "Expenses", "Profit" };
//Save and Dispose
workbook.SaveAs("Chart.xlsx");
workbook.Close();
}
EnteredDirectlyValues
Gets or sets the directly entered series values.
Declaration
object[] EnteredDirectlyValues { get; set; }
Property Value
Type |
---|
System.Object[] |
Examples
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];
//Create chart
IChart chart = sheet.Charts.Add();
//Set serie
IChartSerie serie = chart.Series.Add(ExcelChartType.Pie);
//Set direct values
serie.EnteredDirectlyValues = new object[] { 2000, 1000, 1000 };
//Set direct category label
serie.EnteredDirectlyCategoryLabels = new object[] { "Total Income", "Expenses", "Profit" };
//Save and Dispose
workbook.SaveAs("Chart.xlsx");
workbook.Close();
}
ErrorBarsX
Gets the error bars on the X-axis. Read-only.
Declaration
IChartErrorBars ErrorBarsX { get; }
Property Value
Type |
---|
IChartErrorBars |
Examples
The following code illustrates how IChartErrorBars in X-axis can be accessed.
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 chart type
chart.ChartType = ExcelChartType.Scatter_Line;
//Set range
chart.DataRange = sheet.Range["A1:C2"];
//Set error bar
chart.Series[0].HasErrorBarsX = true;
IChartErrorBars errorBar = chart.Series[0].ErrorBarsX;
//Set error bar type
errorBar.Type = ExcelErrorBarType.Percentage;
//Save and Dispose
workbook.SaveAs("Chart.xlsx");
workbook.Close();
}
ErrorBarsY
Gets the error bars on Y-axis. Read-only.
Declaration
IChartErrorBars ErrorBarsY { get; }
Property Value
Type |
---|
IChartErrorBars |
Examples
The following code illustrates how IChartErrorBars on Y-axis can be accessed.
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 chart type
chart.ChartType = ExcelChartType.Scatter_Line;
//Set range
chart.DataRange = sheet.Range["A1:C2"];
//Set error bar
chart.Series[0].HasErrorBarsY = true;
IChartErrorBars errorBar = chart.Series[0].ErrorBarsY;
//Set error bar type
errorBar.Type = ExcelErrorBarType.Percentage;
//Save and Dispose
workbook.SaveAs("Chart.xlsx");
workbook.Close();
}
HasErrorBarsX
True if series contains X error bars. otherwise False.
Declaration
bool HasErrorBarsX { get; set; }
Property Value
Type |
---|
System.Boolean |
Examples
The following code illustrates how HasErrorBarsX 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["A2"].Value = "10";
sheet.Range["B2"].Value = "20";
sheet.Range["C2"].Value = "30";
//Create chart
IChart chart = sheet.Charts.Add();
//Set chart type
chart.ChartType = ExcelChartType.Scatter_Line;
//Set range
chart.DataRange = sheet.Range["A1:C2"];
//Set error bar
chart.Series[0].HasErrorBarsX = true;
//Save and Dispose
workbook.SaveAs("Chart.xlsx");
workbook.Close();
}
HasErrorBarsY
True if series contains Y error bars. otherwise False.
Declaration
bool HasErrorBarsY { get; set; }
Property Value
Type |
---|
System.Boolean |
Examples
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 chart type
chart.ChartType = ExcelChartType.Scatter_Line;
//Set range
chart.DataRange = sheet.Range["A1:C2"];
//Set error bar
chart.Series[0].HasErrorBarsY = true;
//Save and Dispose
workbook.SaveAs("Chart.xlsx");
workbook.Close();
}
HasLeaderLines
Declaration
bool HasLeaderLines { get; set; }
Property Value
Type |
---|
System.Boolean |
InvertIfNegative
Gets or sets a value to specify the series to invert its colors if the value is negative. The default value is true.
Declaration
Nullable<bool> InvertIfNegative { get; set; }
Property Value
Type |
---|
System.Nullable<System.Boolean> |
Examples
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.Series[0].SerieType = ExcelChartType.Column_Cluster;
chart.Series[0].InvertIfNegative =true;
//Save and Dispose
workbook.SaveAs("Chart.xlsx");
workbook.Close();
}
InvertIfNegativeColor
Gets or sets a value to specify the series to invert its colors if the value is negative.
Declaration
ColorObject InvertIfNegativeColor { get; set; }
Property Value
Type |
---|
ColorObject |
Examples
The following code illustrates how to set values for IChartSerie 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.Series[0].SerieType = ExcelChartType.Column_Cluster;
chart.Series[0].InvertIfNegative =true;
chart.Series[0].InvertIfNegativeColor= Color.Red;
//Save and Dispose
workbook.SaveAs("Chart.xlsx");
workbook.Close();
}
IsFiltered
Gets or sets a boolean value indicating whether the series has been filtered out from the chart.
Declaration
bool IsFiltered { get; set; }
Property Value
Type |
---|
System.Boolean |
Examples
By default all the series in the chart are shown because IsFiltered property is set to "false". Here for example, we set first serie IsFiltered property to "true" so it is filtered out from the chart and it will not be shown in the 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"].Text = "Apr";
sheet.Range["B2"].Text = "May";
sheet.Range["C2"].Text = "Jun";
sheet.Range["A4"].Value = "10";
sheet.Range["B4"].Value = "20";
sheet.Range["C4"].Value = "30";
sheet.Range["A3"].Value = "15";
sheet.Range["B3"].Value = "10";
sheet.Range["C3"].Value = "35";
//Create chart
IChart chart = sheet.Charts.Add();
//Set range
chart.DataRange = sheet.Range["A1:C4"];
//Set chart type
chart.ChartType = ExcelChartType.Line;
//Set IsFiltered
chart.Series[0].IsFiltered = true;
//Save and Dispose
workbook.SaveAs("Chart.xlsx");
workbook.Close();
}
LeaderLines
Declaration
IChartBorder LeaderLines { get; }
Property Value
Type |
---|
IChartBorder |
Name
Gets or sets the name of the series.
Declaration
string Name { get; set; }
Property Value
Type |
---|
System.String |
Examples
The following code illustrates how to access the name of the IChartSerie.
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 serie
IChartSerie serie = chart.Series.Add("BarSerie");
//Set category labels and values
serie.CategoryLabels = sheet.Range["A1:C1"];
serie.Values = sheet.Range["A2:C2"];
//Get Serie name
Console.Write(serie.Name);
//Save and Dispose
workbook.SaveAs("Chart.xlsx");
workbook.Close();
Console.ReadKey();
}
//Output will be
//BarSerie
NameRange
Gets or sets the series name range.
Declaration
IRange NameRange { get; }
Property Value
Type |
---|
IRange |
Examples
The following code illustrates how to access the name range of a particular IChartSerie in the IChartSeries collection.
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 = "Width";
sheet.Range["A2"].Text = "Height";
sheet.Range["B1"].Value = "50";
sheet.Range["C1"].Value = "60";
sheet.Range["D1"].Value = "5";
sheet.Range["B2"].Value = "1";
sheet.Range["C2"].Value = "4";
sheet.Range["D2"].Value = "2";
//Create chart
IChart chart = sheet.Charts.Add();
//Set chart type
chart.ChartType = ExcelChartType.Bubble;
//Set range
chart.DataRange = sheet["A1:D2"];
//Get name range
Console.Write(chart.Series[0].NameRange.AddressLocal);
//Save and Dispose
workbook.SaveAs("Chart.xlsx");
workbook.Close();
Console.ReadKey();
}
//Output will be
//A1
ParetoLineFormat
Gets the Pareto line on the Pareto charts. Read-only.
Declaration
IChartFrameFormat ParetoLineFormat { get; }
Property Value
Type |
---|
IChartFrameFormat |
Examples
The following code illustrates how to set pareto line properties of the Pareto 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 chart format
chart.ChartType = ExcelChartType.Pareto;
//Set range
chart.DataRange = sheet.Range["A1:C2"];
//Set pareto line format
IChartFrameFormat format = chart.Series[0].ParetoLineFormat;
format.LineProperties.ColorIndex = ExcelKnownColors.Red;
//Save the workbook
MemoryStream stream = new MemoryStream();
workbook.SaveAs(stream);
}
SerieFormat
Gets or sets the IChartSerieDataFormat of the series.
Declaration
IChartSerieDataFormat SerieFormat { get; }
Property Value
Type |
---|
IChartSerieDataFormat |
Examples
The following code illustrates how to access the IChartSerieDataFormat from IChartSerie.
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();
}
SerieType
Gets or sets the series type.
Declaration
ExcelChartType SerieType { get; set; }
Property Value
Type |
---|
ExcelChartType |
Examples
SerieType property can be used to create a combination chart by adding more series to the charts. Here for example, we create a chart. By default the ChartType will be Column_Clustered, here we change it by setting SerieType to Line.
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.Series[0].SerieType = ExcelChartType.Line;
//Save and Dispose
workbook.SaveAs("Chart.xlsx");
workbook.Close();
}
TrendLines
Gets the IChartTrendLines collection of the series. Read-only.
Declaration
IChartTrendLines TrendLines { get; }
Property Value
Type |
---|
IChartTrendLines |
Examples
The following code illustrates how IChartTrendLines collection can be accessed from a particular IChartSerie.
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 trend line
IChartTrendLines trendLines = chart.Series[0].TrendLines;
IChartTrendLine trendLine = trendLines.Add(ExcelTrendLineType.Linear);
//Save and Dispose
workbook.SaveAs("Chart.xlsx");
workbook.Close();
}
UsePrimaryAxis
Gets or sets a boolean value indicating whether to use primary axis for series drawing. False to use secondary axis.
Declaration
bool UsePrimaryAxis { get; set; }
Property Value
Type |
---|
System.Boolean |
Examples
The following code illustrates how the secondary axis can be used by disabling primary axis.
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";
sheet.Range["A3"].Value = "100";
sheet.Range["B3"].Value = "200";
sheet.Range["C3"].Value = "300";
//Create chart
IChart chart = sheet.Charts.Add();
//Set range
chart.DataRange = sheet.Range["A1:C3"];
//Set secondary axis
IChartSerie serie = chart.Series[1];
serie.UsePrimaryAxis = false;
chart.SecondaryCategoryAxis.Visible = true;
//Save and Dispose
workbook.SaveAs("Chart.xlsx");
workbook.Close();
}
Values
Gets or sets the series values.
Declaration
IRange Values { get; set; }
Property Value
Type |
---|
IRange |
Examples
The following code illustrates how to set values for IChartSerie 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 serie
IChartSerie serie = chart.Series.Add();
//Set category labels and values
serie.CategoryLabels = sheet.Range["A1:C1"];
serie.Values = sheet.Range["A2:C2"];
//Save and Dispose
workbook.SaveAs("Chart.xlsx");
workbook.Close();
}
Methods
ErrorBar(Boolean)
Creates IChartErrorBars in the specified axis.
Declaration
IChartErrorBars ErrorBar(bool bIsY)
Parameters
Type | Name | Description |
---|---|---|
System.Boolean | bIsY | If true - on Y axis; otherwise on X axis. |
Returns
Type | Description |
---|---|
IChartErrorBars | IChartErrorBars for the IChartSerie. |
Examples
The following code illustrates how to set IChartErrorBars on Y-axis of a particular IChartSerie.
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 error bar
chart.Series[0].ErrorBar(true);
//Save and Dispose
workbook.SaveAs("Chart.xlsx");
workbook.Close();
}
ErrorBar(Boolean, ExcelErrorBarInclude)
Creates IChartErrorBars in the specified axis with specified ExcelErrorBarInclude type.
Declaration
IChartErrorBars ErrorBar(bool bIsY, ExcelErrorBarInclude include)
Parameters
Type | Name | Description |
---|---|---|
System.Boolean | bIsY | If true - on Y axis; otherwise on X axis. |
ExcelErrorBarInclude | include | Represents ExcelErrorBarInclude type. |
Returns
Type | Description |
---|---|
IChartErrorBars | IChartErrorBars for the IChartSerie. |
Examples
The following code illustrates how to set IChartErrorBars with Plus on Y-axis of a particular IChartSerie.
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 error bar
chart.Series[0].ErrorBar(true, ExcelErrorBarInclude.Plus);
//Save and Dispose
workbook.SaveAs("Chart.xlsx");
workbook.Close();
}
ErrorBar(Boolean, ExcelErrorBarInclude, ExcelErrorBarType)
Creates IChartErrorBars of specified ExcelErrorBarType.
Declaration
IChartErrorBars ErrorBar(bool bIsY, ExcelErrorBarInclude include, ExcelErrorBarType type)
Parameters
Type | Name | Description |
---|---|---|
System.Boolean | bIsY | If true - on Y axis; otherwise on X axis. |
ExcelErrorBarInclude | include | Represents ExcelErrorBarInclude type. |
ExcelErrorBarType | type | Represents ExcelErrorBarType. |
Returns
Type | Description |
---|---|
IChartErrorBars | IChartErrorBars for the IChartSerie. |
Examples
The following code illustrates how to set IChartErrorBars with Plus and Percentage on Y-axis of a particular IChartSerie.
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 error bar
chart.Series[0].ErrorBar(true, ExcelErrorBarInclude.Plus, ExcelErrorBarType.Percentage);
//Save and Dispose
workbook.SaveAs("Chart.xlsx");
workbook.Close();
}
ErrorBar(Boolean, ExcelErrorBarInclude, ExcelErrorBarType, Double)
Creates IChartErrorBars of specified ExcelErrorBarType with the specified number value.
Declaration
IChartErrorBars ErrorBar(bool bIsY, ExcelErrorBarInclude include, ExcelErrorBarType type, double numberValue)
Parameters
Type | Name | Description |
---|---|---|
System.Boolean | bIsY | If true - on Y axis; otherwise on X axis. |
ExcelErrorBarInclude | include | Represents ExcelErrorBarInclude type. |
ExcelErrorBarType | type | Represents ExcelErrorBarType. |
System.Double | numberValue | Represents number value for the applicable ExcelErrorBarType. |
Returns
Type | Description |
---|---|
IChartErrorBars | IChartErrorBars for the IChartSerie. |
Remarks
The number value is applicable for Percentage, Fixed and StandardDeviation error bar types.
Examples
The following code illustrates how to set IChartErrorBars with Plus , Percentage and number value of "50" on Y-axis of a particular IChartSerie.
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 error bar
chart.Series[0].ErrorBar(true, ExcelErrorBarInclude.Plus, ExcelErrorBarType.Percentage, 50);
//Save and Dispose
workbook.SaveAs("Chart.xlsx");
workbook.Close();
}
ErrorBar(Boolean, IRange, IRange)
Creates custom IChartErrorBars type.
Declaration
IChartErrorBars ErrorBar(bool bIsY, IRange plusRange, IRange minusRange)
Parameters
Type | Name | Description |
---|---|---|
System.Boolean | bIsY | If true - on Y axis; otherwise on X axis. |
IRange | plusRange | Represents PlusRange. |
IRange | minusRange | Represents MinusRange. |
Returns
Type | Description |
---|---|
IChartErrorBars | IChartErrorBars for the IChartSerie. |
Examples
The following code illustrates how an IChartErrorBars can be created on X-axis with PlusRange and MinusRange.
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";
sheet.Range["A3"].Value = "1";
sheet.Range["B3"].Value = "1";
//Create chart
IChart chart = sheet.Charts.Add();
//Set chart type
chart.ChartType = ExcelChartType.Scatter_Line;
//Set range
chart.DataRange = sheet.Range["A1:C2"];
//Set error bar
chart.Series[0].ErrorBar(false, sheet.Range["A3"], sheet.Range["B3"]);
//Save and Dispose
workbook.SaveAs("Chart.xlsx");
workbook.Close();
}