Page 1 of 1

Palette Update Problem

Posted: Fri Dec 15, 2023 1:30 pm
by 16594956
Hello TChart Team,

There is a problem/bug since the latest version of TChart VCL, with the Display of 3DGridSeries when "UsePalette" is set/used.
Everything is displayed in just ONE color and the Legend just shows Zeros.
PaletteProblemCapture1.PNG
PaletteProblemCapture1.PNG (134.4 KiB) Viewed 16996 times
When I then go into the Chart dialog and Set "UsePaletteMin / Auto" to TRUE :
PaletteProblemCapture2.PNG
PaletteProblemCapture2.PNG (78.38 KiB) Viewed 16996 times
Its starts to get "normal":
PaletteProblemCapture3.PNG
PaletteProblemCapture3.PNG (335.57 KiB) Viewed 16996 times
Note that we do all Chart operation in code and when I set "UsePaletteMin" to True for the 3DGridSeries in Code, that
doesn't help, we still get the ONE Color Chart and zeros in the Legend. Only when I open the TChart Editor Dialog things get correctly updated. Is this bug known and fixed already?

Thanks and best regards,

Thomas

Re: Palette Update Problem

Posted: Fri Dec 15, 2023 9:05 pm
by 16594956
I just found out that I can fix this problem by calling "CreateDefaultPalette()" After populating TSurfaceSeries or TColorGridSeries.
That call was not required in previous versions of TChart VCL.

Re: Palette Update Problem

Posted: Fri Dec 22, 2023 9:11 am
by yeray
Hello,

When the chart is being drawn, the CheckPaletteEmpty method should be called, which calls CreateDefaultPalette in these conditions:

Code: Select all

// Default palette should be re-created when: series has data, and
// when palette is empty or "dirty" and not custom.
Procedure TCustom3DPaletteSeries.CheckPaletteEmpty;
begin
  if (Count>0) and ( (Length(FPalette)=0) or (IDirtyPalette and (not ICustomPalette))) then
     CreateDefaultPalette;
end;
This simple example seems to correctly initialize the palette for me here:

Code: Select all

uses Chart, TeeSurfa;

var Chart1: TChart;

procedure TForm1.FormCreate(Sender: TObject);
var x, z: Integer;
begin
  Chart1:=TChart.Create(Self);

  with Chart1 do
  begin
    Parent:=Self;
    Align:=alClient;
    Color:=clWhite;
    Gradient.Visible:=False;
    Walls.Back.Color:=clWhite;
    Walls.Back.Gradient.Visible:=False;
    View3DOptions.Orthogonal:=False;
    Chart3DPercent:=100;
    Aspect.Zoom:=75;

    with TSurfaceSeries(AddSeries(TSurfaceSeries)) do
    begin
      UseColorRange:=False;
      UsePalette:=True;

      for x:=0 to 9 do
        for z:=0 to 9 do
          AddXYZ(x, x+z, z);
    end;
  end;
end;
surface.png
surface.png (76.19 KiB) Viewed 16811 times
Do you see if I'm missing anything here?