Page 1 of 1
legend properties
Posted: Wed Apr 04, 2018 12:08 am
by 16582473
I have asked related questions earlier but I am still having problems. Current one is how to control the relative sizes in the legend of the symbol and the line for a lineseries. Here is a sample of the problem:
- legend.PNG (1.24 KiB) Viewed 11387 times
The red line is too short (or the symbol too large) for the first item. The second correctly has no line and the third no symbol. Same problem if I have the legend on the right. I would in general prefer the lines to be a little longer rather than reducing the symbol size in the legend. Is that possible?
Somewhat unrelated: in some of my charts the lines in the legend are all black even though they are different colors in the chart. I don't see much difference in my code. Might I have accidentally turned off some option to suppress the colors in the legend?
Thanks,
Jim
Re: legend properties
Posted: Wed Apr 04, 2018 6:55 am
by 16582473
I seem to have found a solution but it seems illogical. By increasing the variable chart.legend.symbol.width it makes the line (not the symbol) larger. Is that a feature or a bug?
Jim
Re: legend properties
Posted: Wed Apr 04, 2018 1:09 pm
by yeray
Hello Jim,
Have you tried incrementing the symbols width?
By default, WidthUnits is set to lcsPercent and Width is set to 20. Changing WidthUnits to lcsPixels looks better for this example:
- Project3_2018-04-04_15-10-41.png (5.09 KiB) Viewed 11359 times
Code: Select all
uses Series;
procedure TForm1.FormCreate(Sender: TObject);
var i: Integer;
begin
Chart1.View3D:=False;
for i:=0 to 2 do
with Chart1.AddSeries(TLineSeries) as TLineSeries do
begin
FillSampleValues;
Pointer.Style:=psCircle;
Pointer.Visible:=i<2;
LinePen.Visible:=i<>1;
end;
Chart1.Legend.Symbol.Squared:=False;
Chart1.Legend.Symbol.WidthUnits:=lcsPixels;
end;
Re: legend properties
Posted: Wed Apr 04, 2018 6:08 pm
by 16582473
That works but why does making the symbol wider make the line longer? Perhaps the "symbol" means the display of both the marker and the line and not just the marker symbol?
Re: legend properties
Posted: Thu Apr 05, 2018 8:21 am
by yeray
JimR wrote:That works but why does making the symbol wider make the line longer? Perhaps the "symbol" means the display of both the marker and the line and not just the marker symbol?
Yes, the legend symbol refers to the space / column in the legend reserved for the symbol to be drawn. The symbol can be a pointer (circle, square,...), a pointer with a line, or a line.