Page 1 of 1

custom legend

Posted: Thu Nov 09, 2006 3:50 pm
by 9231397
D6Pro, Teechart 7.07, Chart with 4 lineseries. I would like to customise the legend so that I can add a columns for stats, so it could show say the average, and maybe the standard deviation and min and max. Is there a recommended way to do this?

thanks
Sean

Posted: Fri Nov 10, 2006 8:38 am
by narcis
Hi Sean,

It may help you doing something like the examples below in the features demo:

All Features\Welcome!\Miscellaneous\Legend\Drawing more text
All Features\Welcome!\Miscellaneous\Legend\Multiple legends

You'll find the features demo at the program group created by the binary installer.

Posted: Tue Nov 14, 2006 10:16 pm
by 9231397
thanks, but I'm still having trouble. I have 32 Teecharts, each with one lineseries, the chartys stacked one above the other on a form. all charts are same height and width. I need all series and x-axes to align vertiocally, and all legends to align vertically.

I've got

procedure TLineplotfrm.Chart1GetLegendPos(Sender: TCustomChart;
Index: Integer; var X, Y, XColor: Integer);
begin
with charts[1].Legend do
customposition:=true;
x:=charts[1].width-100;
xcolor:=x-15;
end;

and this gives the alignment for charts and legends. But I can't see how to add columns to the legend. there is a demo which shows

chart1.legend.columnwidhs[0]:=
chart1.legend.columnwidhs[1]:=

but how do I add text to the columns.

I tried using the afterdraw of the charts with
with charts[1].Legend.shapebounds do
begin
WITH charts[1].Canvas do
begin
textalign:=ta_left;
font.Size:=8;
textout(charts[1].legend.left+30,bottom,'Text-1');
textout(left+30,bottom+10,'Text-2');
end;
end;

but this doesn't track correctly when the chart/form is resized in X, so it moves in its vertical alignment the series titles in the legend. I supect in the afterdraw I'm not getting the correct position of the legend.

thanks
Sean

Posted: Tue Nov 21, 2006 12:39 pm
by Pep
Hi Sean,

I'm afraid that seeing the manner you want to get texts in the legend, the best way would be to draw your custom legend (using the Canvas techniques) directly onto the Chart canvas and not to use the Chart.Legend.