Automatically distribute values on custom color palette

TeeChart VCL for Borland/CodeGear/Embarcadero RAD Studio, Delphi and C++ Builder.
Post Reply
X-Ray
Newbie
Newbie
Posts: 49
Joined: Fri Jan 27, 2012 12:00 am

Automatically distribute values on custom color palette

Post by X-Ray » Mon Sep 14, 2015 7:09 am

Hi,

I am using the "AddPalette" call to add a custom color scheme to a TColorGridSeries and a TSurfaceSeries.
In fact I want to supply just the colors and let TChart self/automatically distribute the Chart values along the given
color values.
Is that possible, is there a setting for this ?

best regards,

X-ray

Yeray
Site Admin
Site Admin
Posts: 9613
Joined: Tue Dec 05, 2006 12:00 am
Location: Girona, Catalonia
Contact:

Re: Automatically distribute values on custom color palette

Post by Yeray » Tue Sep 15, 2015 8:34 am

Hello,

Take a look at the following example where I'm loading a custom palette to a TSurfaceSeries.
Note how I'm distributing proportionally the UpToValue list in the palette.

Code: Select all

uses TeeSurfa, TeeLegendPalette;

var Series1: TSurfaceSeries;
    MyPalette: Array of TColor;

procedure TForm1.FormCreate(Sender: TObject);
var t, x, z: Integer;
    tmp, d: Double;
begin
  Chart1.Aspect.Orthogonal:=false;
  Chart1.Chart3DPercent:=100;
  Chart1.Aspect.Zoom:=80;
  Chart1.Legend.Visible:=false;
  Chart1.MarginLeft:=20;

  Chart1.Axes.Depth.Visible:=True;
  Chart1.Axes.Depth.Increment:=1;
  Chart1.Axes.Left.Increment:=0.1;
  Chart1.Axes.Bottom.Increment:=1;

  SetLength(MyPalette,15);
  for t:=0 to 14 do
    MyPalette[t]:=RGB(255-Round(t*(128.0/15.0)),0,0);

  Series1:=Chart1.AddSeries(TSurfaceSeries) as TSurfaceSeries;
  with Series1 do
  begin
    for x:=1 to 10 do
      for z:=1 to 10 do
      begin
        tmp:=cos(x/10.0)*sin(z/10.0);
        AddXYZ(x, tmp, z, '', clTeeColor);
      end;

    ClearPalette;
    for t:=0 to High(MyPalette) do
    begin
      tmp:=(t+1) * (YValues.MaxValue-YValues.MinValue) / (Length(MyPalette)-1);
      AddPalette(tmp, MyPalette[t]);
    end;

    PaletteStyle:=psCustom;
    UseColorRange:=false;
    UsePalette:=true;
  end;

  (Chart1.Tools.Add(TLegendPaletteTool) as TLegendPaletteTool).Series:=Series1;
end;
Best Regards,
ImageYeray Alonso
Development & Support
Steema Software
Av. Montilivi 33, 17003 Girona, Catalonia (SP)
Image Image Image Image Image Image Please read our Bug Fixing Policy

Post Reply