Page 1 of 1

Setting Legend.VertSpacing causes wider Symbol

Posted: Tue Aug 22, 2017 8:14 pm
by 16579693
TChart 2016.18.160504

In the attached demo, a bitmap created from a TChart is copied to a TImage. The problem is the legend' symbol for each series is not square. They are too long.

Remove this line:

lChart.Legend.VertSpacing := 40;

and it works fine--except the vertical spacing is too tight.

Is this fixed in the latest version? (The latest version breaks our existing code so it is not easy to test).

Thank you,

Ed Dressel

Re: Setting Legend.VertSpacing causes wider Symbol

Posted: Wed Aug 23, 2017 11:22 am
by yeray
Hello,

I could reproduce the problem you reported with the latest version, v2017.22 so I've added it to the public tracker:
http://bugs.teechart.net/show_bug.cgi?id=1908

I've also fixed it, so the ticket is already closed (the next maintenance release will include the fix).

Since you own the sources, you can apply the fix to your copy of the sources and recompile. The fix consists on modifying the TLegendSymbol.CalcWidth at Chart.pas to this:

Code: Select all

Function TLegendSymbol.CalcWidth(Value:Integer):Integer;
begin
  if Visible then
     if Squared then
     begin
        result:=CalcHeight;

        if Assigned(Parent) and (Parent is TCustomChart) then
           result:=result - TCustomChart(Parent).Legend.VertSpacing;
     end
     else
     if FWidthUnits=lcsPercent then result:=Round(Width*Value*0.01)
                               else result:=Width
  else
     result:=0;
end;