Page 1 of 1

Printing & Chart AfterDraw strange behavior

Posted: Sun Aug 13, 2006 10:53 pm
by 9344832
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;

Posted: Mon Aug 14, 2006 8:55 am
by Pep
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');