Back to Devexpress

ShapeOutlineFill.SetSolidFill(Color) Method

officefileapi-devexpress-dot-spreadsheet-dot-drawings-dot-shapeoutlinefill-dot-setsolidfill-x28-system-dot-drawing-dot-color-x29.md

latest9.1 KB
Original Source

ShapeOutlineFill.SetSolidFill(Color) Method

Sets a solid color fill for a drawing object’s element.

Namespace : DevExpress.Spreadsheet.Drawings

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

NuGet Package : DevExpress.Spreadsheet.Core

Declaration

csharp
void SetSolidFill(
    Color color
)
vb
Sub SetSolidFill(
    color As Color
)

Parameters

NameTypeDescription
colorColor

A Color object that specifies the color used to fill a drawing object’s element.

|

Example

The example below demonstrates how to create a clustered column chart and adjust its appearance. First, add the chart title and change the font color via the ShapeTextFont.Color property. Make the plot area transparent by using the ShapeOutlineFill.SetNoFill method, and then apply the gradient fill to the chart area by utilizing the ShapeOutlineFill.SetGradientFill method. To set the picture fill for all columns in a chart, call the ShapeFill.SetPictureFill method for a series object. Finally, change the color of the primary axes by utilizing the ShapeOutlineFill.SetSolidFill method and specify the axis width via the ShapeOutline.Width property.

View Example: Spreadsheet Chart API

csharp
Worksheet worksheet = workbook.Worksheets["chartTask7"];
workbook.Worksheets.ActiveWorksheet = worksheet;

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

// Add and format the chart title.
chart.Title.SetValue("Countries with the largest forest area");
chart.Title.Font.Color = Color.FromArgb(0x34, 0x5E, 0x25);

// Set no fill for the plot area.
chart.PlotArea.Fill.SetNoFill();

// Apply the gradient fill to the chart area.
chart.Fill.SetGradientFill(ShapeGradientType.Linear, Color.FromArgb(0xFD, 0xEA, 0xDA), Color.FromArgb(0x77, 0x93, 0x3C));
ShapeGradientFill gradientFill = chart.Fill.GradientFill;
gradientFill.Stops.Add(0.78f, Color.FromArgb(0xB7, 0xDE, 0xE8));
gradientFill.Angle = 90;

// Set the picture fill for the data series.
chart.Series[0].Fill.SetPictureFill("Pictures\\PictureFill.png");

// Customize the axis appearance.
AxisCollection axisCollection = chart.PrimaryAxes;
foreach (Axis axis in axisCollection)
{
    axis.MajorTickMarks = AxisTickMarks.None;
    axis.Outline.SetSolidFill(Color.FromArgb(0x34, 0x5E, 0x25));
    axis.Outline.Width = 1.25;
}
// Change the scale of the value axis.
Axis valueAxis = axisCollection[1];
valueAxis.Scaling.AutoMax = false;
valueAxis.Scaling.Max = 8000000;
valueAxis.Scaling.AutoMin = false;
valueAxis.Scaling.Min = 0;
// Specify display units for the value axis.
valueAxis.DisplayUnits.UnitType = DisplayUnitType.Thousands;
valueAxis.DisplayUnits.ShowLabel = true;

// Hide the legend.
chart.Legend.Visible = false;
vb
Dim worksheet As Worksheet = workbook.Worksheets("chartTask7")
workbook.Worksheets.ActiveWorksheet = worksheet

' Create a chart and specify its location.
Dim chart As Chart = worksheet.Charts.Add(ChartType.ColumnClustered, worksheet("B2:C8"))
chart.TopLeftCell = worksheet.Cells("F2")
chart.BottomRightCell = worksheet.Cells("N17")

' Add and format the chart title.
chart.Title.SetValue("Countries with the largest forest area")
chart.Title.Font.Color = Color.FromArgb(&H34, &H5E, &H25)

' Set no fill for the plot area.
chart.PlotArea.Fill.SetNoFill()

' Apply the gradient fill to the chart area.
chart.Fill.SetGradientFill(ShapeGradientType.Linear, Color.FromArgb(&HFD, &HEA, &HDA), Color.FromArgb(&H77, &H93, &H3C))
Dim gradientFill As ShapeGradientFill = chart.Fill.GradientFill
gradientFill.Stops.Add(0.78F, Color.FromArgb(&HB7, &HDE, &HE8))
gradientFill.Angle = 90

' Set the picture fill for the data series.
chart.Series(0).Fill.SetPictureFill("Pictures\PictureFill.png")

' Customize the axis appearance.
Dim axisCollection As AxisCollection = chart.PrimaryAxes
For Each axis As Axis In axisCollection
    axis.MajorTickMarks = AxisTickMarks.None
    axis.Outline.SetSolidFill(Color.FromArgb(&H34, &H5E, &H25))
    axis.Outline.Width = 1.25
Next axis
' Change the scale of the value axis.
Dim valueAxis As Axis = axisCollection(1)
valueAxis.Scaling.AutoMax = False
valueAxis.Scaling.Max = 8000000
valueAxis.Scaling.AutoMin = False
valueAxis.Scaling.Min = 0
' Specify display units for the value axis.
valueAxis.DisplayUnits.UnitType = DisplayUnitType.Thousands
valueAxis.DisplayUnits.ShowLabel = True

' Hide the legend.
chart.Legend.Visible = False

The following code snippets (auto-collected from DevExpress Examples) contain references to the SetSolidFill(Color) method.

Note

The algorithm used to collect these code examples remains a work in progress. Accordingly, the links and snippets below may produce inaccurate results. If you encounter an issue with code examples below, please use the feedback form on this page to report the issue.

spreadsheet-document-api-chart-examples/CS/SpreadsheetDocServerChartAPISamples/CodeExamples/StyleActions.cs#L62

csharp
// Change the series colors.
chart.Series[0].Fill.SetSolidFill(Color.FromArgb(0x66, 0xff, 0x66));
chart.Series[1].Fill.SetSolidFill(Color.FromArgb(0xff, 0xff, 0x33));

wpf-spreadsheet-chart-api/CS/SpreadsheetWPFChartAPISamples/CodeExamples/StyleActions.cs#L38

csharp
// Change the series colors.
chart.Series[0].Fill.SetSolidFill(Color.FromArgb(0x66, 0xff, 0x66));
chart.Series[1].Fill.SetSolidFill(Color.FromArgb(0xff, 0xff, 0x33));

winforms-spreadsheet-chart-api/CS/SpreadsheetChartAPISamples/CodeExamples/StyleActions.cs#L57

csharp
// Change the series colors.
chart.Series[0].Fill.SetSolidFill(Color.FromArgb(0x66, 0xff, 0x66));
chart.Series[1].Fill.SetSolidFill(Color.FromArgb(0xff, 0xff, 0x33));

spreadsheet-document-api-chart-examples/VB/SpreadsheetDocServerChartAPISamples/CodeExamples/StyleActions.vb#L64

vb
' Change the series colors.
chart.Series(0).Fill.SetSolidFill(Color.FromArgb(&H66, &HFF, &H66))
chart.Series(1).Fill.SetSolidFill(Color.FromArgb(&HFF, &HFF, &H33))

wpf-spreadsheet-chart-api/VB/SpreadsheetWPFChartAPISamples/CodeExamples/StyleActions.vb#L42

vb
' Change the series colors.
chart.Series(0).Fill.SetSolidFill(Color.FromArgb(&H66, &Hff, &H66))
chart.Series(1).Fill.SetSolidFill(Color.FromArgb(&Hff, &Hff, &H33))

winforms-spreadsheet-chart-api/VB/SpreadsheetChartAPISamples/CodeExamples/StyleActions.vb#L41

vb
' Change the series colors.
chart.Series(0).Fill.SetSolidFill(Color.FromArgb(&H66, &Hff, &H66))
chart.Series(1).Fill.SetSolidFill(Color.FromArgb(&Hff, &Hff, &H33))

See Also

ShapeOutlineFill Interface

ShapeOutlineFill Members

DevExpress.Spreadsheet.Drawings Namespace