.NET Framework 4.5.2+
.NET Framework 4.5.2+
.NET Standard 2.0+

ChartObject.Style Property

Returns or specifies the chart style.

Namespace: DevExpress.Spreadsheet.Charts

Assembly: DevExpress.Spreadsheet.v21.2.Core.dll

Declaration

ChartStyle Style { get; set; }

Property Value

Type Description
ChartStyle

An enumeration value that defines a style to apply to the chart.

Remarks

Use the Style property to apply one of the predefined styles to an existing chart. Each style specifies data series colors, sets the chart’s background fill, and applies different shape effects and outlines to the chart.

The chart appearance to which a style is applied depends on the current document theme. Each theme has a color palette used to specify chart colors. You can select a colorful chart style that applies one of six accent colors to each series, or use a monochromatic style that applies different shades of the same color to each series.

The following example creates a clustered column chart and specifies its chart styles.

Worksheet worksheet = workbook.Worksheets["chartTask3"];
workbook.Worksheets.ActiveWorksheet = worksheet;

// Create a chart and specify its location.
Chart chart = worksheet.Charts.Add(ChartType.ColumnClustered, worksheet["B2:D4"]);
chart.TopLeftCell = worksheet.Cells["H2"];
chart.BottomRightCell = worksheet.Cells["N14"];

// Set the chart style.
chart.Style = ChartStyle.Accent1Dark;

Excel 2016 Chart Styles

Use styles from Style1 to Style9 for Excel 2016 charts. The following table lists supported styles for each chart:

Chart Type Supported Styles
Waterfall Style1 through Style8
Box and Whisker Style1 through Style6
Histogram Style1 through Style6
Pareto Style1 through Style6
Sunburst Style1 through Style8
Funnel Style1 through Style9
Treemap Style1 through Style9

The ChartObject.ColorPalette property allows you to change chart colors.

The example below demonstrates how to create a waterfall chart and specify its colors and style.

Change the chart style and color palette for a waterfall chart

// Create a waterfall chart and specify its location.
Chart chart = worksheet.Charts.Add(ChartType.Waterfall, worksheet["B2:C7"]);
chart.TopLeftCell = worksheet.Cells["E2"];
chart.BottomRightCell = worksheet.Cells["L17"];

// Hide the major gridlines for the value axis.
chart.PrimaryAxes[1].MajorGridlines.Visible = false;

// Specify series options.
var options = chart.Series[0].LayoutOptions.Waterfall;
// Display connector lines.
options.ShowConnectorLines = true;
// Set the third data point as the total.
options.SubtotalDataPoints.Add(2);
// Set the last data point as the total.
options.SubtotalDataPoints.Add(5);

// Specify the chart style.
chart.Style = ChartStyle.Style3;
// Change chart colors.
chart.ColorPalette = ChartColorPalette.Colorful4;

// Add the chart title.
chart.Title.Visible = true;
chart.Title.SetValue("Income Statement");

Custom Style

Use the ChartObject.LoadStyle method to load a custom style from an XML file and apply it to an Excel 2016 chart.

The code sample below applies a custom style to a waterfall chart. The style.xml file contains a definition of a standard style used for histogram and funnel charts.

Apply a custom style to a waterfall chart

// Create a waterfall chart and specify its location.
Chart chart = worksheet.Charts.Add(ChartType.Waterfall, worksheet["B2:C7"]);
chart.TopLeftCell = worksheet.Cells["E2"];
chart.BottomRightCell = worksheet.Cells["L17"];

// Hide the major gridlines for the value axis.
chart.PrimaryAxes[1].MajorGridlines.Visible = false;

// Specify series options.
var options = chart.Series[0].LayoutOptions.Waterfall;
// Display connector lines.
options.ShowConnectorLines = true;
// Set the third data point as the total.
options.SubtotalDataPoints.Add(2);
// Set the last data point as the total.
options.SubtotalDataPoints.Add(5);

// Load a custom style
// and apply it to the chart.
chart.LoadStyle(@"CustomStyles\style.xml");

// Add the chart title.
chart.Title.Visible = true;
chart.Title.SetValue("Income Statement");
See Also