vcl-dxchartpalette.md
A Chart repository component for user palette management.
TdxChartPaletteRepository = class(
TComponent
)
The palette repository is a non-visual component that stores and manages custom palettes for Chart controls.
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.
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.
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.
The list below outlines key members of the TdxChartPaletteRepository class. These members allow you to access and manage chart palettes.
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 | CreateItemFromStreamLoad previously created user palettes from a file or stream.
CountReturns the number of user palettes stored in the repository component.FindPaletteAllows you to access a standard or user palette by its name.ItemsProvides indexed access to all stored user palettes.
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;
// ...
TdxChartUserPalette *AChartPalette;
// ...
AChartPalette = dxChartPaletteRepository1->CreateItem("My Palette 1");
AChartPalette->Count = 3; // Sets the size of the palette item array
AChartPalette->Items[0] = TdxChartPaletteItem(TdxAlphaColors::RosyBrown, TdxAlphaColors::Red);
AChartPalette->Items[1] = TdxChartPaletteItem(TdxAlphaColors::LightGreen, TdxAlphaColors::Green);
AChartPalette->Items[2] = TdxChartPaletteItem(TdxAlphaColors::LightBlue, TdxAlphaColors::Blue);
dxChartControl1->Palette = AChartPalette; // Applies the created palette to a Chart control
TObject TPersistent TComponent TdxChartPaletteRepository
See Also
TdxChartStandardPaletteRepository Class