In our case, tmpR is always (0,0,0,0). The problem with that is that you are calling Axis.AdjustMaxMinRect(0,0,0,0), probably assuming it will not do anything. But it does. In my case, before this method call, the Axis.MinimumValue is zero, as is the Axis.IMinimum.
However, when calling RecalcAdjustedMinMax, you recalculate IMinimum based on the the "adjusted" IStart value, which is the same as the regular IStart (in my case, pixel 37). However, due to rounding errors that occur when converting from pixel to double, the new IMinimum becomes ~0.002.... This would not be a problem, except that in OnGetNextAxisLabel, I use the Axis.MimimumValue as the basis for my calculations, and return 0 as my first label. When I return 0 as the next label value, DoCustomLabels stops drawing any more labels, because 0<0.002 and LabelInside=False;
see in DoCustomLabels
Code: Select all
LabelInside:=(tmpValue>=(IMinimum-DifFloat)) and
(tmpValue<=(IMaximum+DifFloat));
Code: Select all
procedure ApplyMaxMinOffsets;
var tmpHasOffsets : Boolean;
begin
tmpHasOffsets:=(Axis.MaximumOffset<>0) or (Axis.MinimumOffset<>0);
if tmpHasOffsets then
[b]begin // begin added by dns[/b]
if Axis.Horizontal then ApplyOffsets(tmpR.Left,tmpR.Right)
else ApplyOffsets(tmpR.Bottom,tmpR.Top);
Axis.AdjustMaxMinRect(tmpR);
Axis.CalcRoundScales;
if tmpHasOffsets then
with Axis do
FPosTitle:=InflateAxisPos(FPosLabels,SizeLabels);
[b] end;// end added by dns[/b]
end;
Code: Select all
Procedure TChartAxis.AdjustMaxMinRect(Const Rect:TRect);
var tmpMin : Double;
tmpMax : Double;
Procedure RecalcAdjustedMinMax(Pos1,Pos2:Integer);
var OldStart : Integer;
OldEnd : Integer;
Begin
OldStart :=IStartPos;
OldEnd :=IEndPos;
Inc(IStartPos,Pos1);
Dec(IEndPos,Pos2);
IAxisSize:=IEndPos-IStartPos;
tmpMin:=CalcPosPoint(OldStart);
tmpMax:=CalcPosPoint(OldEnd);
end;
Begin
[b] // added by dns
if (rect.Left=0) and (rect.Top=0) and (rect.right=0) and (rect.Bottom=0) then
exit;[/b]
with Rect do
if Horizontal then ReCalcAdjustedMinMax(Left,Right)
else ReCalcAdjustedMinMax(Top,Bottom);
InternalCalcPositions;
IMaximum:=tmpMax;
IMinimum:=tmpMin;
if IMinimum>IMaximum then
SwapDouble(IMinimum,IMaximum);
InternalCalcRange;
end;