Legend with Checkbox misaligned

TeeChart VCL for Borland/CodeGear/Embarcadero RAD Studio, Delphi and C++ Builder.
Post Reply
Jubar
Newbie
Newbie
Posts: 7
Joined: Tue Jan 20, 2009 12:00 am

Legend with Checkbox misaligned

Post by Jubar » Tue Jan 21, 2014 9:29 am

TChart V8.08

I use legend with checkboxes positioned at the top.

When at run time the text is changed, the checboxes move into the text, even if ColumnWidthAuto=TRUE.
Then after some trials I found this to prevent that:

dbChart1.Legend.ColumnWidthAuto:=False;
dbChart1.Legend.ColumnWidths[0]:=100;
dbChart1.Draw;
dbChart1.Legend.Items[1].text:= '-modified-';
dbChart1.Draw;
tChart-Legend1.jpg
tChart-Legend1.jpg (94.67 KiB) Viewed 5616 times
But as soon as the Tchart width is changed at runtime, the checkboxes move over the text again
tChart-Legend2.jpg
tChart-Legend2.jpg (110 KiB) Viewed 5611 times
What can be done to prevent that?

P.S. This only happens once the text is changed.
When using the default text, the positions are always correct.

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

Re: Legend with Checkbox misaligned

Post by Yeray » Wed Jan 22, 2014 3:37 pm

Hi,

I'm trying to reproduce this with the following project but I can't:
testLegend.zip
(1.38 KiB) Downloaded 318 times
I can change the legend font size and then resize the chart without noticing any strange behaviour.
I checked it both with TeeChart v8 and the actual sources.

Could you please modify the project above so we can reproduce the problem here?
Thanks in advance.
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

Jubar
Newbie
Newbie
Posts: 7
Joined: Tue Jan 20, 2009 12:00 am

Re: Legend with Checkbox misaligned

Post by Jubar » Wed Jan 22, 2014 6:50 pm

Thanks Yeray,

Now do this:

Put a button on it with this code
Chart1.Legend.Items[1].text:= '-modified-';

Now you will see the effect that checkboxes are misplaced

Also: At runtime drag the right/left form border to make it wider / smaller, you will see that checkboxes are moved while the text-position remains unchanged.

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

Re: Legend with Checkbox misaligned

Post by Yeray » Thu Jan 23, 2014 11:34 am

Hi,

Right. With this, I can reproduce it now with TeeChart v8 even without changing the legend font.
However, I can't reproduce this with the actual version.
Here it is the new version of the testing application with an exe compiled with the latest TeeChart v2013.09
testLegend.zip
(429.85 KiB) Downloaded 327 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

Jubar
Newbie
Newbie
Posts: 7
Joined: Tue Jan 20, 2009 12:00 am

Re: Legend with Checkbox misaligned

Post by Jubar » Thu Jan 23, 2014 2:25 pm

Thanks Yeray,

Yes, you only need to change the text.

Your .exe works fine indeed.

Is there any workaround that I could do in V8.08 to get the same result?

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

Re: Legend with Checkbox misaligned

Post by Yeray » Fri Jan 24, 2014 12:16 pm

Hi,

I can't think on a workaround for this right now... other than completely hiding the legend and drawing it yourself manually.
For this, you should calculating the positions for each item. Then, you should use custom drawing methods to draw both the checkboxes and the texts in the calculated positions. You should use these custom drawing methods at the AfterDraw event.
And you should force a chart repaint each time the chart is resized so the new positions can be recalculated and the new positions drawn.
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