Control 'chartTest' has no parent window
-
- Newbie
- Posts: 14
- Joined: Mon Jan 18, 2016 12:00 am
Control 'chartTest' has no parent window
I just upgraded to 2016.19.161025 and I get an exception (Control 'chartTest' has no parent window) for a chart I create fully in code. It occurs when I call the .Draw method. I will post an example here soon but I sure would like to have a fix to this ASAP.
Ed Dressel
Ed Dressel
-
- Newbie
- Posts: 14
- Joined: Mon Jan 18, 2016 12:00 am
Re: Control 'chartTest' has no parent window
Attached is a demo that creates the problem. (I just tested 2016.18 and it worked fine. It only seems to occur in .19).
- Attachments
-
- No Parent Control Num 2.zip
- (1.88 KiB) Downloaded 808 times
Re: Control 'chartTest' has no parent window
Hello Test Always,
The problem you're experiencing appears for me using TeeChart Pro VCL/FMX v2016.18, too. But in any case, to fix the problem you should only assign to result.Parent property the parent window it needs. You can modify the code in same way I have done below:
Hoping this helps.
Thanks in advance,
The problem you're experiencing appears for me using TeeChart Pro VCL/FMX v2016.18, too. But in any case, to fix the problem you should only assign to result.Parent property the parent window it needs. You can modify the code in same way I have done below:
Code: Select all
function TFOrm1.CreateChart: TChart;
begin
result := TChart.Create(nil);
result.Parent := Self;
//result.Canvas := TTeeCanvas3D.Create; doesn't allow transparent series for batch gap chart
result.Color := clWhite;
result.BevelOuter := bvNone;
result.LeftAxis.Grid.Color := clSilver;
// result.LeftAxis.LabelsFont.Name := 'Arial Narrow'; {added from Gap Chart}
result.LeftAxis.AutomaticMinimum := False; {added from Gap Chart}
result.LeftAxis.Minimum := 0; {added from Gap Chart}
result.LeftAxis.MinorTicks.Visible := False; {added from Gap Chart}
result.LeftAxis.TicksInner.Visible := False; {added from Gap Chart}
result.LeftAxis.Ticks.Style := psDot;
result.LeftAxis.TickLength := 2; {added from Gap Chart}
result.LeftAxis.Axis.Width := 1;
result.LeftAxis.Title.Font.Name := 'Arial Narrow';
result.BottomAxis.Axis.Color := clSilver;
result.BottomAxis.MinorTicks.Visible := false; {added from Gap Chart}
result.BottomAxis.Ticks.Visible := false;
// result.BottomAxis.LabelsFont.Name := 'Arial Narrow';
result.BottomAxis.Grid.Visible := False;
result.BottomAxis.Axis.Width := 1;
result.Legend.Frame.Visible := False;
result.Legend.Title.Font.Name := 'Arial Narrow';
result.Legend.Title.Font.Style := [];
result.Legend.Shadow.VertSize := 0;
result.Legend.LegendStyle := lsSeries;
result.Legend.Shadow.HorizSize := 0;
result.Legend.Alignment := laRight;
result.Legend.Transparent := True;
result.LeftAxis.Axis.Color := clSilver;
result.LeftAxis.AxisValuesFormat := '$,0';
result.Walls.Visible := False;
result.BackWall.Pen.Color := clSilver;
// result.OnGetAxisLabel := ChartAxisLabel;
result.View3D := False;
end;
procedure TForm1.CreateChartImage;
var
lChart: TChart;
function CreateChartSeries: TAreaSeries;
begin
result := TAreaSeries.Create(self);
result.ParentChart := lChart;
result.AreaLinesPen.Visible := false;
result.Pen.Visible := false;
end;
var
lRect: TRect;
begin
lChart := CreateChart;
try
lChart.LeftAxis.Title.Font.Size := 10;
lChart.BottomAxis.Title.Caption := 'Years in Retirement';
lChart.BottomAxis.Title.Font.Size := 10;
lChart.Legend.CustomPosition := True;
lRect := Rect(1, 1, Image1.Width, Image1.Height);
lChart.SetBounds(0, 0, lRect.Width, lRect.Height);
lChart.Draw;
lChart.Draw;
finally // wrap up
// lChart.FreeAllSeries;
// lChart.Free;
end; // try/finally
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
CreateChartImage;
end;
Thanks in advance,
Best Regards,
Sandra Pazos / Development & Support Steema Software Avinguda Montilivi 33, 17003 Girona, Catalonia Tel: 34 972 218 797 http://www.steema.com |
Instructions - How to post in this forum |
-
- Newbie
- Posts: 14
- Joined: Mon Jan 18, 2016 12:00 am
Re: Control 'chartTest' has no parent window
This was only a demo. The actual chart is created in a data module (so "self" does not work) and I also use this in a online service and would prefer not have to create a TForm.
This wasn't this way in 2015.x.
Can this be fixed?
Ed Dressel
This wasn't this way in 2015.x.
Can this be fixed?
Ed Dressel
Re: Control 'chartTest' has no parent window
Hello Ed Dessel,
The problem appears for me, too using Teechart Pro V2015.16 version. Could you tell us in which exactly TeeChart Pro 2015 version, the problem doesn't appear for you?
Also, I'm sorry the code we offers you doesn't help but it fix the demo example you send us. Is possible you attached the project you're using because we can try to find a solution for the problem you're experiencing? If it is large you can upload it in the link below:
http://www.steema.net/upload/
Thanks in advance
The problem appears for me, too using Teechart Pro V2015.16 version. Could you tell us in which exactly TeeChart Pro 2015 version, the problem doesn't appear for you?
Also, I'm sorry the code we offers you doesn't help but it fix the demo example you send us. Is possible you attached the project you're using because we can try to find a solution for the problem you're experiencing? If it is large you can upload it in the link below:
http://www.steema.net/upload/
Thanks in advance
Best Regards,
Sandra Pazos / Development & Support Steema Software Avinguda Montilivi 33, 17003 Girona, Catalonia Tel: 34 972 218 797 http://www.steema.com |
Instructions - How to post in this forum |
-
- Newbie
- Posts: 14
- Joined: Mon Jan 18, 2016 12:00 am
Re: Control 'chartTest' has no parent window
I hope you have (or had as your probably wont' get to this in 2016) an wonderful New Years and that 2017 is a great year for your.
I appreciate your attention to this issue.
After reviewing my code I didn't t understand what is happening--you are correct (as you know) that the demo does not work in .18 either.
My demo was a very simplified version of what we are doing in code, and I removed quite a bit. But after reviewing more, I did find the issue.
In the (updated) attached demo the way the image gets generated is a little different and optionally uses the TTeeCanvas3D class.
This demo now works in 2016.18 but raises an exception in 2016.19.
Please advise.
Ed Dressel
I appreciate your attention to this issue.
After reviewing my code I didn't t understand what is happening--you are correct (as you know) that the demo does not work in .18 either.
My demo was a very simplified version of what we are doing in code, and I removed quite a bit. But after reviewing more, I did find the issue.
In the (updated) attached demo the way the image gets generated is a little different and optionally uses the TTeeCanvas3D class.
This demo now works in 2016.18 but raises an exception in 2016.19.
Please advise.
Ed Dressel
- Attachments
-
- No Parent Control Num 2.zip
- (7.86 KiB) Downloaded 824 times
Re: Control 'chartTest' has no parent window
Hello Ed Dressel,
Many thanks for the clarification.
I have added the problem in the TeeChart VCL Bugzilla tracker to review it to upcoming releases. Here's the link: http://bugs.teechart.net/show_bug.cgi?id=1738
Also, I would like suggest you, comment the Draw method so the application works fine without that.
Hoping this helps you
Thanks in advance
Many thanks for the clarification.
I have added the problem in the TeeChart VCL Bugzilla tracker to review it to upcoming releases. Here's the link: http://bugs.teechart.net/show_bug.cgi?id=1738
Also, I would like suggest you, comment the Draw method so the application works fine without that.
Hoping this helps you
Thanks in advance
Best Regards,
Sandra Pazos / Development & Support Steema Software Avinguda Montilivi 33, 17003 Girona, Catalonia Tel: 34 972 218 797 http://www.steema.com |
Instructions - How to post in this forum |
-
- Newbie
- Posts: 14
- Joined: Mon Jan 18, 2016 12:00 am
Re: Control 'chartTest' has no parent window
Sigh. If I remove the .Draw command the custom positioned legend does not work. (This was told to do this by Steema's support).
Please let me know how to move forward.
Ed Dressel
Please let me know how to move forward.
Ed Dressel
Re: Control 'chartTest' has no parent window
Hello,
In that case, an alternative would be to add some margin at the top instead of forcing a chart repaint:
I see the legend is drawn on top of the chart if you don't force a chart repaint. I'm not sure if this was the exact cause of that suggestion.Test Always wrote:Sigh. If I remove the .Draw command the custom positioned legend does not work. (This was told to do this by Steema's support).
In that case, an alternative would be to add some margin at the top instead of forcing a chart repaint:
Code: Select all
function TdmCreateChart.CreateImage(aRect: TRect): TGraphic;
//...
lChart.Legend.CustomPosition := True;
lSrs := CreateChartSeries;
lSrs.FillSampleValues(100);
lChart.SetBounds(aRect.Left, aRect.Top, aRect.Right, aRect.Bottom);
lChart.MarginTop:=10; //Add some margin at the top
{lChart.Draw;
lChart.Draw;}
//...
Best Regards,
Yeray Alonso Development & Support Steema Software Av. Montilivi 33, 17003 Girona, Catalonia (SP) | |
Please read our Bug Fixing Policy |
-
- Newbie
- Posts: 14
- Joined: Mon Jan 18, 2016 12:00 am
Re: Control 'chartTest' has no parent window
Like I said this is a simple demo of a much more complex situation. I really don't want to chase down every little item to show you that I really need to call the .draw command. I do--because the positioning of the legend needs more than just a margin begin set.
To set the position of the legend, I use the following code:
Adding a margin doesn't get me this. 2016.19 does not work for my team (we have 4 licenses)--what worked before, and how Steema support told me to implement it (calling the .draw command 2x), is broken in 2016.19.
Ed Dressel
To set the position of the legend, I use the following code:
Code: Select all
...
lChart.OnAfterDraw := GapChartAfterDraw;
...
procedure TMyUnit.GapChartAfterDraw(Sender: TObject);
begin
Assert(sender is TChart);
AdjustGapChartLegend(Sender as TChart);
end;
procedure TMyUnit.AdjustGapChartLegend(aChart: TChart);
var
lLeft: Integer;
begin
if (aChart.SeriesCount > 0) and (aChart.Series[0].Count > 0) then
begin
lLeft := aChart.Series[0].CalcXPos(1);
aChart.Legend.Left := lLeft;
end;
end;
Ed Dressel
Re: Control 'chartTest' has no parent window
Hello Ed,
There was a change in v2016.19 forcing the chart to have a parent when you call Draw method.
An alternative would be to call TeeCreateBitmap.
There was a change in v2016.19 forcing the chart to have a parent when you call Draw method.
An alternative would be to call TeeCreateBitmap.
Best Regards,
Yeray Alonso Development & Support Steema Software Av. Montilivi 33, 17003 Girona, Catalonia (SP) | |
Please read our Bug Fixing Policy |