Events make chart the wrong size, image rendered incorrectly

TeeChart VCL for Borland/CodeGear/Embarcadero RAD Studio, Delphi and C++ Builder.
Yeray
Site Admin
Site Admin
Posts: 9514
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 24, 2014 3:02 pm

Hello Ed,
TestAlways wrote: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.
Yes, and thanks to your projects we could reproduce it and we are trying to give you options to make it work as you desire with the latest version at the same time we investigate if we consider it as a bug or if it's an expectable behaviour.
TestAlways wrote: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.
This is what I get with v2014.10:
v2014.10.png
v2014.10.png (10.87 KiB) Viewed 12593 times
This is what I get with the actual sources (and also with the sources I sent you the 13th March):
v2014.11.png
v2014.11.png (15.11 KiB) Viewed 12592 times
Aren't you getting this with the sources from the 13th March?
TestAlways wrote:#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.
We found the cause of this and modified the sources so the next version will show the transparency in the symbol if the series has it.
However, it would be helpful if you could tell us where did you report it. I can't find it either here nor in the tracker. Just to look for the trace of the issue/ticket.
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 » Mon Mar 24, 2014 3:12 pm

I sincerely appreciate your responsiveness.
Yeray wrote:Aren't you getting this with the sources from the 13th March?
Yes. And there are two images of concern--the chart image and the bitmap created. They are both wrong. Here is a an image--note the legend in the second one.

Image
Yeray wrote:However, it would be helpful if you could tell us where did you report it. I can't find it either here nor in the tracker. Just to look for the trace of the issue/ticket.
http://www.teechart.net/support/viewtop ... ransparent

Ed Dressel

Yeray
Site Admin
Site Admin
Posts: 9514
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 24, 2014 4:40 pm

Hi Ed,
TestAlways wrote:
Yeray wrote:Aren't you getting this with the sources from the 13th March?
Yes. And there are two images of concern--the chart image and the bitmap created. They are both wrong. Here is a an image--note the legend in the second one.
I'm a bit confused. When I run the project you attached in this post I get the images you can see in the reply to that post. However, the images you just posted seem to be from the project of the beginning of the thread, that we thought were fixed with March 13th sources and the solution Narcís proposed here.

So I'm not sure to understand if the project you attached in this post was to still reproduce the problem of the legend position/size, the transparency in the legend symbol, or both (I reproduced the transparency problem in the symbol legend with the latest sources but not the first one). So I'm not sure to understand what exact problem do you still reproduce with the March 13th sources.

Please, try to summarize the problem you are still reproducing with the latest sources you have so I can get back on track :P
TestAlways wrote:
Yeray wrote:However, it would be helpful if you could tell us where did you report it. I can't find it either here nor in the tracker. Just to look for the trace of the issue/ticket.
http://www.teechart.net/support/viewtop ... ransparent
Thanks, I've copied the ticket from the old system to the new tracker so you can follow it's status:
http://bugs.teechart.net/show_bug.cgi?id=663

We've applied the fix but still doubting if this is the best solution: We agree the legend symbol should look as similar as possible to the series, but while a transparency may look nice inside the ChartRect, it may look bad out of it depending on the background color/gradient/image you may have.
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 » Mon Mar 24, 2014 4:48 pm

The code that produced the image is attached. I am using the latest source code.
Attachments
Image Wrong Size fix.zip
(2.8 KiB) Downloaded 582 times

Yeray
Site Admin
Site Admin
Posts: 9514
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 » Tue Mar 25, 2014 9:49 am

Hi Ed,

At the end of this project I see this:

Code: Select all

  Chart1.Draw();
  //Chart1.Draw();
I understand this is what Narcís explained above:
Narcís wrote: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.
If I run the project as it is with the latest sources, this is what I get:
1_Draw.png
1_Draw.png (36.71 KiB) Viewed 12550 times
But, if I uncomment the second Draw:

Code: Select all

  Chart1.Draw();
  Chart1.Draw();
Or if I use Draw+Repaint:

Code: Select all

  Chart1.Draw();
  Chart1.Repaint();
Then, this is what I get:
2_Draws.png
2_Draws.png (39.93 KiB) Viewed 12549 times
Isn't this what you'd like to get?
Isn't this what you get with March 13th sources?
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 » Tue Mar 25, 2014 3:07 pm

Yes, that fixes the problem.

Sigh. The update does introduce another problem. I get an exception, "Control has no parent window". This is from similar code that I have used for years.

I've attached a demo.

Ed Dressel
Attachments
No Parent Control.zip
(4.72 KiB) Downloaded 553 times

Yeray
Site Admin
Site Admin
Posts: 9514
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 » Tue Mar 25, 2014 3:15 pm

Hi Ed,

Please check the project. In Unit1.pas some functions are declared but not implemented:

Code: Select all

    procedure UpdateGapChart(const aRenderWithEvents: boolean);
    procedure GapChartBeforeDrawSeries(Sender: TObject);
And a method UpdateImage is being called both at btnUpdateImageClick and Resize but I can't find this method anywhere.
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 » Tue Mar 25, 2014 3:21 pm

Just saw that. My apologies.

Correct code attached.
Attachments
No Parent Control.zip
(4.75 KiB) Downloaded 599 times

Yeray
Site Admin
Site Admin
Posts: 9514
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 » Wed Mar 26, 2014 3:19 pm

Hi Ed,
TestAlways wrote:Correct code attached.
I see this is a different problem. I understand this is related for you because the changes in the last versions imply that now you must force not only one but two chart Draws before calling TeeCreateBitmap, but I see doing so has always crashed in a chart without parent:
http://bugs.teechart.net/show_bug.cgi?id=667
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: 9514
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 27, 2014 8:34 am

Yeray wrote:I see this is a different problem. I understand this is related for you because the changes in the last versions imply that now you must force not only one but two chart Draws before calling TeeCreateBitmap, but I see doing so has always crashed in a chart without parent:
http://bugs.teechart.net/show_bug.cgi?id=667
As you'll see, we already have a fix for the bug 667.

However, if I apply it to the project you attached above, I don't get the error any more, but I get a wrong Legend again.
This happens because the Draw we forced doesn't know what size will be applied later in the TeeCreateBitmap. It can be easily fixed substituting the lChart.Draw by this:

Code: Select all

lChart.Draw(lChart.Canvas.ReferenceCanvas, lRect);
I even only need one call to get a correct Legend.
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