This content is for v4.x (Alpha). Switch to the Stable version.
The Chart
class, a versatile component within the OpenXMLOffice.Spreadsheet
library, empowers developers to seamlessly integrate various types of charts into Excel spreadsheet. This class supports multiple chart types and configurations, allowing users to add new charts to a sheet with dynamic and data-driven visualizations.
List of supported charts
- Area Chart (2007) :
- Cluster
- Stacked
- 100% Stacked
- Cluster 3D
- Stacked 3D
- 100% Stacked 3D
- Bar Chart (2007) :
- Cluster
- Stacked
- 100% Stacked
- Cluster 3D
- Stacked 3D
- 100% Stacked 3D
- Column Chart (2007) :
- Cluster
- Stacked
- 100% Stacked
- Cluster 3D
- Stacked 3D
- 100% Stacked 3D
- Line Chart (2007) :
- Cluster
- Stacked
- 100% Stacked
- Cluster Marker
- Stacked Marker
- 100% Stacked Marker
- Pie Chart (2007) :
- Pie
- Pie 3D
- Doughnut
- X Y (Scatter) Chart (2007) :
- Scatter
- Scatter Smooth Line Marker
- Scatter Smooth Line
- Scatter Line Marker
- Scatter Line
- Bubble
- Bubble 3D
- Combo Chart (2007) :;
- Waterfall Chart (2016)
Basic Code Samples
Section titled “Basic Code Samples” For each chart family ChartSetting<ExcelSetting>
have its relevant options and settings for customization.
public void ChartSample(Excel excel){ // Default Chart Type Excel excel1 = new("./TestFiles/basic_test.xlsx", true); Worksheet worksheet = excel1.AddSheet("AreaChart"); worksheet.AddChart(new() { cellIdStart = "A1", cellIdEnd = "D4" }, new AreaChartSetting<ExcelSetting>() { applicationSpecificSetting = new() { from = new() { row = 5, column = 5 }, to = new() { row = 20, column = 20 } } });}
ChartSetting<ExcelSetting>
Options
Section titled “ChartSetting<ExcelSetting> Options”This section outlines the options available when configuring charts with ChartSetting
using ExcelSetting
parameters.
Property | Type | Details |
---|---|---|
isSecondaryAxis | bool | If combo chart this can be used to indicate secondary axis activation. |
chartDataSetting | ChartDataSetting | This setting enables users to customize both the input chart data range and value from cell labels with precision. |
chartGridLinesOptions | ChartGridLinesOptions | This feature offers crisp options for users to finely customize the gridline settings of the chart. |
chartLegendOptions | ChartLegendOptions | This feature offers crisp options for users to finely customize the gridline settings of the chart. |
applicationSpecificSetting | <ApplicationSpecificSetting> | This is generic class setting. For Spreadsheet it is ExcelSetting |
ExcelSetting
Options
Section titled “ExcelSetting Options”Property | Type | Details |
---|---|---|
from | AnchorPosition | Placement details for from starting point |
to | AnchorPosition | Placement details for to Ending point |
AnchorPosition
Options
Section titled “AnchorPosition Options”Property | Type | Details |
---|---|---|
column | uint | Default:1 |
columnOffset | uint | Default:0 |
row | uint | Default:1 |
rowOffset | uint | Default:0 |
ChartDataSetting
Options
Section titled “ChartDataSetting Options”Property | Type | Details |
---|---|---|
chartDataColumnEnd | uint | Specify the number of columns for chart series; set to 0 for utilizing all columns. Default: 0 |
chartDataColumnStart | uint | Specify the starting column for chart data. Default: 0 |
chartDataRowEnd | uint | Specify the number of rows for chart series; set to 0 for utilizing all rows. Default: 0 |
chartDataRowStart | uint | Specify the starting row for chart data. Default: 0 |
advancedDataLabel | AdvancedDataLabel | Used for Data Label Option From Office 2013 |
ChartGridLinesOptions
Options
Section titled “ChartGridLinesOptions Options”Property | Type | Details |
---|---|---|
isMajorCategoryLinesEnabled | bool | Toggle visibility of major category lines with clarity. |
isMajorValueLinesEnabled | bool | Toggle visibility of major value lines with clarity. |
isMinorCategoryLinesEnabled | bool | Toggle visibility of minor category lines with clarity. |
isMinorValueLinesEnabled | bool | Toggle visibility of minor value lines with clarity. |
ChartLegendOptions
Options
Section titled “ChartLegendOptions Options”Property | Type | Details |
---|---|---|
isEnableLegend | bool | Toggle visibility of legend with clarity. |
isLegendChartOverLap | bool | Activate the option for a sleek and tidy display by allowing the legends to overlap. |
isBold | bool | Provide the option to set text in a bold format with clarity. |
isItalic | bool | Provide the option to set text in a italic format with clarity. |
fontSize | float | Provide the option to set font size with clarity. |
fontColor | string? | Optional font color using hex code (without #). Default : Theme Text 1. |
underLineValues | UnderLineValues | Text underline options. Default: None |
strikeValues | StrikeValues | Text strike options |
legendPosition | LegendPositionValues | Legend position in chart. Default: Bottom |
ChartDataLabel
Options
Section titled “ChartDataLabel Options”This is base data label class extended by each chart type to give more specific/relevant options
Property | Type | Details |
---|---|---|
separator | string | Data lable text separator used if multiple label enabled |
showCategoryName | bool | Show category name in label |
showLegendKey | bool | Show legend key in label |
showSeriesName | bool | Show series name in label |
showValue | bool | Show value in label |
isBold | bool | Set label bold |
isItalic | bool | Set label italic |
fontSize | float | Set label font size |
fontColor | string? | Set label font color |
underLineValues | UnderLineValues | Set label underline type |
strikeValues | StrikeValues | Set label strike type |
AdvancedDataLabel
Options (2013)
Section titled “AdvancedDataLabel Options (2013)”Property | Type | Details |
---|---|---|
showValueFromColumn | bool | Show Advanced data label |
valueFromColumn | Dictionary<uint, uint> | This option allows configuring a key map where series corresponds to the key, and the value is mapped to a target column based on cell column configuration. |
ChartAxesOptions
Options
Section titled “ChartAxesOptions Options”This properties give control over the X and Y axes. (Relate placement based on your chart option)
Property | Type | Details |
---|---|---|
invertVerticalAxesOrder | string? | |
invertHorizontalAxesOrder | string? | |
isHorizontalAxesEnabled | bool | |
isHorizontalBold | bool | |
isHorizontalItalic | bool | |
horizontalFontSize | float | |
horizontalFontColor | string? | |
horizontalUnderLineValues | UnderLineValues | |
horizontalStrikeValues | StrikeValues | |
isVerticalBold | bool | |
isVerticalItalic | bool | |
verticalFontSize | float | |
verticalFontColor | string? | |
verticalUnderLineValues | UnderLineValues | |
verticalStrikeValues | StrikeValues | |
isVerticalAxesEnabled | bool |
ChartSeriesSetting
Options
Section titled “ChartSeriesSetting Options”Property | Type | Details |
---|---|---|
borderColor | string? | Explicit border color for current data series |
ChartDataPointSettings
Options
Section titled “ChartDataPointSettings Options”Property | Type | Details |
---|---|---|
fillColor | string? | Explicit fill color for one specific data point in a series |
borderColor | string? | Explicit border color for one specific data point in a series |