procedure TChart.Draw(ADrawer: IChartDrawer; const ARect: TRect);
var
tools: TBasicChartToolset;
ldd: TChartLegendDrawingData;
s: TBasicChartSeries;
begin
Prepare;
ADrawer.SetRightToLeft(BiDiMode <> bdLeftToRight);
FClipRect := ARect;
with MarginsExternal do begin
FClipRect.Left += Left;
FClipRect.Top += Top;
FClipRect.Right -= Right;
FClipRect.Bottom -= Bottom;
end;
with ClipRect do begin
FTitle.Measure(ADrawer, 1, Left, Right, Top);
FFoot.Measure(ADrawer, -1, Left, Right, Bottom);
end;
ldd.FItems := nil;
if Legend.Visible then
ldd := PrepareLegend(ADrawer, FClipRect);
try
PrepareAxis(ADrawer);
if Legend.Visible and not Legend.UseSidebar then
Legend.Prepare(ldd, FClipRect);
if (FPrevLogicalExtent <> FLogicalExtent) and Assigned(OnExtentChanging) then
OnExtentChanging(Self);
ADrawer.DrawingBegin(ARect);
ADrawer.SetAntialiasingMode(AntialiasingMode);
Clear(ADrawer, ARect);
FTitle.Draw(ADrawer);
FFoot.Draw(ADrawer);
DrawBackWall(ADrawer);
DisplaySeries(ADrawer);
if Legend.Visible then begin
if Assigned(FOnDrawLegend) then
FOnDrawlegend(Self, ldd.FDrawer, ldd.FItems, ldd.FItemSize, ldd.FBounds,
ldd.FColCount, ldd.FRowCount)
else
Legend.Draw(ldd);
end;
finally
ldd.FItems.Free;
end;
DrawReticule(ADrawer);
//GetToolset.Draw(Self, ADrawer);
tools := getToolSet;
if Assigned(tools) then tools.Draw(self, ADrawer);
for s in Series do
s.AfterDraw;
if Assigned(OnAfterDraw) then
OnAfterDraw(Self, ADrawer);
ADrawer.DrawingEnd;
if FPrevLogicalExtent <> FLogicalExtent then begin
FExtentBroadcaster.Broadcast(Self);
if Assigned(OnExtentChanged) then
OnExtentChanged(Self);
FPrevLogicalExtent := FLogicalExtent;
end;
// Undo changes made by the drawer (mainly for printing). The user may print
// something else after the chart and, for example, would not expect the font
// to be rotated (Fix for issue #0027163) or the pen to be in xor mode.
ADrawer.ResetFont;
ADrawer.SetXor(false);
ADrawer.PrepareSimplePen(clBlack); // resets canvas pen mode to pmCopy
ADrawer.SetPenParams(psSolid, clDefault);
ADrawer.SetBrushParams(bsSolid, clWhite);
ADrawer.SetAntialiasingMode(amDontCare);
end;