Skip to main content

DashboardConfigurator.CustomPalette Event

Allows you to substitute a dashboard palette used to paint dashboard item elements.

Namespace: DevExpress.DashboardWeb

Assembly: DevExpress.Dashboard.v26.1.Web.dll

Declaration

public event CustomPaletteWebEventHandler CustomPalette

Event Data

The CustomPalette event's data class is CustomPaletteWebEventArgs. The following properties provide information specific to this event:

Property Description
DashboardId Gets a dashboard identifier.
Palette Gets or sets a palette used to color dashboard item elements.
PaletteName Gets the name of the selected palette.

Remarks

Tip

For information on how to use the DashboardConfigurator‘s API, see the following topic: Server-Side API Overview.

DevExpress Dashboard uses colors from predefined palettes. Use the DashboardPalette static read-only fields to get predefined dashboard palettes.

On the server, you can use the following events to create your own palette with custom colors:

Custom Palette for a Specific Dashboard

The following example illustrates how to apply a custom palette to a dashboard. Create and initialize the DashboardPalette class instance and assign the resulting object to the e.Palette event parameter:

View Example: ASP.NET Core

using DevExpress.DashboardCommon;
using DevExpress.DashboardWeb;
using System.Drawing;

void Default_CustomPalette(object sender, CustomPaletteWebEventArgs e) {
    if (e.DashboardId == "SalesByCategory") {

        // Create a new custom palette.
        List<DashboardPaletteItem> paletteItems = new List<DashboardPaletteItem>();
        paletteItems.Add(new DashboardPaletteItem(Color.LightBlue));
        paletteItems.Add(new DashboardPaletteItem(Color.Aquamarine));
        paletteItems.Add(new DashboardPaletteItem(Color.SkyBlue,DevExpress.Drawing.DXHatchStyle.DiagonalCross));
        paletteItems.Add(new DashboardPaletteItem(Color.LightCoral));
        paletteItems.Add(new DashboardPaletteItem(Color.Tomato));
        paletteItems.Add(new DashboardPaletteItem(Color.IndianRed));
        paletteItems.Add(new DashboardPaletteItem(Color.Violet, DevExpress.Drawing.DXHatchStyle.Sphere, DevExpress.Drawing.DXDashStyle.DashDotDot));
        paletteItems.Add(new DashboardPaletteItem(Color.Plum));
        paletteItems.Add(new DashboardPaletteItem(Color.MediumOrchid));
        // Assign a newly created custom palette to the Web Dashboard.
        e.Palette = new DashboardPalette(paletteItems);
    }
}

The image below displays the resulting palette:

Coloring for Web Dashboard - Custom Palette

Custom Colors for a Predefined Dashboard Palette

Use the e.PaletteName property to replace the colors of a specific built-in palette.

The following code substitutes the Bright palette colors with a custom set:

using DevExpress.DashboardCommon;
using DevExpress.DashboardWeb;
using System.Drawing;

void Default_CustomPalette(object sender, CustomPaletteWebEventArgs e) {
    if (e.PaletteName == nameof(DashboardPalette.Bright)) {

        // Create a new custom palette.
        List<DashboardPaletteItem> paletteItems = new List<DashboardPaletteItem>();
        paletteItems.Add(new DashboardPaletteItem(Color.LightBlue));
        paletteItems.Add(new DashboardPaletteItem(Color.Aquamarine));
        paletteItems.Add(new DashboardPaletteItem(Color.SkyBlue));
        paletteItems.Add(new DashboardPaletteItem(Color.LightCoral));
        paletteItems.Add(new DashboardPaletteItem(Color.Tomato));
        paletteItems.Add(new DashboardPaletteItem(Color.IndianRed));
        paletteItems.Add(new DashboardPaletteItem(Color.Violet));
        paletteItems.Add(new DashboardPaletteItem(Color.Plum, DevExpress.Drawing.DXHatchStyle.Sphere));
        paletteItems.Add(new DashboardPaletteItem(Color.MediumOrchid));
        // Assign a newly created custom palette to the Web Dashboard.
        e.Palette = new DashboardPalette(paletteItems);
    }
}

The image below displays the result:

Coloring for Web Dashboard - Custom Colors in a Predefined Palette

The following code snippet (auto-collected from DevExpress Examples) contains a reference to the CustomPalette event.

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.

See Also