Skip to main content
All docs
V24.1

TdxChartPalette.GetColorsForIndex(Integer) Method

Returns a stored or interpolated palette item for the target index.

Declaration

function GetColorsForIndex(AIndex: Integer): TdxChartPaletteItem;

Parameters

Name Type Description
AIndex Integer

The target palette item index (0 or a positive value):

  • If the specified index is equal to or less than the maximum stored item index, the function returns a stored palette item accessible through the Items property.
  • If the specified index exceeds the maximum stored item index, the function returns a palette item with interpolated colors based on colors of stored palette items.

Note

As the specified index increases, the difference between two adjacent interpolated colors becomes less distinguishable.

Returns

Type Description
TdxChartPaletteItem

A stored or interpolated palette item.

Remarks

While a Chart palette (a TdxChartPalette class descendant instance) stores a finite number of items, you can call the GetColorsForIndex function to generate any number of palette items whose Color and Color2 field values are interpolated based on stored palette item colors.

Code Example

The following code example demonstrates a diagram’s OnGetSeriesPointDrawParameters event handler that uses the Slipstream predefined palette to generate unique fill colors for all point markers in the Europe series:

procedure TFeaturesDemoMainForm.cdLineGetSeriesPointDrawParameters(
  Sender: TdxChartCustomDiagram;
  AArgs: TdxChartGetSeriesPointDrawParametersEventArgs);
var
  ALineDrawParameters: TdxChartLineSeriesPointDrawParameters;
  APalette: TdxChartPalette;
  APaletteItem: TdxChartPaletteItem;
begin
  APalette := TdxChartStandardPaletteRepository.FindPalette('Slipstream');
  if AArgs.SeriesPoint.Series.Caption = 'Europe' then
  begin
    if AArgs.DrawParameters.ClassType <> TdxChartLineSeriesPointDrawParameters then Exit;
    ALineDrawParameters := AArgs.DrawParameters as TdxChartLineSeriesPointDrawParameters;
    APaletteItem := APalette.GetColorsForIndex(AArgs.SeriesPoint.Index);
    ALineDrawParameters.MarkerAppearance.FillOptions.Color := APaletteItem.Color;
  end;
end;

VCL Chart Control: Unique Line Marker Colors

See Also