Page 1 of 1

Automatically distribute values on custom color palette

Posted: Mon Sep 14, 2015 7:09 am
by 16561419
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

Re: Automatically distribute values on custom color palette

Posted: Tue Sep 15, 2015 8:34 am
by yeray
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;