Page 1 of 1

2nd legend not visible

Posted: Wed Nov 11, 2015 11:16 pm
by 16573190
In a previous version of TChart, I used the following code to create a second legend:

Code: Select all

          lsrs := CreateBarSeries('none', lChart, clNone, 0);
          lsrs.Active := false;
          lsrs.AddNull('Pre-Tax');
          lsrs.AddNull('Roth');

          lChart.Legend.Symbol.Width := 45;

          lExtraLegend := TExtraLegendTool.Create(self);
          lExtraLegend.ParentChart := lChart;
          lExtraLegend.Legend.CustomPosition := True;
          lExtraLegend.Legend.LegendStyle := lsValues;
          lExtraLegend.Legend.Transparent := True;
          lExtraLegend.Legend.Symbol.OnDraw := AccumChartLegendDrawAccountSymbols;
          lExtraLegend.Legend.TextStyle := ltsPlain;
          lExtraLegend.Series := lsrs;
          lExtraLegend.Active := True;
          lExtraLegend.Legend.Symbol.Width := 45;

          lChart.OnGetLegendText  := BPAccumChartLegendText;
          lExtraLegend.Legend.Title.Text.Text := 'Accounts';

          lChart.OnBeforeDrawSeries := BPAccumChartBeforeDrawSeries;
And I got the following result (which is what I want):

Image

But this does not work in the current version I am using--it only shows one legend symbol (the blue ones). (And, as you might expet, the BPAccumChartBeforeDrawSeries event is never called).

Here is the original post from which I got this answer from:

http://www.teechart.net/support/viewtop ... end#p58861

How do I add the second column of legend symbols?

Thank you,

Ed Dressel

Re: 2nd legend not visible

Posted: Thu Nov 12, 2015 9:26 am
by yeray
Hello Ed,

The code above is incomplete. Could you please arrange a simple example project we can run as-is to reproduce the problem here?
Ie, I read "Rates of Return" in the image you posted with the desired result but I don't find that text in the code you posted.

The project here looks like this for me here:
legend.png
legend.png (29.1 KiB) Viewed 11865 times

Re: 2nd legend not visible

Posted: Thu Nov 12, 2015 4:03 pm
by 16573190
I was using v. 15 and have changed to v. 16 and get the same results you do from the demo

But in a previous version of TChart, I got the two different symbols under "Rates of Return" in my first image. How can I get the second column of symbols?

Image

Thank you,

Ed Dressel

Re: 2nd legend not visible

Posted: Fri Nov 13, 2015 3:47 pm
by yeray
Hello,
TestAlways wrote:But in a previous version of TChart, I got the two different symbols under "Rates of Return" in my first image. How can I get the second column of symbols?
Could you please post an example showing how did you achieve that result with v2015.15?

Re: 2nd legend not visible

Posted: Fri Nov 13, 2015 5:17 pm
by 16573190
The attached demo can create the following image in 2013.09.131119:

Image

FYI--this is what I need (it would be nice to have less margin between the two legends).

Re: 2nd legend not visible

Posted: Mon Nov 16, 2015 10:45 am
by yeray
Hello,

From v2014.10 to v2015.15 the ExtraLegend wasn't shown (id=755).

Regarding the symbols you are manually drawing, note before v2014.11 the Legend.Symbol.Square property was false by default and we moved it to true from that version. This makes your symbols to be squared and the width is incorrect for your purpose.
Add these lines to your TForm1.Create to fix that:

Code: Select all

  Chart1.Legend.Symbol.Squared:=false;
  FExtraLegend.Legend.Symbol.Squared:=false;