Printing & Chart AfterDraw strange behavior

TeeChart VCL for Borland/CodeGear/Embarcadero RAD Studio, Delphi and C++ Builder.
Post Reply
marc_x
Newbie
Newbie
Posts: 3
Joined: Mon Jan 09, 2006 12:00 am

Printing & Chart AfterDraw strange behavior

Post by marc_x » Sun Aug 13, 2006 10:53 pm

hi,

I am adding text to the chart on the AfterDraw event. when printing the text is realy oversized unless I select the smooth checkbox in the preview dialog. How can this be fixed and how are printing properties such as Smooth set with code.

here is the Afterdraw code in case needed
sorry for the formatting...

Thanks


SavedFont:= TFont.Create;
try
SavedFont.Assign(ChartAnalysis.Canvas.Font);

for i:= 0 to DataFile.NumSensors - 1 do
begin
aSerie := FastLineSeries(FindComponent(DataFile.Sensors.SensorInfo.siName));

if ((aSerie = nil) or (aSerie.Visible = false)) then
Continue;

XPos:= aSerie.GetHorizAxis.IEndPos + 5;
YPos:= aSerie.CustomVertAxis.IStartPos;

if (FCalcResultUseSeriesColor = true) then
ChartAnalysis.Canvas.Font.Color:= aSerie.Color;

ChartAnalysis.Canvas.Font.Name:= 'courier new';
ChartAnalysis.Canvas.Font.Size:= 8;

aStr:= '000.0 000.0';
ChartAnalysis.Canvas.TextOut(XPos, YPos, aStr);

aStr:= '000.0 000.0 000.0';
YPos := aSerie.CustomVertAxis.IStartPos +
((aSerie.CustomVertAxis.IEndPos -
aSerie.CustomVertAxis.IStartPos) div 2) + 2;

ChartAnalysis.Canvas.TextOut(XPos, YPos, aStr);
end;

finally
ChartAnalysis.Canvas.Font.Assign(SavedFont);
SavedFont.Free;
end;

Pep
Site Admin
Site Admin
Posts: 3299
Joined: Fri Nov 14, 2003 5:00 am
Contact:

Post by Pep » Mon Aug 14, 2006 8:55 am

Hi Marc,

the problem is you're using Canvas.Font.Size to set font "size", when printing, you should always use Font.Height instead of Font.Size.

Something like this (placed in TChart OnAfterDraw event) should work:

Chart1.Canvas.Font.Height = -13; // note the - sign!
Chart1.Canvas.TextOut(100,100,'Hello World');

Post Reply