I'm having a problem with Tee Chart, which doesn't appear to have been
addressed in version 5.
The chart printing routine I've developed is shown below. The resizing
ensures that the correct font / pen settings are used, whatever the printer
settings. The routine works fine for all chart / series types - except for
pie charts. The chart is printed as an oval - even when it's Circled
property is set to true.
Can anyone offer an solution to this problem, or an alternative method for
printing pie charts in a specified printer rectangle that maintains font and
pen settings ?
Thanks
John Leavey
Procedure CopySeries( DestChart, SourceChart:TChart );
Var
tmpSeries: TChartSeries;
tmpS: TChartSeriesClass;
i: Integer;
begin
for i := 0 to SourceChart.SeriesCount - 1 do
begin
tmpS := TChartSeriesClass( SourceChart.Series[i].ClassType );
tmpSeries := tmpS.Create( DestChart );
tmpSeries.Assign( SourceChart.Series[ i ] );
DestChart.AddSeries( tmpSeries );
end;
end;
procedure PrintChartInRect( Chart: TChart; R: TRect );
var
H, W, MapMode, i: Integer;
XRatio, YRatio: Double;
tmpChart: TChart;
begin
tmpChart := TChart.Create( Application );
try
tmpChart.Parent := Application.MainForm;
tmpChart.Visible := False;
tmpChart.Assign( Chart );
// this property doesn't seem to be set properly by assign
tmpChart.Legend.ShadowSize := Chart.Legend.ShadowSize;
CopySeries( tmpChart, Chart );
H := ( R.Bottom - R.Top );
W := ( R.Right - R.Left );
XRatio := GetDeviceCaps( Printer.Handle, LOGPIXELSX ) /
Screen.PixelsPerInch;
YRatio := GetDeviceCaps( Printer.Handle, LOGPIXELSY ) /
Screen.PixelsPerInch;
tmpChart.Width := Round( W / XRatio );
tmpChart.Height := Round( H / YRatio );
MapMode := GetMapMode( Printer.Handle );
tmpChart.PrintPartial( R );
SetMapMode( Printer.Handle, MapMode );
finally
tmpChart.Free;
end;
end;