TeeChart FireMonkey (Windows,OSX,iOS & Android) for Embarcadero RAD Studio, Delphi and C++ Builder (XE5+)
-
riskassessor
- Newbie
- Posts: 29
- Joined: Tue Oct 13, 2015 12:00 am
Post
by riskassessor » Thu Mar 31, 2016 8:11 am
When trying to refresh the chart using the command Chart1.Draw, a copy of the chart is created rather than a refresh of the original chart. To reproduce, create a MultiDevice Application. Place a TChart somewhere in the middle of the form. Place a TButton on the form with the following OnClick code:
Code: Select all
procedure TForm1.Button1Click(Sender: TObject);
begin
Chart1.Draw;
end;
Run and click the button. A copy of the chart appears in the top left of the form.
Is this the expected behavior of Draw in Firemonkey? If so, how can I force a refresh when something more than a Repaint is required?
-
Yeray
- Site Admin
- Posts: 9622
- Joined: Tue Dec 05, 2006 12:00 am
- Location: Girona, Catalonia
-
Contact:
Post
by Yeray » Fri Apr 01, 2016 7:36 am
Hello,
I could reproduce the problem so I've added it to the public tracker:
http://bugs.teechart.net/show_bug.cgi?id=1488
Feel free to add your mail to the CC list to be automatically notified when an update arrives.
-
riskassessor
- Newbie
- Posts: 29
- Joined: Tue Oct 13, 2015 12:00 am
Post
by riskassessor » Mon Apr 04, 2016 4:33 am
Given the bug in Draw, how may I force a refresh of a chart? I find my chart refreshes when edits are made in controls but not necessarily when edits are made programmatically. Specifically, I'm recalculating the chart height periodically. Repaint does not force an update after a height revision in code. I was hoping to use Draw for this purpose but since it is not working, what else might I do?
-
Yeray
- Site Admin
- Posts: 9622
- Joined: Tue Dec 05, 2006 12:00 am
- Location: Girona, Catalonia
-
Contact:
Post
by Yeray » Mon Apr 04, 2016 11:48 am
Hello,
As a workaround, this seems to work fine for me here:
Code: Select all
Chart1.Draw(Chart1.DelphiCanvas, RectF(Chart1.Position.X, Chart1.Position.Y, Chart1.Position.X+Chart1.Width, Chart1.Position.Y+Chart1.Height));
-
riskassessor
- Newbie
- Posts: 29
- Joined: Tue Oct 13, 2015 12:00 am
Post
by riskassessor » Tue Apr 05, 2016 12:06 am
Thank you. The proposed workaround works if the chart lies directly on the form. But let's say that the chart is inside a TRectangle that is on the form. Then the code must be modified to:
Code: Select all
procedure TForm1.Button1Click(Sender: TObject);
begin
with Chart1 do
Draw(DelphiCanvas, RectF(Rectangle1.Position.X + Position.X,
Rectangle1.Position.Y + Position.Y,
Rectangle1.Position.X + Position.X + Width,
Rectangle1.Position.Y + Position.Y + Height));
end;
It appears that Chart1.DelphiCanvas covers the entire form. Therefore, Chart1.Draw() (no parameters) redraws the chart in the top left of the form. Chart1.Draw(Chart1.DelphiCanvas, RectF) can be made to redraw the chart in the correct place but the user must calculate the RectF position and size taking into account any components in which the chart is nested.