Steema Issues Database

Note: This database is for bugs and wishes only. For technical support help, if you are a customer please visit our online forums;
otherwise you can use StackOverflow.
Before using this bug-tracker we recommend a look at this document, Steema Bug Fixing Policy.



Bug 271

Summary: [TV52016026] Use a Custom Palette for the TContourSeries. If we try the code belo...
Product: VCL TeeChart Reporter: yeray alonso <yeray>
Component: SeriesAssignee: Steema Issue Manager <issuemanager>
Status: RESOLVED NOTABUG    
Severity: enhancement CC: david
Priority: Normal    
Version: unspecified   
Target Milestone: ---   
Hardware: All   
OS: All   
Chart Series: --- Delphi / C++ Builder RAD IDE Version:

Description yeray alonso 2013-11-20 10:35:40 EST
Use a Custom Palette for the TContourSeries.
If we try the code below, the default palette is still used:
uses TeeSurfa;
procedure TForm1.FormCreate(Sender: TObject);
var JMPPalette: TCustom3DPalette;
    i: Integer;
begin
  Chart1.View3D:=false;
  with Chart1.AddSeries(TContourSeries) as TContourSeries do
  begin
    FillSampleValues();
    SetLength(JMPPalette,5);
    JMPPalette[0].Color:= clBlack;
    JMPPalette[1].Color:= clBlue;
    JMPPalette[2].Color:= clGreen;
    JMPPalette[3].Color:= clYellow;
    JMPPalette[4].Color:= clRed;
    NumLevels:=Length(JMPPalette);
    CreateAutoLevels;
    for i := 0 to NumLevels-1 do JMPPalette[i].UpToValue:=Levels[i].UpToValue;
    Palette:=JMPPalette;
    Marks.Visible:=true;
    Brush.Style:=bsSolid;
  end;
end;
I think the problem is that when we assing the custom Palette, the ILevels color list should use it.
Aproximation:
Changing the 3992 in TeeSurfa.pas, where says:
          tmpIso.Palette[t].Color:=ILevels[t].Color;
For this:
          tmpIso.Palette[t].Color:=Palette[t].Color;
The example above works fine but it breaks the colors when you don't use a palette.
Suggested fix!
In TeeSurfa.pas, in the PrepareLevels procedure. If you change the line:
        Color:=Level.InternalColor;
For this:
      if UsePalette then
        Color:=Palette[TheLevel].Color
      else
        Color:=Level.InternalColor;
Then you can add UsePalette:=true in your application to make the custom palette work. [created:2012-02-09T17:36:24.000+01:00 reported by:yeray@steema.com reported in version:2011.04.41118 (TeeChart VCL)]
Comment 1 david berneda 2013-12-19 11:22:31 EST
One easy way to make it work is to set the Color manually:

    for i := 0 to NumLevels-1 do
    begin
      JMPPalette[i].UpToValue:=Levels[i].UpToValue;
      Levels[i].Color:=JMPPalette[i].Color;   // <----------- HERE
    end;


Maybe the best fix would be to make this automatically whenever the Palette property is changed:

    Series1.Palette:=JMPPalette;   // <---- At this time

Another workaround to make this work, it to call again CreateAutoLevels after then palette has been changed:

    Series1.Palette:=JMPPalette;
    Series1.CreateAutoLevels;    // <--- Calling this, will use JMPPalette
Comment 2 david berneda 2013-12-19 11:35:38 EST
Finally found a reason.
This problem its not exactly a bug. The problem is Series1.ColorEachPoint is True and so, the level colors are obtained from the Chart1.ColorPalette instead of from Series1.Palette.

Adding this code before calling CreateAutoLevels makes it to work fine:

    Series1.ColorEachPoint:=False;
    Series1.UseColorRange:=False;
    Series1.UsePalette:=True;

    Palette:=JMPPalette;
    CreateAutoLevels;