Events make chart the wrong size, image rendered incorrectly

TeeChart VCL for Borland/CodeGear/Embarcadero RAD Studio, Delphi and C++ Builder.
TestAlways
Advanced
Posts: 228
Joined: Tue Aug 28, 2007 12:00 am
Location: Oregon, USA

Events make chart the wrong size, image rendered incorrectly

Post by TestAlways » Wed Mar 12, 2014 5:18 pm

The latest update (2014.10) has some significant problems.

In the attached demo, there is a check box in the header, "Create with Events". When it is checked, the chart is created incorrectly and the (duplicate) image is different than the chart.

I really need a fix to this.

Thanks
Ed Dressel
Attachments
Image Wrong Size.zip
(2.72 KiB) Downloaded 641 times

tmac2
Newbie
Newbie
Posts: 2
Joined: Mon Jun 17, 2013 12:00 am

Re: Events make chart the wrong size, image rendered incorrectly

Post by tmac2 » Wed Mar 12, 2014 8:14 pm

TeeChart Pro 2014.10.140220, Delphi XE, Win XP
I have a similar problem and found that by simply having OnGetAxisLabel hooked, the chart changes size. The event handler can do nothing at all and the problem will be seen. This project demonstrates the problem. When the "Hook OnGetAxisLabel" checkbox is checked, it will cause the chart to "shrink" vertically.

TeeChart Pro 2013.09.131119 does not have this problem -- it works as expected.

1-SizeOK.png
This is the correct size without any labels overridden.

2-SizeNG.png
Hook OnGetAxisLabel and the resizing appears.

3-SizeNG-ChangedLabels.png
When hooked, changing the labels causes no further "damage".
Attachments
Tee-OnGetAxisLabel.zip
Sample project with screenshots
(129.59 KiB) Downloaded 637 times

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

Re: Events make chart the wrong size, image rendered incorrectly

Post by Yeray » Thu Mar 13, 2014 2:54 pm

Hi Ed,
TestAlways wrote:The latest update (2014.10) has some significant problems.

In the attached demo, there is a check box in the header, "Create with Events". When it is checked, the chart is created incorrectly and the (duplicate) image is different than the chart.
I've added this to your project, to identify the TeeChart version being used:

Code: Select all

uses TeeConst;

procedure TForm1.FormCreate(Sender: TObject);
begin
  Caption:=TeeMsg_Version;
end;
Here it is what I obtain with the last TeeChart versions:
v2013.09.png
v2013.09.png (19.8 KiB) Viewed 20302 times
v2014.10.png
v2014.10.png (15.68 KiB) Viewed 20299 times
v2014.11.png
v2014.11.png (21.6 KiB) Viewed 20299 times
With the actual sources (last screenshot, v2014.11) only the legend of the second chart looks wrong. We'll continue investigating it and we'll be back here asap.
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

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

Re: Events make chart the wrong size, image rendered incorrectly

Post by Yeray » Thu Mar 13, 2014 3:06 pm

Hello tmac2,
tmac2 wrote:TeeChart Pro 2014.10.140220, Delphi XE, Win XP
I have a similar problem and found that by simply having OnGetAxisLabel hooked, the chart changes size. The event handler can do nothing at all and the problem will be seen. This project demonstrates the problem. When the "Hook OnGetAxisLabel" checkbox is checked, it will cause the chart to "shrink" vertically.

TeeChart Pro 2013.09.131119 does not have this problem -- it works as expected.

1-SizeOK.png
This is the correct size without any labels overridden.

2-SizeNG.png
Hook OnGetAxisLabel and the resizing appears.

3-SizeNG-ChangedLabels.png
When hooked, changing the labels causes no further "damage".
I could reproduce the problem with v2014.10 and also see how with v2013.09 the chart height didn't change.
Then I've checked it with the actual sources we have here and seen it isn't reproducible any more, so I'd expect it to be fixed with the next maintenance release.
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

TestAlways
Advanced
Posts: 228
Joined: Tue Aug 28, 2007 12:00 am
Location: Oregon, USA

Re: Events make chart the wrong size, image rendered incorrectly

Post by TestAlways » Thu Mar 13, 2014 3:22 pm

I'm a bit frustrated. The last few versions of TChart have been buggy. We are still using 2013.08.
With the actual sources (last screenshot, v2014.11) only the legend of the second chart looks wrong. We'll continue investigating it and we'll be back here asap.
1) Do I have access to 2014.11? I don't know what that is--I checked my downloads and it is not available.

2) With having the source, why aren't there patch instructions?

Ed Dressel

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

Re: Events make chart the wrong size, image rendered incorrectly

Post by Yeray » Thu Mar 13, 2014 3:47 pm

Hello,

Since both you are source code customers, I've prepared a beta installer so you can check what I found above.
I'll send the link to the mail accounts you have registered in this forum.
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

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

Re: Events make chart the wrong size, image rendered incorrectly

Post by Yeray » Fri Mar 14, 2014 11:35 am

Hello Ed,

Regarding the problem you report in the first post here, I've been playing with the testing application you attached and found what look as "bad practices" in it.
- You are calling the UpdateGapChart method at the Form Resize override. Since UpdateGapChart is removing all the series and recreating them, you are doing this each time the form is being resized. Why don't you do the initialization at Form OnCreate event or OnShow? This way this job will only be done once.
- You are setting Legend.Left:=5 at UpdateGapChart. Then, if the events are assigned, you are setting Legend.Left:=Series[0].CalcXPos(1). If you debug the application, you'll see how each time you resize the form, both lines are executed. Changing a property like this two times at different moments in the drawing process may be a problem.

Take a look at the modifications I've made to the testing application you sent. It works fine for me with the sources I sent you yesterday.
I'm basically setting the chart and the series at the Form OnCreate instead on at the Form Resize override and calling two times the UpdateGapChart, with a chart repaint in the middle to make sure all the properties are updated before the exportation to bitmap.
Image Wrong Size.zip
(2.64 KiB) Downloaded 640 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

TestAlways
Advanced
Posts: 228
Joined: Tue Aug 28, 2007 12:00 am
Location: Oregon, USA

Re: Events make chart the wrong size, image rendered incorrectly

Post by TestAlways » Fri Mar 14, 2014 2:56 pm

Thank you for this--obviously the code I sent you was test code and not release code. In our code the does not not exist in the GUI, it is only there to create for a report, so it is a bit different.

As for the code release you sent me--I can't use it as it is a beta release. I need a solid release.

Ed Dressel

Narcís
Site Admin
Site Admin
Posts: 14730
Joined: Mon Jun 09, 2003 4:00 am
Location: Banyoles, Catalonia
Contact:

Re: Events make chart the wrong size, image rendered incorrectly

Post by Narcís » Fri Mar 14, 2014 3:03 pm

Hello Ed,

In that case you'll have to wait until the next maintenance release. In the meantime you can either patch your sources or install a previous version where this functionality worked.
Best Regards,
Narcís Calvet / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Image Image Image Image Image Image
Instructions - How to post in this forum

tmac2
Newbie
Newbie
Posts: 2
Joined: Mon Jun 17, 2013 12:00 am

Re: Events make chart the wrong size, image rendered incorrectly

Post by tmac2 » Fri Mar 14, 2014 7:32 pm

Yeray wrote:Hello,

Since both you are source code customers, I've prepared a beta installer so you can check what I found above.
I'll send the link to the mail accounts you have registered in this forum.
Yeray,

Thank you very much for the speedy response! This worked great with all the charts that were a problem. Everything is "like it used to be" now.

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

Re: Events make chart the wrong size, image rendered incorrectly

Post by Yeray » Mon Mar 17, 2014 11:37 am

Hello,
tmac2 wrote:Thank you very much for the speedy response! This worked great with all the charts that were a problem. Everything is "like it used to be" now.
Great! Thanks for the feedback!
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

TestAlways
Advanced
Posts: 228
Joined: Tue Aug 28, 2007 12:00 am
Location: Oregon, USA

Re: Events make chart the wrong size, image rendered incorrectly

Post by TestAlways » Thu Mar 20, 2014 11:56 pm

I finally got around to downloading and testing.

See the attached demo. The chart is correct, but in the image, the legend is not located correctly.

Ed Dressel
Attachments
Image Wrong Size.zip
(2.69 KiB) Downloaded 628 times

Narcís
Site Admin
Site Admin
Posts: 14730
Joined: Mon Jun 09, 2003 4:00 am
Location: Banyoles, Catalonia
Contact:

Re: Events make chart the wrong size, image rendered incorrectly

Post by Narcís » Fri Mar 21, 2014 11:05 am

Hi Ed,

Thanks for your feedback.

The problem is only with the code in the OnBeforeDrawSeries event. Looks like the chart hasn't calculated the series positions (CalcXPos call) before rendering the image. Therefore the legend is not positioned correctly. Calling Chart1.Draw(); before Chart1.TeeCreateBitmap solves the problem. However, the problem is transferred to the real chart now! If you unzoom it you'll see the legend is positioned correctly then. It clearly needs being repainted. The chart worked fine in your example because TeeCreateBitmap also performs the repaint that the chart needed. Anyway, it would make more sense this code runs in the OnAfterDraw event. This doesn't improve the situation much as one single TChart.Draw call works for the image but changes the position at the original chart making 2 TChart.Draw calls necessary. We will investigate why this occur. In the meantime, I'm attaching the project with the modifications for this to work at the present moment.
Attachments
Image Wrong Size.zip
(5.31 KiB) Downloaded 634 times
Best Regards,
Narcís Calvet / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Image Image Image Image Image Image
Instructions - How to post in this forum

TestAlways
Advanced
Posts: 228
Joined: Tue Aug 28, 2007 12:00 am
Location: Oregon, USA

Re: Events make chart the wrong size, image rendered incorrectly

Post by TestAlways » Fri Mar 21, 2014 3:20 pm

Thank you.

Note that this example worked in a previous version of TChart (2013.?) and this code was created years ago when I asked how to achieve this.

Ed Dressel

TestAlways
Advanced
Posts: 228
Joined: Tue Aug 28, 2007 12:00 am
Location: Oregon, USA

Re: Events make chart the wrong size, image rendered incorrectly

Post by TestAlways » Fri Mar 21, 2014 6:05 pm

Your demo worked fine and I reviewed the code changes. Then when I implemented in my main app, it doesn't work. Attached. I don't know what I am doing wrong.

I created the attached example.

#2: It actually has an old "bug" (may you are not calling it that) that I raised some years ago. If the area series is transparent, then the symbol for the series must be custom drawn otherwise it does not match the color of the series.

Ed Dressel
Attachments
Legend Pos.zip
(2.88 KiB) Downloaded 610 times

Post Reply