Page 1 of 2

Events make chart the wrong size, image rendered incorrectly

Posted: Wed Mar 12, 2014 5:18 pm
by 10546565
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

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

Posted: Wed Mar 12, 2014 8:14 pm
by 16566253
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".

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

Posted: Thu Mar 13, 2014 2:54 pm
by yeray
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 20308 times
v2014.10.png
v2014.10.png (15.68 KiB) Viewed 20305 times
v2014.11.png
v2014.11.png (21.6 KiB) Viewed 20305 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.

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

Posted: Thu Mar 13, 2014 3:06 pm
by yeray
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.

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

Posted: Thu Mar 13, 2014 3:22 pm
by 10546565
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

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

Posted: Thu Mar 13, 2014 3:47 pm
by yeray
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.

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

Posted: Fri Mar 14, 2014 11:35 am
by yeray
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

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

Posted: Fri Mar 14, 2014 2:56 pm
by 10546565
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

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

Posted: Fri Mar 14, 2014 3:03 pm
by narcis
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.

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

Posted: Fri Mar 14, 2014 7:32 pm
by 16566253
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.

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

Posted: Mon Mar 17, 2014 11:37 am
by yeray
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!

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

Posted: Thu Mar 20, 2014 11:56 pm
by 10546565
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

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

Posted: Fri Mar 21, 2014 11:05 am
by narcis
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.

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

Posted: Fri Mar 21, 2014 3:20 pm
by 10546565
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

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

Posted: Fri Mar 21, 2014 6:05 pm
by 10546565
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