TAChart: Measure "edge" marks correctly in the presence of axis transformations

git-svn-id: trunk@31772 -
This commit is contained in:
ask 2011-07-20 15:49:18 +00:00
parent 490ec0cbdc
commit 92659628f1
2 changed files with 5 additions and 4 deletions

View File

@ -433,7 +433,6 @@ procedure TChartAxis.Draw;
var var
fixedCoord: Integer; fixedCoord: Integer;
pv, v: Double; pv, v: Double;
axisTransf: TTransformFunc;
t: TChartValueText; t: TChartValueText;
begin begin
if not Visible then exit; if not Visible then exit;
@ -443,9 +442,8 @@ begin
pv := NaN; pv := NaN;
FHelper.BeginDrawing; FHelper.BeginDrawing;
FHelper.DrawAxisLine(AxisPen, fixedCoord); FHelper.DrawAxisLine(AxisPen, fixedCoord);
axisTransf := @GetTransform.AxisToGraph;
for t in FMarkValues do begin for t in FMarkValues do begin
v := axisTransf(t.FValue); v := FHelper.FAxisTransf(t.FValue);
FHelper.DrawMark(fixedCoord, v, t.FText); FHelper.DrawMark(fixedCoord, v, t.FText);
DrawMinors(fixedCoord, pv, v); DrawMinors(fixedCoord, pv, v);
pv := v; pv := v;
@ -597,7 +595,7 @@ begin
end; end;
pv := cv; pv := cv;
// Optimization: only measure edge labels to calculate longitudinal margins. // Optimization: only measure edge labels to calculate longitudinal margins.
c := FHelper.GraphToImage(cv); c := FHelper.GraphToImage(FHelper.FAxisTransf(cv));
if not InRange(c, rmin, rmax) then continue; if not InRange(c, rmin, rmax) then continue;
if c < minc then begin if c < minc then begin
minc := c; minc := c;
@ -634,6 +632,7 @@ begin
else else
FHelper := TAxisDrawHelperX.Create; FHelper := TAxisDrawHelperX.Create;
FHelper.FAxis := Self; FHelper.FAxis := Self;
FHelper.FAxisTransf := @GetTransform.AxisToGraph;
FHelper.FClipRect := AClipRect; FHelper.FClipRect := AClipRect;
FHelper.FDrawer := ADrawer; FHelper.FDrawer := ADrawer;
FHelper.FTransf := ATransf; FHelper.FTransf := ATransf;

View File

@ -179,6 +179,7 @@ type
function TryApplyStripes: Boolean; inline; function TryApplyStripes: Boolean; inline;
public public
FAxis: TChartBasicAxis; FAxis: TChartBasicAxis;
FAxisTransf: TTransformFunc;
FClipRect: ^TRect; FClipRect: ^TRect;
FDrawer: IChartDrawer; FDrawer: IChartDrawer;
FPrevCoord: Integer; FPrevCoord: Integer;
@ -255,6 +256,7 @@ function TAxisDrawHelper.Clone: TAxisDrawHelper;
begin begin
Result := TAxisDrawHelperClass(ClassType).Create; Result := TAxisDrawHelperClass(ClassType).Create;
Result.FAxis := FAxis; Result.FAxis := FAxis;
Result.FAxisTransf := FAxisTransf;
Result.FClipRect := FClipRect; Result.FClipRect := FClipRect;
Result.FDrawer := FDrawer; Result.FDrawer := FDrawer;
Result.FTransf := FTransf; Result.FTransf := FTransf;