Skip to main content
All docs
V24.1

TdxChartPaletteRepository Class

A Chart repository component for user palette management.

Declaration

TdxChartPaletteRepository = class(
    TComponent
)

Remarks

The palette repository is a non-visual component that stores and manages custom palettes for Chart controls.

VCL Chart Control: An Example of a Custom Palette Derived from a Standard Palette

Note

All stored palettes must have unique names that do not match any of the standard palette names. If you attempt to add a palette whose name matches an existing user palette name in the same repository or a standard palette name, an exception occurs.

While user palettes in different repositories can have matching names, we recommend that you define unique names for all palettes in the same application project.

Palette Repository Editor

At design time, you can double-click a TdxChartPaletteRepository component to invoke the Palette Repository Editor dialog. You can use this editor to manage user chart palettes in the project.

VCL Chart Control: The Palette Repository Editor Dialog

Note

You cannot manage the list of standard palettes or customize them.

Refer to the following topic for detailed information on user palette management at design time: Palette Repository Editor.

Main API Members

The list below outlines key members of the TdxChartPaletteRepository class. These members allow you to access and manage chart palettes.

Palette Creation

CreateItem

These functions allow you to create new user palettes in the repository from scratch.

Tip

To delete a user palette, release it directly in code (call the Free procedure in Delphi or use the delete keyword in C++Builder).

CreateItemFromFile | CreateItemFromStream
Load previously created user palettes from a file or stream.

Palette Access

Count
Returns the number of user palettes stored in the repository component.
FindPalette
Allows you to access a standard or user palette by its name.
Items
Provides indexed access to all stored user palettes.

Code Example: Create and Populate a User Palette

The code example below creates a user palette, populates it with three sets of different primary and secondary colors, and applies the created palette to a Chart control with three simple Bar series. All series bars are filled with vertical linear gradients.

var
  AChartPalette: TdxChartUserPalette;
begin
  AChartPalette := dxChartPaletteRepository1.CreateItem('My Palette 1');
  AChartPalette.Count := 3;  // Sets the size of the palette item array
  AChartPalette.Items[0] := TdxChartPaletteItem.Create(TdxAlphaColors.RosyBrown, TdxAlphaColors.Red);
  AChartPalette.Items[1] := TdxChartPaletteItem.Create(TdxAlphaColors.LightGreen, TdxAlphaColors.Green);
  AChartPalette.Items[2] := TdxChartPaletteItem.Create(TdxAlphaColors.LightBlue, TdxAlphaColors.Blue);
  dxChartControl1.Palette := AChartPalette; // Applies the created palette to a Chart control
end;

VCL Chart Control: A Custom Palette with Two Color Pairs for Gradients

Inheritance

TObject
TPersistent
TComponent
TdxChartPaletteRepository
See Also