TdxChartPalette.Count Property
In This Article
Returns the number of explicitly defined (stored) standard palette items.
#Declaration
Delphi
property Count: Integer read;
#Property Value
Type | Description |
---|---|
Integer | The number of stored standard palette items accessible through the Items property. |
#Remarks
You can use the Count
property to iterate through all items in the standard palette.
If the palette does not have enough stored colors to draw all affected series or series values differently, the Chart control generates interpolated colors based on explicitly defined colors.
#Code Example: Copy Standard Palette Colors to a User Palette
The following code example creates a custom palette based on one of the predefined palettes and applies the created palette to a Chart control:
var
AStandardPalette: TdxChartPalette;
AChartPalette: TdxChartUserPalette;
APaletteItems: TdxChartPaletteItems; // A dynamic array of palette items used as a temporary container
I: Integer;
begin
AStandardPalette := TdxChartStandardPaletteRepository.FindPalette('Nature Colors');
if AStandardPalette = nil then Exit;
SetLength(APaletteItems, AStandardPalette.Count);
// Copies all colors from the obtained color palette into the defined dynamic array
for I := 0 to AStandardPalette.Count - 1 do
APaletteItems[I] := AStandardPalette.Items[I];
AChartPalette := dxChartPaletteRepository1.CreateItem('My Palette 1', APaletteItems);
// Replaces the third palette item
AChartPalette.Items[2] := TdxChartPaletteItem.Create(TdxAlphaColors.Red);
// Adds a new palette item
AChartPalette.Count := AChartPalette.Count + 1; // Increments the size of the palette item array
AChartPalette.Items[AChartPalette.Count - 1] := TdxChartPaletteItem.Create(TdxAlphaColors.LightGreen);
dxChartControl1.Palette := AChartPalette; // Assigns the created palette to a TdxChartControl instance
end;
See Also