D6Pro, Teechart 8.01
Chart with several tlineseries on, the legendstyle is set to LSseries so that I get a coloured point and a text title in the legend for for each series.
I'm drawing the series as dots of X,Y scatter plots, so no lines joining the dots. The dots are controlled with
pointer.size:=2
seriescolor:=acolor
coloreachpoint:=false;
So series-1 are red dots, series-2 is blue dots.
My problem is that the size of the dot drawn in the legend next to the series titel in the legend is linked to the pointer.size. So if i add a spin edit to adjust pointer.size the dot drawn in the legend tracks this as ewll as the dots on the chart. I want to draw the dots in the legend at a fixed size that is not affected by changing pointer.size. Something like legend.pointersize:=3;
is there a way to do this please?
cheers
Sean
Size of items in legend
-
- Newbie
- Posts: 19
- Joined: Thu Sep 27, 2007 12:00 am
- Location: UK
- Contact:
Hi Sean,
I've made an example of how could you do this using an event to draw your rectangles directly to the canvas. It's similar to the demo "Symbol OnDraw":
I've made an example of how could you do this using an event to draw your rectangles directly to the canvas. It's similar to the demo "Symbol OnDraw":
Code: Select all
...
type
...
private
{ Private declarations }
procedure LegendDraw(Sender: TObject; Series:TChartSeries; ValueIndex:Integer; R:TRect);
...
procedure TForm1.FormCreate(Sender: TObject);
var i: integer;
begin
for i:= 0 to 9 do
begin
Series1.AddXY(i,random(100));
Series2.AddXY(i,random(100));
end;
Series1.Pointer.Size := 5;
Series2.Pointer.Size := 5;
Series1.ColorEachPoint := false;
Series2.ColorEachPoint := false;
Series1.SeriesColor := clRed;
Series2.SeriesColor := clBlue;
// Set event to display custom legend symbols:
Chart1.Legend.Symbol.OnDraw:=LegendDraw;
end;
procedure TForm1.LegendDraw(Sender: TObject; Series:TChartSeries; ValueIndex:Integer; R:TRect);
var tmpRect : TRect;
const extra=-2;
begin
Chart1.Canvas.Brush.Color:=Series.Color;
Chart1.Canvas.Pen.Color:=clBlack;
tmpRect.Left:=R.Left;
tmpRect.Top:=R.Top;
tmpRect.Right:=R.Right+extra;
tmpRect.Bottom:=R.Bottom+extra;
Chart1.Canvas.Rectangle(tmpRect);
end;
Best Regards,
Yeray Alonso Development & Support Steema Software Av. Montilivi 33, 17003 Girona, Catalonia (SP) | |
Please read our Bug Fixing Policy |