Page 1 of 1

Legend with Checkbox misaligned

Posted: Tue Jan 21, 2014 9:29 am
by 10051555
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 5611 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 5606 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.

Re: Legend with Checkbox misaligned

Posted: Wed Jan 22, 2014 3:37 pm
by yeray
Hi,

I'm trying to reproduce this with the following project but I can't:
testLegend.zip
(1.38 KiB) Downloaded 317 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.

Re: Legend with Checkbox misaligned

Posted: Wed Jan 22, 2014 6:50 pm
by 10051555
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.

Re: Legend with Checkbox misaligned

Posted: Thu Jan 23, 2014 11:34 am
by yeray
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 326 times

Re: Legend with Checkbox misaligned

Posted: Thu Jan 23, 2014 2:25 pm
by 10051555
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?

Re: Legend with Checkbox misaligned

Posted: Fri Jan 24, 2014 12:16 pm
by yeray
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.