Page 1 of 1

Easy way to reverse Legend Items or reverse pie drawing

Posted: Tue Jan 09, 2007 9:11 pm
by 9347345
I have a minor issue that seems to require a lot of work to change. I noted that pie graphs start with the first pie piece created at 180 degrees and populates counter clockwise. When I use a half pie as a 'gauge' the left most pie piece corresponds to the bottom legend item, but is the first item for my graph. I need it to be reversed so it shows first. I tried using exchange, but it seems to need to be called after all items are drawn. Is there a way I can override the default drawing and populate the legend manually? Or is there a way to make the pie graphs start drawing from the left and populating clockwise?
Thanks,
Rick

Posted: Wed Jan 10, 2007 8:59 am
by narcis
Hi Rick,

Have you tried using inverted legend?

Code: Select all

  Chart1.Legend.Inverted:=true;

Perfect

Posted: Wed Jan 10, 2007 2:48 pm
by 9347345
I didn't even know that was an option. Thanks so much.

One more question. I have the following code for printing the graph:

Graph1 := TChart1(G1);
Meta := Graph1.TeeCreateMetafile(True, Rect(0, 0, Graph1.Width, Graph1.Height));
try
Canvas.StretchDraw(CRect, Meta);
finally
end;
finally
Meta.Free;
end;

When I print with this function the Legend colored symbols print out excessively wide and I can't figure out how to resize them to normal as they appear on the screen. Everything else prints normal size. Any ideas?

Thanks again,
Rick

Posted: Mon Jan 15, 2007 10:34 am
by Pep
Hi Rick,

are you modifying any legend symbol settings ? Using the following code it prints out fine here :

Code: Select all

procedure TForm1.BitBtn1Click(Sender: TObject);
var meta : TMetafile;
begin
   Chart1.BevelOuter := bvNone;
   Meta := Chart1.TeeCreateMetafile(True, Chart1.ClientRect);
   try
      Printer.Orientation := poPortrait;
      Printer.BeginDoc;
      try
         Printer.Canvas.StretchDraw(Rect(1,1,Printer.PageWidth - 1,
         Printer.PageHeight - 1),Meta);
      finally
         Printer.EndDoc;
      end;
   finally
      Meta.Free;
      Chart1.BevelOuter := bvRaised;
   end;
end;