Back to Devexpress

Create a Custom Palette

windowsforms-7435-controls-and-libraries-chart-control-appearance-customization-create-a-custom-palette.md

latest3.5 KB
Original Source

Create a Custom Palette

  • Dec 22, 2020
  • 2 minutes to read

Palettes are used to paint chart series. You can use the predefined palettes that ship with the Chart Control or create a custom palette.

Create and Apply a Palette at Design Time

Click the chart’s smart tag and select the Palettes… link.

This invokes the Palettes dialog that you can use to change the collection of predefined palettes and create new palettes.

Click the Add button.

Rename the newly created palette.

Click the plus button to add new colors to the palette. Double-click a color to change it.

Click OK to save the palette and apply it to the chart. This registers the palette in the Chart Control’s palette repository and adds the palette to the chart toolbar‘s Palette menu.

Create and Apply a Palette at Runtime

The following example shows how to create a palette, register and apply it to a chart:

csharp
// Create a palette.
Palette palette = new Palette("Custom Palette");
palette.Add(Color.Yellow);
palette.Add(Color.Red);
palette.Add(Color.Green);
// Register the palette.
chartControl1.PaletteRepository.RegisterPalette(palette);
// Assign the palette to the chart.
chartControl1.PaletteName = "Custom Palette";
vb
' Create a palette.
Dim palette As Palette = New Palette("Custom Palette")
palette.Add(Color.Yellow)
palette.Add(Color.Red)
palette.Add(Color.Green)
' Register the palette.
chartControl1.PaletteRepository.RegisterPalette(palette)
' Assign the palette to the chart.
chartControl1.PaletteName = "Custom Palette"

See Also

Define an Appearance for Painting All Visual Elements

Choose a Palette for Painting Series, Points and Indicators

Prioritized Appearance and the Appearance Template