Error in TColorGridSeries and TLegendPalette

TeeChart VCL for Borland/CodeGear/Embarcadero RAD Studio, Delphi and C++ Builder.
Post Reply
Friis
Newbie
Newbie
Posts: 23
Joined: Mon May 07, 2012 12:00 am

Error in TColorGridSeries and TLegendPalette

Post by Friis » Wed Jan 02, 2013 8:52 am

Hi,

When I use the code below I get an error: "Control '' has no parent window"??

How do i fix that error??

Can You reproduce that error??

Code: Select all

unit Unit10;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, ExtCtrls, TeeProcs, TeEngine, Chart, TeeSurfa, TeeLegendPalette;

type
  TForm10 = class(TForm)
    Chart1: TChart;
    procedure FormShow(Sender: TObject);
    Procedure SetColorPalette;
    procedure InitSeries(ASeries: TCustom3DGridSeries);
    function CoolColorCode(ColorValue:single):TColor;
  private
    { Private declarations }
  public
    LegendPalette : TLegendPaletteTool;
    LegendPalette2 : TLegendPaletteTool;
    ColorPalette: array[0..50] of TColor;
    ColorPaletteLevels: array[0..50] of double;
    { Public declarations }
  end;

var
  Form10: TForm10;

implementation

{$R *.dfm}

procedure TForm10.FormShow(Sender: TObject);
var
i,j,k : integer;
begin

Chart1.RemoveAllSeries;
Chart1.FreeAllSeries();

if (LegendPalette=nil) then
  LegendPalette:=TLegendPaletteTool.Create(Chart1);

Chart1.View3D := false;
Chart1.Legend.Visible := false;
Chart1.Legend.Shadow.Visible := false;
Chart1.Legend.Gradient.Visible := false;
Chart1.Color := clwhite;

Chart1.AddSeries(TColorGridSeries.Create(self));
Chart1[0].ParentChart := Chart1;
SetColorPalette;
InitSeries(TCustom3DGridSeries(Chart1[0]));

with LegendPalette do
  begin
    Series:=Chart1[0];
    Pen.Visible:=false;
    LegendPalette.Left:= Chart1.Width-LegendPalette.Width-10;
    LegendPalette.Height := round(2*Chart1.Height/3);
  end;

Chart1.Tools.Add(LegendPalette);

with Chart1[0] as TColorGridSeries do
  begin
    IrregularGrid := true;
    CenteredPoints := false;
    Pen.Visible := false;
  end;

for i := 0 to 100-1 do
  for k := 0 to 100-1 do
    with Chart1[0] as TColorGridSeries do
      AddXYZ(i,i*k,k);

Chart1.Title.Clear;
Chart1.Title.Text.Add('Mesh Geometry');
Chart1.Title.Font.Size := 18;

Chart1.MarginRight := 10;
LegendPalette.Left:= Chart1.Width-LegendPalette.Width-10;
LegendPalette.Height := Chart1.Height-10;

end;


Procedure TForm10.SetColorPalette;
var
i:integer;
begin

for i := Low(ColorPalette) to High(ColorPalette) do
  begin
    ColorPalette[i] := CoolColorCode(i/High(ColorPalette));
    ColorPaletteLevels[i] := 20 + i*230/High(ColorPalette);
  end;

end;

procedure TForm10.InitSeries(ASeries: TCustom3DGridSeries);
var i: Integer;
begin
  ASeries.UsePalette := True;
  ASeries.UseColorRange := false;

  ASeries.ClearPalette;
  for i := Low(ColorPalette) to High(ColorPalette) do
    ASeries.AddPalette(ColorPaletteLevels[i],ColorPalette[i]);

  ASeries.Repaint;
end;

function TForm10.CoolColorCode(ColorValue:single):TColor;
begin

ColorValue := 100 - ColorValue*100;

if (ColorValue < 0) then
  ColorValue := 0
else if (ColorValue > 100) then
  ColorValue := 100;

if ColorValue < 25 then
  result := rgb(255,round(ColorValue/25*255),0)
else if ColorValue < 50 then
  result := rgb(255-round((ColorValue-25)/25*255),255,0)
else if ColorValue < 75 then
  result := rgb(0,255,round((ColorValue-50)/25*255))
else
  result := rgb(0,255-round((ColorValue-75)/25*255),255);
end;

end.

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

Re: Error in TColorGridSeries and TLegendPalette

Post by Yeray » Wed Jan 02, 2013 11:22 am

Hi Hans,

I've created a new project in Delphi 7, added a chart to the form at design time, changed TForm10 for TForm1, Unit10 for Unit1,... and linked the OnShow event to the FormShow procedure in your code, and it seems to work for me here without problems.
Attachments
test.zip
(2.16 KiB) Downloaded 82 times
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

Friis
Newbie
Newbie
Posts: 23
Joined: Mon May 07, 2012 12:00 am

Re: Error in TColorGridSeries and TLegendPalette

Post by Friis » Wed Jan 02, 2013 11:37 am

Hi Yeray,

You need to click on the chart in order to get the error

I have attached an image of the error message...
Attachments
Error.JPG
Error.JPG (24.73 KiB) Viewed 1662 times

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

Re: Error in TColorGridSeries and TLegendPalette

Post by Yeray » Thu Jan 03, 2013 8:23 am

Hi Hans,

I've found in another post you are using Delphi 2007, isn't it? Just to try it with the same environment than you, because it seems to work fine for me here with Delphi 7 and TeeChart v2012.07.
I've also tried the project attached above in Delphi 2007 with TeeChart v2012.07 and clicked around (on the series, on the legend, on the title,...), zoomed it, scrolled it,... and I can't get any error.
Please, check your installation is correct: check the library and search paths. And if the correct paths are present and on the top of the lists, you could try running TeeInstall.exe twice (one to uninstall and one to reinstall the component), and check the paths again.
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

Friis
Newbie
Newbie
Posts: 23
Joined: Mon May 07, 2012 12:00 am

Re: Error in TColorGridSeries and TLegendPalette

Post by Friis » Thu Jan 03, 2013 9:26 am

Hi,

I'm using TeeChart V2012.05.120327 so I will update to V2012.07.

I'm using Delphi 2007, for Win 32, R2 Version 11.0.2902

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

Re: Error in TColorGridSeries and TLegendPalette

Post by Yeray » Thu Jan 03, 2013 10:32 am

Hi Hans,

I've just seen how the problem was reproducible in TeeChart v2012.05 but in the actual v2012.07. So yes, I'd suggest you to upgrade.
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